mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
wombat reinit fix (#383)
* wombat init fix: - fix change from #339 which removed reiniting of wombat - allow reiniting of wombat if inited via init_new_window_wombat() - don't allow if reinited directly from <head>, as happened in document import * tests: fix tests for 'new _WBWombat -> WombatInit' change * wombat: window.frames optimization: - since window.frames === window, no need for separate override! - ensure init_new_window_wombat() is called on any returned window from object proxy
This commit is contained in:
parent
e7098522b2
commit
9f81933fbd
@ -2253,6 +2253,12 @@ var _WBWombat = function($wbwindow, wbinfo) {
|
|||||||
//============================================
|
//============================================
|
||||||
function override_frames_access($wbwindow)
|
function override_frames_access($wbwindow)
|
||||||
{
|
{
|
||||||
|
// If $wbwindow.frames is the window itself, nothing to override
|
||||||
|
// This can be handled in the Obj Proxy
|
||||||
|
if ($wbwindow.Proxy && $wbwindow === $wbwindow.frames) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$wbwindow.__wb_frames = $wbwindow.frames;
|
$wbwindow.__wb_frames = $wbwindow.frames;
|
||||||
|
|
||||||
var getter = function() {
|
var getter = function() {
|
||||||
@ -3543,6 +3549,9 @@ var _WBWombat = function($wbwindow, wbinfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type === "object" && retVal && retVal._WB_wombat_obj_proxy) {
|
} else if (type === "object" && retVal && retVal._WB_wombat_obj_proxy) {
|
||||||
|
if (retVal instanceof Window) {
|
||||||
|
init_new_window_wombat(retVal);
|
||||||
|
}
|
||||||
return retVal._WB_wombat_obj_proxy;
|
return retVal._WB_wombat_obj_proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4091,3 +4100,13 @@ var _WBWombat = function($wbwindow, wbinfo) {
|
|||||||
|
|
||||||
window._WBWombat = _WBWombat;
|
window._WBWombat = _WBWombat;
|
||||||
|
|
||||||
|
window._WBWombatInit = function() {
|
||||||
|
if (!this._wb_wombat || !this._wb_wombat.actual) {
|
||||||
|
this._wb_wombat = new _WBWombat(this, wbinfo);
|
||||||
|
this._wb_wombat.actual = true;
|
||||||
|
} else if (!this._wb_wombat) {
|
||||||
|
console.warn("_wb_wombat missing!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -374,3 +374,14 @@ var _WBWombat = function ($wbwindow, wbinfo) {
|
|||||||
|
|
||||||
window._WBWombat = _WBWombat;
|
window._WBWombat = _WBWombat;
|
||||||
|
|
||||||
|
window._WBWombatInit = function() {
|
||||||
|
if (!this._wb_wombat || !this._wb_wombat.actual) {
|
||||||
|
this._wb_wombat = new _WBWombat(this, wbinfo);
|
||||||
|
this._wb_wombat.actual = true;
|
||||||
|
} else if (!this._wb_wombat) {
|
||||||
|
console.warn("_wb_wombat missing!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,10 +44,8 @@
|
|||||||
|
|
||||||
wbinfo.wombat_opts = {};
|
wbinfo.wombat_opts = {};
|
||||||
|
|
||||||
if (window && window._WBWombat && !window._wb_wombat) {
|
if (window && window._WBWombatInit) {
|
||||||
window._wb_wombat = new _WBWombat(window, wbinfo);
|
window._WBWombatInit();
|
||||||
} else if (!window._wb_wombat) {
|
|
||||||
console.warn("_wb_wombat missing!");
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -101,7 +101,7 @@ class TestWbIntegration(BaseConfigTest):
|
|||||||
|
|
||||||
assert '"20140127171238"' in resp.text, resp.text
|
assert '"20140127171238"' in resp.text, resp.text
|
||||||
assert 'wombat.js' in resp.text
|
assert 'wombat.js' in resp.text
|
||||||
assert 'new _WBWombat' in resp.text, resp.text
|
assert '_WBWombatInit' in resp.text, resp.text
|
||||||
assert '/pywb/20140127171238{0}/http://www.iana.org/time-zones"'.format(fmod) in resp.text
|
assert '/pywb/20140127171238{0}/http://www.iana.org/time-zones"'.format(fmod) in resp.text
|
||||||
|
|
||||||
if fmod == 'mp_':
|
if fmod == 'mp_':
|
||||||
|
@ -73,7 +73,7 @@ class TestMemento(MementoMixin, BaseConfigTest):
|
|||||||
# Body
|
# Body
|
||||||
assert '"20140127171238"' in resp.text
|
assert '"20140127171238"' in resp.text
|
||||||
assert 'wombat.js' in resp.text
|
assert 'wombat.js' in resp.text
|
||||||
assert 'new _WBWombat' in resp.text, resp.text
|
assert 'WBWombatInit' in resp.text, resp.text
|
||||||
assert '/pywb/20140127171238{0}/http://www.iana.org/time-zones"'.format(fmod) in resp.text
|
assert '/pywb/20140127171238{0}/http://www.iana.org/time-zones"'.format(fmod) in resp.text
|
||||||
|
|
||||||
def test_memento_at_timegate_latest(self, fmod):
|
def test_memento_at_timegate_latest(self, fmod):
|
||||||
|
@ -38,7 +38,7 @@ class TestPrefixedDeploy(BaseConfigTest):
|
|||||||
assert "'http://localhost:80/prefix/static/default_banner.js'" in resp.text
|
assert "'http://localhost:80/prefix/static/default_banner.js'" in resp.text
|
||||||
assert '"http://localhost:80/prefix/static/"' in resp.text
|
assert '"http://localhost:80/prefix/static/"' in resp.text
|
||||||
assert '"http://localhost:80/prefix/pywb/"' in resp.text
|
assert '"http://localhost:80/prefix/pywb/"' in resp.text
|
||||||
assert 'new _WBWombat' in resp.text, resp.text
|
assert 'WBWombatInit' in resp.text, resp.text
|
||||||
assert '"/prefix/pywb/20140127171238{0}/http://www.iana.org/time-zones"'.format(fmod) in resp.text, resp.text
|
assert '"/prefix/pywb/20140127171238{0}/http://www.iana.org/time-zones"'.format(fmod) in resp.text, resp.text
|
||||||
|
|
||||||
def test_static_content(self):
|
def test_static_content(self):
|
||||||
|
@ -19,7 +19,7 @@ class TestRedirectClassic(BaseConfigTest):
|
|||||||
|
|
||||||
assert '"20140127171238"' in resp.text, resp.text
|
assert '"20140127171238"' in resp.text, resp.text
|
||||||
assert 'wombat.js' in resp.text
|
assert 'wombat.js' in resp.text
|
||||||
assert 'new _WBWombat' in resp.text, resp.text
|
assert 'WBWombatInit' in resp.text, resp.text
|
||||||
assert '/pywb/20140127171238{0}/http://www.iana.org/time-zones"'.format(fmod) in resp.text
|
assert '/pywb/20140127171238{0}/http://www.iana.org/time-zones"'.format(fmod) in resp.text
|
||||||
|
|
||||||
assert ('wbinfo.is_framed = ' + ('true' if fmod else 'false')) in resp.text
|
assert ('wbinfo.is_framed = ' + ('true' if fmod else 'false')) in resp.text
|
||||||
|
@ -13,7 +13,7 @@ class TestRootColl(BaseConfigTest):
|
|||||||
# Body
|
# Body
|
||||||
assert '"20140127171238"' in resp.text
|
assert '"20140127171238"' in resp.text
|
||||||
assert 'wombat.js' in resp.text
|
assert 'wombat.js' in resp.text
|
||||||
assert 'new _WBWombat' in resp.text, resp.text
|
assert 'WBWombatInit' in resp.text, resp.text
|
||||||
assert '/20140127171238{0}/http://www.iana.org/time-zones"'.format(fmod) in resp.text
|
assert '/20140127171238{0}/http://www.iana.org/time-zones"'.format(fmod) in resp.text
|
||||||
|
|
||||||
def test_root_replay_no_ts(self, fmod):
|
def test_root_replay_no_ts(self, fmod):
|
||||||
@ -23,7 +23,7 @@ class TestRootColl(BaseConfigTest):
|
|||||||
# Body
|
# Body
|
||||||
assert 'request_ts = ""' in resp.text
|
assert 'request_ts = ""' in resp.text
|
||||||
assert 'wombat.js' in resp.text
|
assert 'wombat.js' in resp.text
|
||||||
assert 'new _WBWombat' in resp.text, resp.text
|
assert 'WBWombatInit' in resp.text, resp.text
|
||||||
assert '/{0}http://www.iana.org/time-zones"'.format(fmod_slash) in resp.text
|
assert '/{0}http://www.iana.org/time-zones"'.format(fmod_slash) in resp.text
|
||||||
|
|
||||||
def test_root_replay_redir(self, fmod):
|
def test_root_replay_redir(self, fmod):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user