mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
wombat: better detection of top replay frame when in 'non-frame container' mode
avoids banner being accidentally added to inner frames!
This commit is contained in:
parent
22dc59f7c2
commit
08849a573b
@ -136,6 +136,7 @@ this.load = function() {
|
|||||||
|
|
||||||
window._wb_js_inited = true;
|
window._wb_js_inited = true;
|
||||||
|
|
||||||
|
// Non-Framed Replay OR top frame for framed replay!
|
||||||
if (window.wbinfo && (!window.__WB_top_frame || window.__WB_top_frame == window)) {
|
if (window.wbinfo && (!window.__WB_top_frame || window.__WB_top_frame == window)) {
|
||||||
if (wbinfo.is_framed && wbinfo.mod != "bn_") {
|
if (wbinfo.is_framed && wbinfo.mod != "bn_") {
|
||||||
var hash = window.location.hash;
|
var hash = window.location.hash;
|
||||||
@ -154,6 +155,7 @@ this.load = function() {
|
|||||||
// Init Banner (no frame or top frame)
|
// Init Banner (no frame or top frame)
|
||||||
add_event("readystatechange", init_banner, document);
|
add_event("readystatechange", init_banner, document);
|
||||||
|
|
||||||
|
// Framed Replay
|
||||||
} else if (window.__WB_top_frame && window != window.__WB_top_frame && window.__WB_top_frame.update_wb_url) {
|
} else if (window.__WB_top_frame && window != window.__WB_top_frame && window.__WB_top_frame.update_wb_url) {
|
||||||
add_event("readystatechange", notify_top, document);
|
add_event("readystatechange", notify_top, document);
|
||||||
}
|
}
|
||||||
|
@ -2111,17 +2111,28 @@ var wombat_internal = function($wbwindow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init_top_frame($wbwindow) {
|
function init_top_frame($wbwindow) {
|
||||||
function check_frame(win, frame) {
|
function next_parent(win) {
|
||||||
try {
|
try {
|
||||||
return (win && win.wbinfo && (!win.wbinfo.is_frame == !frame));
|
if (!win) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if no wbinfo, see if _wb_wombat was set (eg. if about:blank page)
|
||||||
|
if (!win.wbinfo) {
|
||||||
|
return (win._wb_wombat != undefined);
|
||||||
|
} else {
|
||||||
|
// otherwise, ensure that it is not a top container frame
|
||||||
|
return !win.wbinfo.is_frame;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) && next_parent(replay_top.parent)) {
|
||||||
replay_top = replay_top.parent;
|
replay_top = replay_top.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2129,7 +2140,7 @@ var wombat_internal = function($wbwindow) {
|
|||||||
|
|
||||||
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 && real_parent && real_parent.wbinfo && real_parent.wbinfo.is_frame) {
|
||||||
$wbwindow.__WB_top_frame = real_parent;
|
$wbwindow.__WB_top_frame = real_parent;
|
||||||
|
|
||||||
// Disable frameElement also as this should be top frame
|
// Disable frameElement also as this should be top frame
|
||||||
|
Loading…
x
Reference in New Issue
Block a user