Bug 1337272: Convert tests within toolkit/ to not rely on principal inheritance for data: URIs. r=gijs
☠☠ backed out by 8d8bee539dc2 ☠ ☠
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Tue, 18 Jul 2017 13:47:53 +0200
changeset 418270 b669da0374a2d7d7d946983865c0a799362725d9
parent 418269 38615ea1031444020b37b34a7c759e15a2b2e6bf
child 418271 0f61bc51de113c1054411e909ef9d53809423bb7
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgijs
bugs1337272
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 1337272: Convert tests within toolkit/ to not rely on principal inheritance for data: URIs. r=gijs
toolkit/components/windowwatcher/test/file_named_window.html
toolkit/components/windowwatcher/test/mochitest.ini
toolkit/components/windowwatcher/test/test_named_window.html
toolkit/content/tests/mochitest/file_mousecapture.html
toolkit/content/tests/mochitest/file_mousecapture2.html
toolkit/content/tests/mochitest/file_mousecapture3.html
toolkit/content/tests/mochitest/file_mousecapture4.html
toolkit/content/tests/mochitest/file_mousecapture5.html
toolkit/content/tests/mochitest/mochitest.ini
toolkit/content/tests/mochitest/test_mousecapture.xhtml
toolkit/content/tests/widgets/file_videocontrols_jsdisabled.html
toolkit/content/tests/widgets/mochitest.ini
toolkit/content/tests/widgets/test_videocontrols_jsdisabled.html
new file mode 100644
--- /dev/null
+++ b/toolkit/components/windowwatcher/test/file_named_window.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+test_named_window.html new window
+</body>
+</html>
--- a/toolkit/components/windowwatcher/test/mochitest.ini
+++ b/toolkit/components/windowwatcher/test/mochitest.ini
@@ -1,12 +1,14 @@
 [DEFAULT]
 tags = openwindow
 
 [test_blank_named_window.html]
 skip-if = (os == 'android') # Fennec doesn't support web content opening new windows (See bug 1277544 for details)
 [test_named_window.html]
+support-files =
+  file_named_window.html
 skip-if = (os == 'android') # Fennec doesn't support web content opening new windows (See bug 1277544 for details)
 [test_storage_copied.html]
 support-files =
   file_storage_copied.html
 skip-if = (os == 'android') # Fennec doesn't support web content opening new windows (See bug 1277544 for details)
 
--- a/toolkit/components/windowwatcher/test/test_named_window.html
+++ b/toolkit/components/windowwatcher/test/test_named_window.html
@@ -16,17 +16,18 @@ window.
 </head>
 <body>
   <a href="#" id="link">Click me</a>
 
   <script type="application/javascript">
     "use strict";
 
     const NAME = "my_window";
