From 4b7a2c677a8bda717cbc21f8e06ee43c0d9f0005 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 6 May 2018 14:31:20 +0200 Subject: moebius#231: Consider blocking top level window data: URIs (tests) https://github.com/MoonchildProductions/moebius/pull/231 --- dom/base/test/file_ipc_messagemanager_blob.html | 1 + dom/base/test/mochitest.ini | 1 + dom/base/test/test_ipc_messagemanager_blob.html | 3 +-- dom/base/test/test_x-frame-options.html | 6 +++++- dom/browser-element/mochitest/browserElementTestHelpers.js | 4 ++++ .../mochitest/browserElement_BrowserWindowResize.js | 1 + dom/browser-element/mochitest/browserElement_Close.js | 1 + dom/browser-element/mochitest/browserElement_ContextmenuEvents.js | 1 + dom/browser-element/mochitest/browserElement_CopyPaste.js | 1 + dom/browser-element/mochitest/browserElement_DataURI.js | 1 + dom/browser-element/mochitest/browserElement_Iconchange.js | 1 + dom/browser-element/mochitest/browserElement_Manifestchange.js | 1 + dom/browser-element/mochitest/browserElement_Metachange.js | 1 + dom/browser-element/mochitest/browserElement_Opensearch.js | 1 + dom/browser-element/mochitest/browserElement_PromptCheck.js | 1 + dom/browser-element/mochitest/browserElement_PromptConfirm.js | 1 + .../mochitest/browserElement_RemoveBrowserElement.js | 1 + dom/browser-element/mochitest/browserElement_ScrollEvent.js | 1 + dom/browser-element/mochitest/browserElement_Titlechange.js | 1 + dom/browser-element/mochitest/browserElement_TopBarrier.js | 1 + dom/html/test/test_fullscreen-api-race.html | 4 +++- dom/plugins/test/mochitest/test_pluginstream_err.html | 8 +++++++- dom/tests/mochitest/bugs/test_resize_move_windows.html | 5 ++++- 23 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 dom/base/test/file_ipc_messagemanager_blob.html (limited to 'dom') diff --git a/dom/base/test/file_ipc_messagemanager_blob.html b/dom/base/test/file_ipc_messagemanager_blob.html new file mode 100644 index 000000000..dbdd64a34 --- /dev/null +++ b/dom/base/test/file_ipc_messagemanager_blob.html @@ -0,0 +1 @@ + diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini index ddfd57443..b3b804ce4 100644 --- a/dom/base/test/mochitest.ini +++ b/dom/base/test/mochitest.ini @@ -676,6 +676,7 @@ skip-if = (toolkit == 'android') # Android: Bug 775227 [test_intersectionobservers.html] skip-if = true # Track Bug 1320704 [test_ipc_messagemanager_blob.html] +support-files = file_ipc_messagemanager_blob.html [test_link_prefetch.html] skip-if = !e10s # Track Bug 1281415 [test_link_stylesheet.html] diff --git a/dom/base/test/test_ipc_messagemanager_blob.html b/dom/base/test/test_ipc_messagemanager_blob.html index 74eab2945..77d6c767f 100644 --- a/dom/base/test/test_ipc_messagemanager_blob.html +++ b/dom/base/test/test_ipc_messagemanager_blob.html @@ -14,8 +14,7 @@ SimpleTest.waitForExplicitFinish(); - const childFrameURL = - "data:text/html,"; + const childFrameURL = "file_ipc_messagemanager_blob.html"; function childFrameScript() { "use strict"; diff --git a/dom/base/test/test_x-frame-options.html b/dom/base/test/test_x-frame-options.html index 8e24d8a78..a0c7acdc3 100644 --- a/dom/base/test/test_x-frame-options.html +++ b/dom/base/test/test_x-frame-options.html @@ -147,7 +147,11 @@ var testFrameInDataURI = function() { SimpleTest.waitForExplicitFinish(); // load the test harness -document.getElementById("harness").src = "file_x-frame-options_main.html"; +SpecialPowers.pushPrefEnv({ + "set": [["security.data_uri.block_toplevel_data_uri_navigations", false],] +}, function() { + document.getElementById("harness").src = "file_x-frame-options_main.html"; +}); diff --git a/dom/browser-element/mochitest/browserElementTestHelpers.js b/dom/browser-element/mochitest/browserElementTestHelpers.js index 004b25333..8df1476ac 100644 --- a/dom/browser-element/mochitest/browserElementTestHelpers.js +++ b/dom/browser-element/mochitest/browserElementTestHelpers.js @@ -84,6 +84,10 @@ const browserElementTestHelpers = { 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 diff --git a/dom/browser-element/mochitest/browserElement_BrowserWindowResize.js b/dom/browser-element/mochitest/browserElement_BrowserWindowResize.js index 420b4bc34..65a777861 100644 --- a/dom/browser-element/mochitest/browserElement_BrowserWindowResize.js +++ b/dom/browser-element/mochitest/browserElement_BrowserWindowResize.js @@ -7,6 +7,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); function runTest() { var srcResizeTo = "data:text/html, \ diff --git a/dom/browser-element/mochitest/browserElement_Close.js b/dom/browser-element/mochitest/browserElement_Close.js index 57bdf384d..103805404 100644 --- a/dom/browser-element/mochitest/browserElement_Close.js +++ b/dom/browser-element/mochitest/browserElement_Close.js @@ -7,6 +7,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); function runTest() { var iframe = document.createElement('iframe'); diff --git a/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js b/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js index 66aa8e015..a8c361ebd 100644 --- a/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js +++ b/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js @@ -4,6 +4,7 @@ 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'; diff --git a/dom/browser-element/mochitest/browserElement_CopyPaste.js b/dom/browser-element/mochitest/browserElement_CopyPaste.js index b23feef59..97a37be8b 100644 --- a/dom/browser-element/mochitest/browserElement_CopyPaste.js +++ b/dom/browser-element/mochitest/browserElement_CopyPaste.js @@ -9,6 +9,7 @@ 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; diff --git a/dom/browser-element/mochitest/browserElement_DataURI.js b/dom/browser-element/mochitest/browserElement_DataURI.js index f57f4566a..d31678f89 100644 --- a/dom/browser-element/mochitest/browserElement_DataURI.js +++ b/dom/browser-element/mochitest/browserElement_DataURI.js @@ -7,6 +7,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); function runTest() { var iframe1 = document.createElement('iframe'); diff --git a/dom/browser-element/mochitest/browserElement_Iconchange.js b/dom/browser-element/mochitest/browserElement_Iconchange.js index 367a2de15..283331d3c 100644 --- a/dom/browser-element/mochitest/browserElement_Iconchange.js +++ b/dom/browser-element/mochitest/browserElement_Iconchange.js @@ -7,6 +7,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); function createHtml(link) { return 'data:text/html,' + link + ''; diff --git a/dom/browser-element/mochitest/browserElement_Manifestchange.js b/dom/browser-element/mochitest/browserElement_Manifestchange.js index 22cf8fe7c..5b3733d14 100644 --- a/dom/browser-element/mochitest/browserElement_Manifestchange.js +++ b/dom/browser-element/mochitest/browserElement_Manifestchange.js @@ -7,6 +7,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); function createHtml(manifest) { return 'data:text/html,' + manifest + ''; diff --git a/dom/browser-element/mochitest/browserElement_Metachange.js b/dom/browser-element/mochitest/browserElement_Metachange.js index 7789a3e18..53c8d2397 100644 --- a/dom/browser-element/mochitest/browserElement_Metachange.js +++ b/dom/browser-element/mochitest/browserElement_Metachange.js @@ -7,6 +7,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); function createHtml(meta) { return 'data:text/html,' + meta + ''; diff --git a/dom/browser-element/mochitest/browserElement_Opensearch.js b/dom/browser-element/mochitest/browserElement_Opensearch.js index 8df44d2a9..5762e6f0e 100644 --- a/dom/browser-element/mochitest/browserElement_Opensearch.js +++ b/dom/browser-element/mochitest/browserElement_Opensearch.js @@ -7,6 +7,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); function createHtml(link) { return 'data:text/html,' + link + ''; diff --git a/dom/browser-element/mochitest/browserElement_PromptCheck.js b/dom/browser-element/mochitest/browserElement_PromptCheck.js index d6edde09f..952f4468e 100644 --- a/dom/browser-element/mochitest/browserElement_PromptCheck.js +++ b/dom/browser-element/mochitest/browserElement_PromptCheck.js @@ -13,6 +13,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); function runTest() { diff --git a/dom/browser-element/mochitest/browserElement_PromptConfirm.js b/dom/browser-element/mochitest/browserElement_PromptConfirm.js index c01836a25..b920a6d26 100644 --- a/dom/browser-element/mochitest/browserElement_PromptConfirm.js +++ b/dom/browser-element/mochitest/browserElement_PromptConfirm.js @@ -11,6 +11,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); function runTest() { var iframe = document.createElement('iframe'); diff --git a/dom/browser-element/mochitest/browserElement_RemoveBrowserElement.js b/dom/browser-element/mochitest/browserElement_RemoveBrowserElement.js index 583d58734..3ab206388 100644 --- a/dom/browser-element/mochitest/browserElement_RemoveBrowserElement.js +++ b/dom/browser-element/mochitest/browserElement_RemoveBrowserElement.js @@ -9,6 +9,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); function runTest() { var iframe = document.createElement('iframe'); diff --git a/dom/browser-element/mochitest/browserElement_ScrollEvent.js b/dom/browser-element/mochitest/browserElement_ScrollEvent.js index 06dc91b86..5230c524a 100644 --- a/dom/browser-element/mochitest/browserElement_ScrollEvent.js +++ b/dom/browser-element/mochitest/browserElement_ScrollEvent.js @@ -7,6 +7,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); function runTest() { var iframe = document.createElement('iframe'); diff --git a/dom/browser-element/mochitest/browserElement_Titlechange.js b/dom/browser-element/mochitest/browserElement_Titlechange.js index 78c939ad8..145e9baa8 100644 --- a/dom/browser-element/mochitest/browserElement_Titlechange.js +++ b/dom/browser-element/mochitest/browserElement_Titlechange.js @@ -7,6 +7,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); function runTest() { var iframe1 = document.createElement('iframe'); diff --git a/dom/browser-element/mochitest/browserElement_TopBarrier.js b/dom/browser-element/mochitest/browserElement_TopBarrier.js index 3bd68854c..186622b33 100644 --- a/dom/browser-element/mochitest/browserElement_TopBarrier.js +++ b/dom/browser-element/mochitest/browserElement_TopBarrier.js @@ -7,6 +7,7 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); browserElementTestHelpers.addPermission(); +browserElementTestHelpers.allowTopLevelDataURINavigation(); var iframe; function runTest() { diff --git a/dom/html/test/test_fullscreen-api-race.html b/dom/html/test/test_fullscreen-api-race.html index 03c6c6da3..6664e2ab5 100644 --- a/dom/html/test/test_fullscreen-api-race.html +++ b/dom/html/test/test_fullscreen-api-race.html @@ -35,7 +35,9 @@ addLoadEvent(function () { SpecialPowers.pushPrefEnv({ "set": [ ["full-screen-api.unprefix.enabled", true], - ["full-screen-api.allow-trusted-requests-only", false] + ["full-screen-api.allow-trusted-requests-only", false], + // Use legacy data: URI behavior to run test. + ["security.data_uri.block_toplevel_data_uri_navigations", false] ] }, next); }); diff --git a/dom/plugins/test/mochitest/test_pluginstream_err.html b/dom/plugins/test/mochitest/test_pluginstream_err.html index 0ac2a5efc..79f06154c 100644 --- a/dom/plugins/test/mochitest/test_pluginstream_err.html +++ b/dom/plugins/test/mochitest/test_pluginstream_err.html @@ -13,7 +13,7 @@ Tests for plugin stream error conditions. - + Mozilla Bug 517078 - Plugin Stream Error Tests

@@ -158,6 +158,12 @@ function continueTest() { index++; } +function startTests() { + SpecialPowers.pushPrefEnv({"set": [ + ["security.data_uri.block_toplevel_data_uri_navigations", false], + ]}, runNextTest); +} + diff --git a/dom/tests/mochitest/bugs/test_resize_move_windows.html b/dom/tests/mochitest/bugs/test_resize_move_windows.html index 0762e9231..f84b4fde8 100644 --- a/dom/tests/mochitest/bugs/test_resize_move_windows.html +++ b/dom/tests/mochitest/bugs/test_resize_move_windows.html @@ -312,7 +312,10 @@ function checkChangeIsEnabled(aWindow, aNext) .then(aNext); } -SpecialPowers.pushPrefEnv({"set": [["dom.disable_window_move_resize", false]]}, function() { +SpecialPowers.pushPrefEnv({ + "set": [["dom.disable_window_move_resize", 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."); -- cgit v1.2.3