1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-24 06:59:52 +01:00

wombat: only fix window.parent on top frame if 'embeddable' is not set to true, allow for communication w/ embedding frame this way

This commit is contained in:
Ilya Kreymer 2015-08-07 18:21:37 -07:00
parent 6bf6a02868
commit 6dd432ab38

View File

@ -1769,9 +1769,10 @@ var wombat_internal = function($wbwindow) {
//============================================ //============================================
function wombat_init(wbinfo) { function wombat_init(wbinfo) {
init_top_frame($wbwindow);
wb_info = wbinfo; wb_info = wbinfo;
wb_opts = wbinfo.wombat_opts;
init_top_frame($wbwindow);
wb_replay_prefix = wbinfo.prefix; wb_replay_prefix = wbinfo.prefix;
if (wb_replay_prefix.indexOf($wbwindow.__WB_replay_top.location.origin) == 0) { if (wb_replay_prefix.indexOf($wbwindow.__WB_replay_top.location.origin) == 0) {
@ -1782,7 +1783,6 @@ var wombat_internal = function($wbwindow) {
wb_coll_prefix_check = wb_coll_prefix; wb_coll_prefix_check = wb_coll_prefix;
wbinfo.wombat_opts = wbinfo.wombat_opts || {}; wbinfo.wombat_opts = wbinfo.wombat_opts || {};
wb_opts = wbinfo.wombat_opts;
wb_curr_host = $wbwindow.location.protocol + "//" + $wbwindow.location.host; wb_curr_host = $wbwindow.location.protocol + "//" + $wbwindow.location.host;
@ -1911,17 +1911,14 @@ var wombat_internal = function($wbwindow) {
} }
} }
var replay_parent = $wbwindow;
var replay_top = $wbwindow; var replay_top = $wbwindow;
while ((replay_top.parent != replay_top) && check_frame(replay_top.parent, false)) { while ((replay_top.parent != replay_top) && check_frame(replay_top.parent, false)) {
replay_top = replay_top.parent; replay_top = replay_top.parent;
// Update parent first time
if (replay_parent == $wbwindow) {
replay_parent = replay_top;
}
} }
$wbwindow.__WB_replay_top = replay_top;
var real_parent = replay_top.__WB_orig_parent || replay_top.parent; var real_parent = replay_top.__WB_orig_parent || replay_top.parent;
if (real_parent != $wbwindow && check_frame(real_parent, true)) { if (real_parent != $wbwindow && check_frame(real_parent, true)) {
@ -1938,11 +1935,11 @@ var wombat_internal = function($wbwindow) {
$wbwindow.__WB_top_frame = undefined; $wbwindow.__WB_top_frame = undefined;
} }
$wbwindow.__WB_replay_top = replay_top; // Fix .parent only if not embeddable, otherwise leave for accessing embedding window
if (!wb_opts.embedded && (replay_top == $wbwindow)) {
$wbwindow.__WB_orig_parent = $wbwindow.parent; $wbwindow.__WB_orig_parent = $wbwindow.parent;
$wbwindow.parent = replay_top;
$wbwindow.parent = replay_parent; }
if (Object.defineProperty) { if (Object.defineProperty) {
var getter = function() { var getter = function() {