-    const TARGET_URL = "data:text/html,<html><body>test_named_window.html new window</body></html>";
+    const TARGET_URL = location.href.replace("test_named_window.html",
+                                             "file_named_window.html");
     const TARGET_URL_2 = TARGET_URL + "#2";
     const TARGET_URL_3 = TARGET_URL + "#3";
 
     /**
      * Returns a Promise that resolves once some target has had
      * some event dispatched on it.
      *
      * @param target
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/mochitest/file_mousecapture.html
@@ -0,0 +1,1 @@
+<html><p>One</p><p style='margin-top: 200px;'>Two</p><p style='margin-top: 4000px'>This is some text</p></html>
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/mochitest/file_mousecapture2.html
@@ -0,0 +1,1 @@
+<html><p>One</p><p style='margin-top: " + topPos + "'>Two</p><p style='margin-top: 4000px'>This is some text</p></html>
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/mochitest/file_mousecapture3.html
@@ -0,0 +1,1 @@
+<body style='font-size: 40pt;'>.<b id='b'>This</b> is some text<div id='fixed' style='position: fixed; left: 55px; top: 5px; width: 10px; height: 10px'>.</div></body>
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/mochitest/file_mousecapture4.html
@@ -0,0 +1,1 @@
+<frameset cols='50%, 50%'><frame src='about:blank'><frame src='about:blank'></frameset>
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/mochitest/file_mousecapture5.html
@@ -0,0 +1,1 @@
+<input id='input' onfocus='this.style.display = "none"' style='float: left;'>
--- a/toolkit/content/tests/mochitest/mochitest.ini
+++ b/toolkit/content/tests/mochitest/mochitest.ini
@@ -1,5 +1,11 @@
 [test_autocomplete_change_after_focus.html]
 skip-if = toolkit == "android"
 [test_mousecapture.xhtml]
+support-files =
+  file_mousecapture.html
+  file_mousecapture2.html
+  file_mousecapture3.html
+  file_mousecapture4.html
+  file_mousecapture5.html
 skip-if = toolkit == "android"
 
--- a/toolkit/content/tests/mochitest/test_mousecapture.xhtml
+++ b/toolkit/content/tests/mochitest/test_mousecapture.xhtml
@@ -13,16 +13,18 @@
   <p id="display"/><div id="content" style="display: none"/><pre id="test"/>
 
 <script><![CDATA[
 
 SimpleTest.expectAssertions(6, 12);
 
 SimpleTest.waitForExplicitFinish();
 
+const TEST_PATH = location.href.replace("test_mousecapture.xhtml", "");
+
 var captureRetargetMode = false;
 var cachedMouseDown = null;
 var previousWidth = 0, originalWidth = 0;
 var loadInWindow = false;
 
 function splitterCallback(adjustment) {
   var newWidth = Number($("leftbox").width); // getBoundingClientRect().width;
   var expectedWidth = previousWidth + adjustment;
@@ -90,17 +92,17 @@ function selectionScrollCheck() {
     if (loadInWindow) {
       SimpleTest.finish();
     } else {
       // now try again, but open the page in a new window
       loadInWindow = true;
       synthesizeMouse(document.getElementById("custom"), 2, 2, { type: "mousedown" });
 
       // check to ensure that selection dragging scrolls the right scrollable area
-      otherWindow = window.open("data:text/html,<html><p>One</p><p style='margin-top: 200px;'>Two</p><p style='margin-top: 4000px'>This is some text</p></html>", "_blank", "width=200,height=200,scrollbars=yes");
+      otherWindow = window.open(TEST_PATH + "file_mousecapture.html", "_blank", "width=200,height=200,scrollbars=yes");
       SimpleTest.waitForFocus(selectionScrollCheck, otherWindow);
     }
   }
 
   SimpleTest.executeSoon(function() {
     disableNonTestMouseEvents(true);
     synthesizeMouse(element, 2, 2, { type: "mousedown" }, otherWindow);
     synthesizeMouse(element, 100, otherWindow.innerHeight + 20, { type: "mousemove" }, otherWindow);
@@ -178,17 +180,17 @@ function runTests() {
   synthesizeMouse(body, 8, 8, { type: "mousedown" }, frames[0]);
   body.removeEventListener("mousedown", captureOnBody, true);
   synthesizeMouseExpectEvent(fixed, 2, 2, { type: "mousemove" },
                              fixed, "mousemove", "setCapture on body retargets to root node", frames[0]);
   synthesizeMouse(body, 8, 8, { type: "mouseup" }, frames[0]);
 
   previousWidth = frames[1].frames[0].document.documentElement.clientWidth;
   originalWidth = previousWidth;
-  runCaptureTest(frames[1].document.documentElement.lastChild, framesetCallback);
+  runCaptureTest(frames[1].document.documentElement.lastElementChild, framesetCallback);
 
   // ensure that clicking on an element where the frame disappears doesn't crash
   synthesizeMouse(frames[2].document.getElementById("input"), 8, 8, { type: "mousedown" }, frames[2]);
   synthesizeMouse(frames[2].document.getElementById("input"), 8, 8, { type: "mouseup" }, frames[2]);
 
   var select = document.getElementById("select");
   select.scrollIntoView();
 
@@ -199,17 +201,17 @@ function runTests() {
   window.scroll(0, 0);
 
   synthesizeMouse(custom, 2, 2, { type: "mousedown" });
 
   // check to ensure that selection dragging scrolls the right scrollable area.
   // This should open the page in a new tab.
 
   var topPos = window.innerHeight;
-  otherWindow = window.open("data:text/html,<html><p>One</p><p style='margin-top: " + topPos + "'>Two</p><p style='margin-top: 4000px'>This is some text</p></html>", "_blank");
+  otherWindow = window.open(TEST_PATH + "file_mousecapture2.html", "_blank");
   SimpleTest.waitForFocus(selectionScrollCheck, otherWindow);
 }
 
 function runCaptureTest(element, callback) {
   var expectedTarget = null;
 
   // ownerGlobal doesn't exist in content privileged windows.
   // eslint-disable-next-line mozilla/use-ownerGlobal
@@ -293,24 +295,19 @@ SimpleTest.waitForFocus(runTests);
         onmousedown="this.setCapture(captureRetargetMode);">
     <spacer id="custom5spacer" width="5"/>
     <hbox id="custom5inner" width="35" height="35"/>
   </hbox>
   <vbox id="custom6" width="10" height="10"
         onmousedown="document.createElement('hbox').setCapture();"/>
 </xul:vbox>
 
-  <iframe width="100" height="100"
-          src="data:text/html,%3Cbody style%3D'font-size%3A 40pt%3B'%3E.%3Cb id%3D'b'%3EThis%3C/b%3E is some text%3Cdiv id='fixed' style='position: fixed; left: 55px; top: 5px; width: 10px; height: 10px'%3E.%3C/div%3E%3C/body%3E"/>
-
-  <iframe width="100" height="100"
-          src="data:text/html,%3Cframeset cols='50%, 50%'%3E%3Cframe src='about:blank'%3E%3Cframe src='about:blank'%3E%3C/frameset%3E"/>
-
-  <iframe width="100" height="100"
-          src="data:text/html,%3Cinput id='input' onfocus='this.style.display = &quot;none&quot;' style='float: left;'>"/>
+  <iframe width="100" height="100" src="file_mousecapture3.html"/>
+  <iframe width="100" height="100" src="file_mousecapture4.html"/>
+  <iframe width="100" height="100" src="file_mousecapture5.html"/>
 
   <select id="select" xmlns="http://www.w3.org/1999/xhtml" size="4">
     <option id="option1">One</option>
     <option id="option2">Two</option>
     <option id="option3">Three</option>
     <option id="option4">Four</option>
     <option id="option5">Five</option>
     <option id="option6">Six</option>
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/widgets/file_videocontrols_jsdisabled.html
@@ -0,0 +1,2 @@
+<video src="seek_with_sound.ogg" controls autoplay=true></video>
+<script>window.testExpando = true;</script>
--- a/toolkit/content/tests/widgets/mochitest.ini
+++ b/toolkit/content/tests/widgets/mochitest.ini
@@ -1,12 +1,13 @@
 [DEFAULT]
 support-files =
   audio.wav
   audio.ogg
+  file_videocontrols_jsdisabled.html
   seek_with_sound.ogg
   video.ogg
   head.js
   tree_shared.js
   videocontrols_direction-1-ref.html
   videocontrols_direction-1a.html
   videocontrols_direction-1b.html
   videocontrols_direction-1c.html
--- a/toolkit/content/tests/widgets/test_videocontrols_jsdisabled.html
+++ b/toolkit/content/tests/widgets/test_videocontrols_jsdisabled.html
@@ -50,22 +50,19 @@ function loadevent(event) {
   video = win.document.querySelector("video");
   // Other events expected by the test.
   video.addEventListener("timeupdate", runTest);
   video.addEventListener("pause", runTest);
 }
 
 var win;
 function startTest() {
-  var videoURL = new URL("seek_with_sound.ogg", document.documentURI).href;
-
-  // eslint-disable-next-line no-useless-concat
-  var url = "data:text/html,<video src=" + videoURL + " controls autoplay=true></video><script>window.testExpando = true;</scr" + "ipt>";
-
-  win = window.open(url);
+  const TEST_FILE = location.href.replace("test_videocontrols_jsdisabled.html",
+                                          "file_videocontrols_jsdisabled.html");
+  win = window.open(TEST_FILE);
   win.addEventListener("load", loadevent);
 }
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 </body>