Bug 1316837 P2 Verify that navigating right after sync xhr does not trigger assertions. r=smaug a=jcristau
authorBen Kelly <ben@wanderview.com>
Tue, 15 Nov 2016 05:05:10 -0800
changeset 440011 07f57a55ee1b4d5fb5655fd4c5a9094e2d8a0f09
parent 440010 e5820bfe8d4eaac41b074e4f46a24fc619aab863
child 440012 b364ddf1922dddae7f2f515bd9d190949a2b7c50
push id36143
push userjkingston@mozilla.com
push dateWed, 16 Nov 2016 22:20:38 +0000
reviewerssmaug, jcristau
bugs1316837
milestone52.0a2
Bug 1316837 P2 Verify that navigating right after sync xhr does not trigger assertions. r=smaug a=jcristau
dom/xhr/tests/file_sync_xhr_document_write_with_iframe.html
dom/xhr/tests/mochitest.ini
dom/xhr/tests/test_sync_xhr_document_write_with_iframe.html
new file mode 100644
--- /dev/null
+++ b/dom/xhr/tests/file_sync_xhr_document_write_with_iframe.html
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML>
+<body>
+<script>
+function syncXHR() {
+  let xhr = new XMLHttpRequest();
+  xhr.open("GET", window.location, false);
+  xhr.send(null);
+}
+
+addEventListener('load', evt => {
+  syncXHR();
+  document.open();
+  document.write(
+    '<body>' +
+    '<iframe src="about:blank"></iframe>' +
+    '<script>window.opener.postMessage("DONE", "*");</' + 'script>' +
+    '</body>');
+  document.close();
+}, { once: true });
+</script>
+</body>
--- a/dom/xhr/tests/mochitest.ini
+++ b/dom/xhr/tests/mochitest.ini
@@ -58,16 +58,17 @@ support-files =
   subdir/relativeLoad_sub_worker2.js
   subdir/relativeLoad_sub_import.js
   common_temporaryFileBlob.js
   worker_temporaryFileBlob.js
   worker_bug1300552.js
   sync_xhr_unload.sjs
   iframe_sync_xhr_unload.html
   empty.html
+  file_sync_xhr_document_write_with_iframe.html
 
 [test_bug1300552.html]
 [test_html_in_xhr.html]
 [test_relativeLoad.html]
 skip-if = buildapp == 'b2g' # b2g(Failed to load script: relativeLoad_import.js) b2g-debug(Failed to load script: relativeLoad_import.js) b2g-desktop(Failed to load script: relativeLoad_import.js)
 [test_sync_xhr_timer.xhtml]
 skip-if = toolkit == 'android'
 [test_sync_xhr_unload.html]
@@ -106,8 +107,9 @@ skip-if = toolkit == 'android'
 skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) # b2g-debug(12 total, 2 failing - .mozSystem == true - got false, expected true + ) b2g-desktop(12 total, 2 failing - .mozSystem == true - got false, expected true + )
 [test_XHR_timeout.html]
 skip-if = buildapp == 'b2g' || (android_version == '18' && debug) # b2g(flaky on B2G, bug 960743) b2g-debug(flaky on B2G, bug 960743) b2g-desktop(flaky on B2G, bug 960743)
 support-files = test_XHR_timeout.js
 [test_xhr_withCredentials.html]
 [test_XHRDocURI.html]
 [test_XHRResponseURL.html]
 [test_XHRSendData.html]
+[test_sync_xhr_document_write_with_iframe.html]
new file mode 100644
--- /dev/null
+++ b/dom/xhr/tests/test_sync_xhr_document_write_with_iframe.html
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for Bug </title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+<script>
+function runTest() {
+  let w = window.open('file_sync_xhr_document_write_with_iframe.html');
+  addEventListener('message', evt => {
+    is(evt.data, 'DONE');
+    w.close();
+    SimpleTest.finish();
+  }, { once: true });
+}
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(runTest);
+</script>
+</pre>
+</body>
+</html>