diff --git a/pywb/static/wombat.js b/pywb/static/wombat.js index badf1f2b..6e76cd04 100644 --- a/pywb/static/wombat.js +++ b/pywb/static/wombat.js @@ -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(); diff --git a/pywb/webapp/replay_views.py b/pywb/webapp/replay_views.py index 0301b6ee..06e43da7 100644 --- a/pywb/webapp/replay_views.py +++ b/pywb/webapp/replay_views.py @@ -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' diff --git a/tests/test_integration.py b/tests/test_integration.py index 4d9d4c0b..01ca6fa5 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -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