1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +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:
Ilya Kreymer 2015-09-10 17:04:40 -07:00
parent 22dc59f7c2
commit 08849a573b
2 changed files with 18 additions and 5 deletions

View File

@ -136,6 +136,7 @@ this.load = function() {
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 (wbinfo.is_framed && wbinfo.mod != "bn_") {
var hash = window.location.hash;
@ -154,6 +155,7 @@ this.load = function() {
// Init Banner (no frame or top frame)
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) {
add_event("readystatechange", notify_top, document);
}

View File

@ -2111,17 +2111,28 @@ var wombat_internal = function($wbwindow) {
}
function init_top_frame($wbwindow) {
function check_frame(win, frame) {
function next_parent(win) {
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) {
return false;
}
}
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;
}
@ -2129,7 +2140,7 @@ var wombat_internal = function($wbwindow) {
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;
// Disable frameElement also as this should be top frame