Bug 1377492 - fix mochitest-1 failure in docshell when data: URI is a unique origin. r=smaug
authorYoshi Huang <allstars.chh@mozilla.com>
Tue, 27 Jun 2017 13:42:10 -0700
changeset 368384 68d5e6c5ee1b6b15ed5c4db7aab041e227414293
parent 368383 1362c0928dc15e9a9cd6fa7ed9ee57a14365286e
child 368385 3467531e2747be6022ae3c4b74aaf99a70d8264b
push id32162
push usercbook@mozilla.com
push dateWed, 12 Jul 2017 09:07:26 +0000
treeherdermozilla-central@09a4282d1172 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1377492
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1377492 - fix mochitest-1 failure in docshell when data: URI is a unique origin. r=smaug When we turn on the pref security.data_uri.unique_opaque_origin to make data URI is unique origin, the following tests will fail because now data document is treated as cross origin, so we replace data URIs with seperate files, hence it will still in the same origin.
docshell/test/bug404548-subframe.html
docshell/test/bug404548-subframe_window.html
docshell/test/file_bfcache_plus_hash_1.html
docshell/test/file_bfcache_plus_hash_2.html
docshell/test/file_bug1121701_1.html
docshell/test/file_bug1121701_2.html
docshell/test/file_bug1186774.html
docshell/test/file_bug369814.html
docshell/test/file_bug660404-1.html
docshell/test/historyframes.html
docshell/test/iframesandbox/file_child_navigation_by_location.html
docshell/test/iframesandbox/mochitest.ini
docshell/test/iframesandbox/test_child_navigation_by_location.html
docshell/test/mochitest.ini
docshell/test/navigation/bluebox_bug430723.html
docshell/test/navigation/mochitest.ini
docshell/test/navigation/redbox_bug430723.html
docshell/test/navigation/test_bug430624.html
docshell/test/navigation/test_bug430723.html
docshell/test/start_historyframe.html
docshell/test/test_bfcache_plus_hash.html
docshell/test/test_bug1121701.html
docshell/test/test_bug1186774.html
docshell/test/test_bug369814.html
docshell/test/test_bug660404.html
docshell/test/url1_historyframe.html
docshell/test/url2_historyframe.html
editor/libeditor/crashtests/430624-1.html
--- a/docshell/test/bug404548-subframe.html
+++ b/docshell/test/bug404548-subframe.html
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html>
-<body onload="setTimeout(function() { window.location = &quot;data:text/html,<body onload='window.opener.finishTest()'>&quot; }, 10)">
-<iframe src="data:text/html,<body onpagehide='var p = window.parent.opener; var e = window.frameElement; e.parentNode.removeChild(e); if (e.parentNode == null && e.contentWindow == null) { p.firstRemoved = true; }'>">
+<body onload="setTimeout(function() { window.location = 'bug404548-subframe_window.html'; }, 10)">
+<iframe srcdoc="<body onpagehide='var p = window.parent.opener; var e = window.frameElement; e.parentNode.removeChild(e); if (e.parentNode == null && e.contentWindow == null) { p.firstRemoved = true; }'>">
 </iframe>
-<iframe src="data:text/html,<body onpagehide='window.parent.opener.secondHidden = true;'>">
+<iframe srcdoc="<body onpagehide='window.parent.opener.secondHidden = true;'>">
 </iframe>
new file mode 100644
--- /dev/null
+++ b/docshell/test/bug404548-subframe_window.html
@@ -0,0 +1,1 @@
+<body onload='window.opener.finishTest()'>
new file mode 100644
--- /dev/null
+++ b/docshell/test/file_bfcache_plus_hash_1.html
@@ -0,0 +1,1 @@
+<html><body onload="opener.childLoad(1)" onpageshow="opener.childPageshow(1)">Popup 1</body></html>
new file mode 100644
--- /dev/null
+++ b/docshell/test/file_bfcache_plus_hash_2.html
@@ -0,0 +1,1 @@
+<html><body onload="opener.childLoad(2)">Popup 2</body></html>
new file mode 100644
--- /dev/null
+++ b/docshell/test/file_bug1121701_1.html
@@ -0,0 +1,1 @@
+<script>window.onpageshow = function(e) { opener.child1PageShow(e); } </script>
new file mode 100644
--- /dev/null
+++ b/docshell/test/file_bug1121701_2.html
@@ -0,0 +1,1 @@
+<script>window.onpageshow = function(e) { opener.child2PageShow(e); } </script>
new file mode 100644
--- /dev/null
+++ b/docshell/test/file_bug1186774.html
@@ -0,0 +1,1 @@
+<div style='height: 9000px;'></div>
new file mode 100644
--- /dev/null
+++ b/docshell/test/file_bug369814.html
@@ -0,0 +1,1 @@
+<script>window.onunload = function() { frameElement.unloading(); }</script>
new file mode 100644
--- /dev/null
+++ b/docshell/test/file_bug660404-1.html
@@ -0,0 +1,1 @@
+<script>window.onload = function() { opener.continueTest(); }</script>
--- a/docshell/test/historyframes.html
+++ b/docshell/test/historyframes.html
@@ -4,17 +4,17 @@
 https://bugzilla.mozilla.org/show_bug.cgi?id=602256
 -->
 <head>
   <title>Test for Bug 602256</title>
 </head>
 <body onload="SimpleTest.executeSoon(run_test)">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=602256">Mozilla Bug 602256</a>
 <div id="content">
