mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
update wombat.js (support for write override, fill in WB_wombat_location on new iframe)
disable 307 redirects as FF always displays modal confirmation for these, even for same host
This commit is contained in:
parent
bdafe0938d
commit
41e1809039
@ -111,7 +111,7 @@ WB_wombat_init = (function() {
|
||||
if (!url) {
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
var urltype_ = (typeof url);
|
||||
|
||||
// If object, use toString
|
||||
@ -548,9 +548,9 @@ WB_wombat_init = (function() {
|
||||
var desc;
|
||||
|
||||
if (child instanceof DocumentFragment) {
|
||||
// desc = child.querySelectorAll("*[href],*[src]");
|
||||
desc = child.querySelectorAll("a[href], iframe[src]");
|
||||
} else if (child.getElementsByTagName) {
|
||||
// desc = child.getElementsByTagName("*");
|
||||
desc = child.getElementsByTagName("*");
|
||||
}
|
||||
|
||||
if (desc) {
|
||||
@ -561,9 +561,14 @@ WB_wombat_init = (function() {
|
||||
|
||||
var created = orig.apply(this, arguments);
|
||||
|
||||
if (created.tagName == "IFRAME" ||
|
||||
created.tagName == "IMG" ||
|
||||
created.tagName == "SCRIPT") {
|
||||
if (created.tagName == "IFRAME"
|
||||
//|| created.tagName == "IMG"
|
||||
//|| created.tagName == "SCRIPT"
|
||||
) {
|
||||
|
||||
if (created.contentWindow) {
|
||||
created.contentWindow.window.WB_wombat_location = created.contentWindow.window.location;
|
||||
}
|
||||
|
||||
override_attr(created, "src");
|
||||
|
||||
@ -636,6 +641,22 @@ WB_wombat_init = (function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//============================================
|
||||
function init_write_override()
|
||||
{
|
||||
document.write = function(string) {
|
||||
var doc = new DOMParser().parseFromString(string, "text/html");
|
||||
|
||||
if (doc) {
|
||||
var children = doc.body.children;
|
||||
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
document.body.appendChild(children[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//============================================
|
||||
function wombat_init(replay_prefix, capture_date, orig_scheme, orig_host, timestamp) {
|
||||
@ -715,6 +736,9 @@ WB_wombat_init = (function() {
|
||||
// postMessage
|
||||
init_postmessage_override();
|
||||
|
||||
// write
|
||||
init_write_override();
|
||||
|
||||
// Ajax
|
||||
init_ajax_rewrite();
|
||||
init_worker_override();
|
||||
|
@ -187,8 +187,10 @@ class ReplayView(object):
|
||||
new_url = wbrequest.urlrewriter.get_timestamp_url(cdx['timestamp'],
|
||||
cdx['original'])
|
||||
|
||||
if wbrequest.method not in ('HEAD', 'GET'):
|
||||
statusline = '307 Same-Method Internal Redirect'
|
||||
if wbrequest.method == 'POST':
|
||||
# FF shows a confirm dialog, so can't use 307 effectively
|
||||
# statusline = '307 Same-Method Internal Redirect'
|
||||
return None
|
||||
else:
|
||||
statusline = '302 Internal Redirect'
|
||||
|
||||
|
@ -222,12 +222,14 @@ class TestWb:
|
||||
|
||||
def test_post_1(self):
|
||||
resp = self.testapp.post('/pywb/httpbin.org/post', {'foo': 'bar', 'test': 'abc'})
|
||||
assert resp.status_int == 307
|
||||
assert resp.headers['Location'].endswith('/pywb/20140610000859/http://httpbin.org/post')
|
||||
|
||||
# no redirects for POST, as some browsers (FF) show modal confirmation dialog!
|
||||
#assert resp.status_int == 307
|
||||
#assert resp.headers['Location'].endswith('/pywb/20140610000859/http://httpbin.org/post')
|
||||
|
||||
# XX webtest doesn't support 307 redirect of post
|
||||
#resp = resp.follow()
|
||||
resp = self.testapp.post(resp.headers['Location'], {'foo': 'bar', 'test': 'abc'})
|
||||
#resp = self.testapp.post(resp.headers['Location'], {'foo': 'bar', 'test': 'abc'})
|
||||
|
||||
assert resp.status_int == 200
|
||||
assert '"foo": "bar"' in resp.body
|
||||
|
Loading…
x
Reference in New Issue
Block a user