Bug 1399074 - Update more tests within dom/ to comply with new toplevel data: URI navigation policy. r=smaug
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Tue, 12 Sep 2017 17:54:49 +0200
changeset 663356 be5bcc9e9657f8ccfc304cda349899ec19caee6f
parent 663355 f559248aac81105d5e83105f5ff75934709ca6b8
child 663357 294b732822db474cbce1624a517282956e174669
push id79424
push userbmo:tchiovoloni@mozilla.com
push dateTue, 12 Sep 2017 23:17:54 +0000
reviewerssmaug
bugs1399074
milestone57.0a1
Bug 1399074 - Update more tests within dom/ to comply with new toplevel data: URI navigation policy. r=smaug
dom/browser-element/mochitest/browserElementTestHelpers.js
dom/browser-element/mochitest/browserElement_BrowserWindowResize.js
dom/browser-element/mochitest/browserElement_Close.js
dom/browser-element/mochitest/browserElement_ContextmenuEvents.js
dom/browser-element/mochitest/browserElement_CopyPaste.js
dom/browser-element/mochitest/browserElement_DataURI.js
dom/browser-element/mochitest/browserElement_TopBarrier.js
dom/tests/mochitest/bugs/test_resize_move_windows.html
--- a/dom/browser-element/mochitest/browserElementTestHelpers.js
+++ b/dom/browser-element/mochitest/browserElementTestHelpers.js
@@ -77,16 +77,20 @@ const browserElementTestHelpers = {
 
   addPermission: function() {
     this.lockTestReady();
     SpecialPowers.pushPermissions(
       [{'type': "browser", 'allow': 1, 'context': document}],
       this.unlockTestReady.bind(this));
   },
 
+  allowTopLevelDataURINavigation: function() {
+    this._setPref("security.data_uri.block_toplevel_data_uri_navigations", false);
+  },
+
   _observers: [],
 
   // This function is a wrapper which lets you register an observer to one of
   // the process priority manager's test-only topics.  observerFn should be a
   // function which takes (subject, topic, data).
   //
   // We'll clean up any observers you add at the end of the test.
   addProcessPriorityObserver: function(processPriorityTopic, observerFn) {
--- a/dom/browser-element/mochitest/browserElement_BrowserWindowResize.js
+++ b/dom/browser-element/mochitest/browserElement_BrowserWindowResize.js
@@ -2,16 +2,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 891763 - Test the mozbrowserresize event
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
+browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function runTest() {
   var srcResizeTo = "data:text/html,       \
     <script type='application/javascript'> \
       window.resizeTo(300, 300);           \
     <\/script>                             \
   ";
 
--- a/dom/browser-element/mochitest/browserElement_Close.js
+++ b/dom/browser-element/mochitest/browserElement_Close.js
@@ -2,16 +2,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that window.close() works.
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
+browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function runTest() {
   var iframe = document.createElement('iframe');
   iframe.setAttribute('mozbrowser', 'true');
   document.body.appendChild(iframe);
 
   iframe.addEventListener("mozbrowserclose", function(e) {
     ok(true, "got mozbrowserclose event.");
--- a/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js
+++ b/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js
@@ -1,14 +1,15 @@
 'use strict';
 
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.setClipboardPlainTextOnlyPref(false);
 browserElementTestHelpers.addPermission();
+browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 var audioUrl = 'http://mochi.test:8888/tests/dom/browser-element/mochitest/audio.ogg';
 var videoUrl = 'http://mochi.test:8888/tests/dom/browser-element/mochitest/short-video.ogv';
 
 function runTests() {
   createIframe(function onIframeLoaded() {
     checkEmptyContextMenu();
   });
--- a/dom/browser-element/mochitest/browserElement_CopyPaste.js
+++ b/dom/browser-element/mochitest/browserElement_CopyPaste.js
@@ -4,16 +4,17 @@
 // Test that "cut, copy, paste, selectall" and caretstatechanged event works from inside an <iframe mozbrowser>.
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("untriaged");
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.setupAccessibleCaretPref();
 browserElementTestHelpers.addPermission();
+browserElementTestHelpers.allowTopLevelDataURINavigation();
 const { Services } = SpecialPowers.Cu.import('resource://gre/modules/Services.jsm');
 
 var gTextarea = null;
 var mm;
 var iframeOuter;
 var iframeInner;
 var state = 0;
 var stateMeaning;
--- a/dom/browser-element/mochitest/browserElement_DataURI.js
+++ b/dom/browser-element/mochitest/browserElement_DataURI.js
@@ -2,16 +2,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that data: URIs work with mozbrowserlocationchange events.
 
 "use strict";
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
+browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function runTest() {
   var iframe1 = document.createElement('iframe');
   iframe1.setAttribute('mozbrowser', 'true');
   iframe1.id = 'iframe1';
   iframe1.addEventListener('mozbrowserloadend', function() {
     ok(true, 'Got first loadend event.');
     SimpleTest.executeSoon(runTest2);
--- a/dom/browser-element/mochitest/browserElement_TopBarrier.js
+++ b/dom/browser-element/mochitest/browserElement_TopBarrier.js
@@ -2,16 +2,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that an <iframe mozbrowser> is a window.{top,parent,frameElement} barrier.
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
+browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 var iframe;
 function runTest() {
   iframe = document.createElement('iframe');
   iframe.addEventListener('mozbrowserloadend', function() {
     try {
       outerIframeLoaded();
     } catch(e) {
--- a/dom/tests/mochitest/bugs/test_resize_move_windows.html
+++ b/dom/tests/mochitest/bugs/test_resize_move_windows.html
@@ -307,18 +307,20 @@ function checkChangeIsEnabled(aWindow, a
 
     aWindow.outerWidth = origWidth;
     aWindow.outerHeight = origHeight;
     return hitEventLoop(outerChangeCondition, outerChangeTest, hits);
   })
   .then(aNext);
 }
 
-SpecialPowers.pushPrefEnv({"set": [["dom.disable_window_move_resize", false],
-                                   ["security.data_uri.unique_opaque_origin", false]]},
+SpecialPowers.pushPrefEnv({
+  "set": [["dom.disable_window_move_resize", false],
+          ["security.data_uri.unique_opaque_origin", false],
+          ["security.data_uri.block_toplevel_data_uri_navigations", false],]},
                           function() {
 SimpleTest.waitForFocus(function() {
   if (screen.width <= 200 || screen.height <= 200) {
     todo(false, "The screen needs to be bigger than 200px*200px to run this test.");
     SimpleTest.finish();
     return;
   }