-  <iframe id="iframe" src="data:text/html,<p%20id='text'>Start</p>"></iframe>
+  <iframe id="iframe" src="start_historyframe.html"></iframe>
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 602256 **/
 
 var testWin = window.opener ? window.opener : window.parent;
 
@@ -45,19 +45,20 @@ function loadContent(aURL, aCallback) {
 function getURL() {
   return gFrame.contentDocument.documentURI;
 }
 
 function getContent() {
   return gFrame.contentDocument.getElementById("text").textContent;
 }
 
-var START = "data:text/html,<p%20id='text'>Start</p>";
-var URL1 = "data:text/html,<p%20id='text'>Test1</p>";
-var URL2 = "data:text/html,<p%20id='text'>Test2</p>";
+var BASE_URI = "http://mochi.test:8888/tests/docshell/test/";
+var START = BASE_URI + "start_historyframe.html";
+var URL1 = BASE_URI + "url1_historyframe.html";
+var URL2 = BASE_URI + "url2_historyframe.html";
 
 function run_test() {
   window.location.hash = "START";
 
   gFrame = document.getElementById("iframe");
 
   test_basic_inner_navigation();
 }
new file mode 100644
--- /dev/null
+++ b/docshell/test/iframesandbox/file_child_navigation_by_location.html
@@ -0,0 +1,1 @@
+<script>function onNav() { parent.parent.postMessage('childIframe', '*'); } window.onload = onNav; window.onhashchange = onNav;</script>
--- a/docshell/test/iframesandbox/mochitest.ini
+++ b/docshell/test/iframesandbox/mochitest.ini
@@ -1,10 +1,11 @@
 [DEFAULT]
 support-files =
+  file_child_navigation_by_location.html
   file_marquee_event_handlers.html
   file_other_auxiliary_navigation_by_location.html
   file_our_auxiliary_navigation_by_location.html
   file_parent_navigation_by_location.html
   file_sibling_navigation_by_location.html
   file_top_navigation_by_location.html
   file_top_navigation_by_location_exotic.html
 
--- a/docshell/test/iframesandbox/test_child_navigation_by_location.html
+++ b/docshell/test/iframesandbox/test_child_navigation_by_location.html
@@ -8,18 +8,17 @@ html5 sandboxed iframe should not be abl
 <meta charset="utf-8">
 <title>Test for Bug 785310 - iframe sandbox child navigation by location tests</title>
 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 
 <script>
   SimpleTest.waitForExplicitFinish();
 
-  var testHtml = "<script>function onNav() { parent.parent.postMessage('childIframe', '*'); } window.onload = onNav; window.onhashchange = onNav;<\/script>";
-  var testDataUri = "data:text/html," + testHtml;
+  var testDataUri = "file_child_navigation_by_location.html";
 
   function runScriptNavigationTest(testCase) {
     window.onmessage = function(event) {
       if (event.data != 'childIframe') {
         ok(false, "event.data: got '" + event.data + "', expected 'childIframe'");
       }
       ok(!testCase.shouldBeBlocked, testCase.desc, "child navigation was NOT blocked");
       runNextTest();
@@ -81,12 +80,12 @@ html5 sandboxed iframe should not be abl
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=785310">Mozilla Bug 785310</a>
 <p id="display"></p>
 <div id="content">
 Tests for Bug 785310
 </div>
 
-<iframe name="parentIframe" sandbox="allow-scripts allow-same-origin" src="data:text/html,<iframe name='sameOriginChildIframe'></iframe><iframe name='crossOriginChildIframe' sandbox='allow-scripts'></iframe>"</iframe>
+<iframe name="parentIframe" sandbox="allow-scripts allow-same-origin" srcdoc="<iframe name='sameOriginChildIframe'></iframe><iframe name='crossOriginChildIframe' sandbox='allow-scripts'></iframe>"</iframe>
 
 </body>
 </html>
--- a/docshell/test/mochitest.ini
+++ b/docshell/test/mochitest.ini
@@ -1,46 +1,57 @@
 [DEFAULT]
 support-files =
   bug123696-subframe.html
   bug369814.jar
   bug369814.zip
   bug404548-subframe.html
+  bug404548-subframe_window.html
   bug413310-post.sjs
   bug413310-subframe.html
   bug529119-window.html
   bug570341_recordevents.html
   bug668513_redirect.html
   bug668513_redirect.html^headers^
   bug691547_frame.html
   dummy_page.html
   file_anchor_scroll_after_document_open.html
+  file_bfcache_plus_hash_1.html
+  file_bfcache_plus_hash_2.html
+  file_bug369814.html
   file_bug385434_1.html
   file_bug385434_2.html
   file_bug385434_3.html
   file_bug475636.sjs
   file_bug509055.html
   file_bug540462.html
   file_bug580069_1.html
   file_bug580069_2.sjs
   file_bug590573_1.html
   file_bug590573_2.html
   file_bug634834.html
   file_bug640387.html
   file_bug653741.html
   file_bug660404
   file_bug660404^headers^
+  file_bug660404-1.html
   file_bug662170.html
   file_bug669671.sjs
   file_bug680257.html
   file_bug703855.html
   file_bug728939.html
+  file_bug1121701_1.html
+  file_bug1121701_2.html
+  file_bug1186774.html
   file_bug1151421.html
   file_pushState_after_document_open.html
   historyframes.html
+  start_historyframe.html
+  url1_historyframe.html
+  url2_historyframe.html
 
 [test_anchor_scroll_after_document_open.html]
 [test_bfcache_plus_hash.html]
 [test_bug123696.html]
 [test_bug369814.html]
 [test_bug384014.html]
 [test_bug385434.html]
 [test_bug387979.html]
new file mode 100644
--- /dev/null
+++ b/docshell/test/navigation/bluebox_bug430723.html
@@ -0,0 +1,6 @@
+<html><head>
+<script> window.addEventListener("pageshow", function(){opener.nextTest();}, false); </script>
+</head><body>
+<div style="position:absolute; left:0px; top:0px; width:50%; height:150%; background-color:blue">
+<p>This is a very tall blue box.</p>
+</div></body></html>
--- a/docshell/test/navigation/mochitest.ini
+++ b/docshell/test/navigation/mochitest.ini
@@ -1,14 +1,16 @@
 [DEFAULT]
 support-files =
   NavigationUtils.js
   blank.html
   file_bug386782_contenteditable.html
   file_bug386782_designmode.html
+  redbox_bug430723.html
+  bluebox_bug430723.html
   file_bug462076_1.html
   file_bug462076_2.html
   file_bug462076_3.html
   file_bug508537_1.html
   file_bug534178.html
   file_document_write_1.html
   file_fragment_handling_during_load.html
   file_nested_frames.html
new file mode 100644
--- /dev/null
+++ b/docshell/test/navigation/redbox_bug430723.html
@@ -0,0 +1,6 @@
+<html><head>
+<script> window.addEventListener("pageshow", function(){opener.nextTest();}, false); </script> 
+</head><body>
+<div style="position:absolute; left:0px; top:0px; width:50%; height:150%; background-color:red">
+<p>This is a very tall red box.</p>
+</div></body></html>
--- a/docshell/test/navigation/test_bug430624.html
+++ b/docshell/test/navigation/test_bug430624.html
@@ -20,17 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 430624 **/
 
 function onLoad() {
   window.frames[0].frameElement.onload = onReload;
-  window.frames[0].location = window.frames[0].location;
+  window.frames[0].frameElement.srcdoc = window.frames[0].frameElement.srcdoc;
 }
 
 function onReload() {
   var iframe = window.frames[0].frameElement;
   SimpleTest.waitForFocus(doTest, iframe.contentWindow);
   iframe.contentDocument.body.focus();
 }
 
@@ -44,13 +44,13 @@ function doTest() {
   SimpleTest.finish();
 }
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 
-<iframe onload="onLoad()" src="data:text/html;charset=utf-8,<body contenteditable>contentEditable</body>"></iframe>
+<iframe onload="onLoad()" srcdoc="<body contenteditable>contentEditable</body>"></iframe>
 
 </body>
 </html>
 
--- a/docshell/test/navigation/test_bug430723.html
+++ b/docshell/test/navigation/test_bug430723.html
@@ -16,31 +16,19 @@ https://bugzilla.mozilla.org/show_bug.cg
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 //<![CDATA[
 
 /** Test for Bug 430723 **/
 
-var gTallRedBoxURI = "data:text/html;charset=utf-8;base64,PGh0bWw%2BPGhlYWQ%2BPHNjcmlwdD53aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcigncGFnZXNob3cnLCBmdW5jdGlvbigpe29wZW5lci5uZXh0VGVzdCgpO30sIGZhbHNlKTs8L3NjcmlwdD48L2hlYWQ%2BPGJvZHk%2BPGRpdiBzdHlsZT0icG9zaXRpb246YWJzb2x1dGU7IGxlZnQ6MHB4OyB0b3A6MHB4OyB3aWR0aDo1MCU7IGhlaWdodDoxNTAlOyBiYWNrZ3JvdW5kLWNvbG9yOnJlZCI%2BPHA%2BVGhpcyBpcyBhIHZlcnkgdGFsbCByZWQgYm94LjwvcD48L2Rpdj48L2JvZHk%2BPC9odG1sPg%3D%3D";
-// <html><head>
-// < script > window.addEventListener("pageshow", function(){opener.nextTest();}, false); < /script > 
-// </head><body>
-// <div style="position:absolute; left:0px; top:0px; width:50%; height:150%; background-color:red">
-// <p>This is a very tall red box.</p>
-// </div></body></html>
-
-var gTallBlueBoxURI = "data:text/html;charset=utf-8;base64,PGh0bWw%2BPGhlYWQ%2BPHNjcmlwdD53aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcigncGFnZXNob3cnLCBmdW5jdGlvbigpe29wZW5lci5uZXh0VGVzdCgpO30sIGZhbHNlKTs8L3NjcmlwdD48L2hlYWQ%2BPGJvZHk%2BPGRpdiBzdHlsZT0icG9zaXRpb246YWJzb2x1dGU7IGxlZnQ6MHB4OyB0b3A6MHB4OyB3aWR0aDo1MCU7IGhlaWdodDoxNTAlOyBiYWNrZ3JvdW5kLWNvbG9yOmJsdWUiPjxwPlRoaXMgaXMgYSB2ZXJ5IHRhbGwgYmx1ZSBib3guPC9wPjwvZGl2PjwvYm9keT48L2h0bWw%2B";
-// <html><head>
-// < script > window.addEventListener("pageshow", function(){opener.nextTest();}, false); < /script > 
-// </head><body>
-// <div style="position:absolute; left:0px; top:0px; width:50%; height:150%; background-color:blue">
-// <p>This is a very tall blue box.</p>
-// </div></body></html>
+var BASE_URI = "http://mochi.test:8888/tests/docshell/test/navigation/";
+var gTallRedBoxURI = BASE_URI + "redbox_bug430723.html";
+var gTallBlueBoxURI = BASE_URI + "bluebox_bug430723.html";
 
 window.onload = runTest;
 
 var testWindow;
 var testNum = 0;
 
 var smoothScrollPref = "general.smoothScroll";
 function runTest() {
new file mode 100644
--- /dev/null
+++ b/docshell/test/start_historyframe.html
@@ -0,0 +1,1 @@
+<p id='text'>Start</p>
--- a/docshell/test/test_bfcache_plus_hash.html
+++ b/docshell/test/test_bfcache_plus_hash.html
@@ -77,27 +77,23 @@ function waitForLoad(n) {
 }
 
 function waitForShow(n) {
   debug('Waiting for show ' + n);
   expectedPageshowNum = n;
 }
 
 function* test() {
-  var popup = window.open('data:text/html,' +
-                          '<html><body onload="opener.childLoad(1)" ' +
-                                      'onpageshow="opener.childPageshow(1)">' +
-                                'Popup 1' +
-                                '</body></html>');
+  var popup = window.open('file_bfcache_plus_hash_1.html');
   waitForLoad(1);
   yield undefined;
 
   popup.history.pushState('', '', '');
 
-  popup.location = 'data:text/html,<html><body onload="opener.childLoad(2)">Popup 2</body></html>';
+  popup.location = 'file_bfcache_plus_hash_2.html';
   waitForLoad(2);
   yield undefined;
 
   // Now go back 2.  The first page should be retrieved from bfcache.
   popup.history.go(-2);
   waitForShow(1);
   yield undefined;
 
--- a/docshell/test/test_bug1121701.html
+++ b/docshell/test/test_bug1121701.html
@@ -7,18 +7,18 @@ https://bugzilla.mozilla.org/show_bug.cg
   <meta charset="utf-8">
   <title>Test for Bug 1121701</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
 
   /** Test for Bug 1121701 **/
 
-  var testUrl1 = "data:text/html,<script>window.onpageshow = function(e) { opener.child1PageShow(e); } <" + "/script>";
-  var testUrl2 = "data:text/html,<script>window.onpageshow = function(e) { opener.child2PageShow(e); } <" + "/script>";
+  var testUrl1 = "file_bug1121701_1.html";
+  var testUrl2 = "file_bug1121701_2.html";
   var testWin;
 
   var page1LoadCount = 0;
   function child1PageShow(e) {
     ++page1LoadCount;
     if (page1LoadCount == 1) {
       SimpleTest.executeSoon(function() {
         is(e.persisted, false, "Initial page load shouldn't be persisted.");
--- a/docshell/test/test_bug1186774.html
+++ b/docshell/test/test_bug1186774.html
@@ -10,17 +10,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
 
   /** Test for Bug 1186774 **/
 
 var child;
 
 function runTest() {
-  child = window.open("data:text/html,<div style='height: 9000px;'></div>", "", "width=100,height=100");
+  child = window.open("file_bug1186774.html", "", "width=100,height=100");
   child.onload = function() {
     setTimeout(function() {
       child.scrollTo(0, 0);
       child.history.pushState({}, "initial");
       child.scrollTo(0, 3000);
       child.history.pushState({}, "scrolled");
       child.scrollTo(0, 6000);
       child.history.back();
--- a/docshell/test/test_bug369814.html
+++ b/docshell/test/test_bug369814.html
@@ -86,17 +86,17 @@ function loadErrorTest(test)
       } catch (e) {
         errorPage = true;
       }
       ok(errorPage, gCurrentTest["name"] + ": should block a suspicious JAR load.");
 
       finishTest();
     }, 0);
   }
-  var unloadDetector = "data:text/html,<script>window.onunload = function() { frameElement.unloading(); }</" + "script>";
+  var unloadDetector = "file_bug369814.html";
   gTestFrame.src = unloadDetector;
 }
 
 function iframeTest(test) {
   gTestFrame.src = test['url'];
   loadEvent(gTestFrame, function() {
       finishTest();
     });
--- a/docshell/test/test_bug660404.html
+++ b/docshell/test/test_bug660404.html
@@ -35,14 +35,14 @@ function continueTest() {
 function finishTest() {
   is(w.document.documentElement.textContent, "opener.finishTest();");
   is(w.document.documentElement.innerHTML, "<head><script>opener.finishTest();</"+"script></head>");
   w.close();
   SimpleTest.finish();
 }
 
 // Have to open a new window, since there's no bfcache in subframes
-w = window.open("data:text/html,<script>window.onload = function() { opener.continueTest(); }</"+"script>");
+w = window.open("file_bug660404-1.html");
 
 </script>
 </pre>
 </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/docshell/test/url1_historyframe.html
@@ -0,0 +1,1 @@
+<p id='text'>Test1</p>
new file mode 100644
--- /dev/null
+++ b/docshell/test/url2_historyframe.html
@@ -0,0 +1,1 @@
+<p id='text'>Test2</p>
--- a/editor/libeditor/crashtests/430624-1.html
+++ b/editor/libeditor/crashtests/430624-1.html
@@ -6,9 +6,9 @@ function crash() {
   window.frames[0].location = 'data:text/html;charset=utf-8,2nd%20page';
 }
 </script>
 </head>
 <body onload="crash()">
   <!-- iframe contents: <html><body onload="document.body.setAttribute('spellcheck', true);"></body></html> -->
   <iframe src="data:text/html;charset=utf-8;base64,PGh0bWw%2BPGJvZHkgb25sb2FkPSJkb2N1bWVudC5ib2R5LnNldEF0dHJpYnV0ZSgnc3BlbGxjaGVjaycsIHRydWUpOyI%2BPC9ib2R5PjwvaHRtbD4%3D"></iframe>
 </body>
-</html>
\ No newline at end of file
+</html>