From 45de248a8b9ce78553625f547b1c88e4a60997c8 Mon Sep 17 00:00:00 2001 From: Anish Date: Thu, 19 Feb 2015 11:53:01 -0500 Subject: [PATCH] Bug 1056851 - Change existing callers of SpecialPowers.setBoolPref/setIntPref/setCharPref to SpecialPowers.pushPrefEnv. r=jmaher,mwargers --- .../tests/mochitest/elm/test_canvas.html | 11 ++-- .../hittest/test_canvas_hitregion.html | 10 ++-- docshell/test/navigation/test_bug430723.html | 8 ++- dom/apps/tests/test_app_update.html | 14 ++---- dom/base/test/test_EventSource_redirects.html | 7 ++- dom/base/test/test_bug666604.html | 20 ++------ dom/base/test/test_bug715041.xul | 5 +- dom/base/test/test_bug715041_removal.xul | 6 +-- .../test_child_process_shutdown_message.html | 18 ++----- .../test_messagemanager_assertpermission.html | 7 +-- .../test_websocket_permessage_deflate.html | 10 ++-- .../mochitest/priority/test_Preallocated.html | 16 ++---- ..._composite_canvaspattern_setTransform.html | 5 +- dom/canvas/test/test_canvas_path.html | 6 +-- dom/canvas/test/test_hitregion_canvas.html | 8 ++- dom/datastore/tests/test_app_install.html | 10 ++-- dom/datastore/tests/test_arrays.html | 3 +- dom/datastore/tests/test_basic.html | 3 +- dom/datastore/tests/test_basic_worker.html | 3 +- dom/datastore/tests/test_bug1008044.html | 3 +- dom/datastore/tests/test_bug1058108.html | 3 +- dom/datastore/tests/test_bug924104.html | 3 +- dom/datastore/tests/test_bug957086.html | 3 +- dom/datastore/tests/test_bug976311.html | 3 +- dom/datastore/tests/test_certifiedApp.html | 3 +- dom/datastore/tests/test_duplicate.html | 3 +- dom/datastore/tests/test_keys.html | 3 +- dom/datastore/tests/test_oop.html | 3 +- dom/datastore/tests/test_oop_events.html | 3 +- dom/datastore/tests/test_readonly.html | 19 ++++--- dom/datastore/tests/test_sync.html | 3 +- dom/datastore/tests/test_sync_worker.html | 3 +- dom/datastore/tests/test_transactions.html | 3 +- dom/datastore/tests/test_worker_close.html | 3 +- dom/events/test/test_bug422132.html | 13 ++--- dom/events/test/test_bug563329.html | 22 ++------ dom/events/test/test_bug574663.html | 28 +++-------- dom/events/test/test_bug607464.html | 26 ++-------- dom/events/test/test_bug822898.html | 16 +----- dom/html/test/file_fullscreen-api.html | 34 ++++++------- dom/html/test/file_fullscreen-denied.html | 38 +++++++------- .../file_fullscreen-esc-context-menu.html | 6 +-- .../forms/test_input_number_key_events.html | 10 ++-- .../forms/test_input_radio_radiogroup.html | 39 ++++++++------- .../forms/test_input_range_key_events.html | 8 +-- .../test/forms/test_input_range_rounding.html | 11 ++-- dom/html/test/forms/test_radio_in_label.html | 39 ++++++++------- .../test/forms/test_valueAsDate_pref.html | 7 +-- dom/html/test/test_bug369370.html | 15 +++--- dom/html/test/test_bug633058.html | 8 +-- dom/html/test/test_bug674558.html | 7 +-- dom/html/test/test_fullscreen-api.html | 21 +++----- .../test_networkstats_enabled_no_perm.html | 42 ++++++++-------- .../tests/test_tcpsocket_enabled_no_perm.html | 22 ++++---- .../test_tcpsocket_enabled_with_perm.html | 15 +++--- dom/requestsync/tests/test_basic_app.html | 3 +- dom/tests/mochitest/bugs/test_bug265203.html | 10 ++-- .../test_MozEnteredDomFullscreen_event.xul | 14 +++--- .../chrome/test_clipboard_events_chrome.html | 8 +-- .../general/test_clipboard_events.html | 1 - .../mochitest/general/test_vibrator.html | 27 ++++------ .../localstorage/test_appIsolation.html | 23 ++------- .../mochitest/test_tv_non_permitted_app.html | 3 +- dom/xul/test/test_bug757137.xul | 41 ++++++--------- editor/libeditor/tests/test_bug549262.html | 9 ++-- editor/libeditor/tests/test_bug578771.html | 24 ++++----- editor/libeditor/tests/test_bug640321.html | 20 ++++---- editor/libeditor/tests/test_bug645914.html | 12 ++--- editor/libeditor/tests/test_bug674770-1.html | 7 +-- editor/libeditor/tests/test_bug674770-2.html | 50 ++++++++----------- editor/libeditor/tests/test_bug795785.html | 7 ++- .../test_permissionmanager_app_isolation.html | 28 +++-------- image/test/crashtests/ownerdiscard.html | 7 +-- .../test_SpecialPowersExtension.html | 1 - .../passwordmgr/test/test_basic_form_2.html | 12 ++--- ...est_basic_form_observer_autofillForms.html | 12 ++--- .../test_allowlisted_annotations.html | 9 ++-- .../chrome/test_preferences_beforeaccept.xul | 10 +--- widget/tests/test_assign_event_data.html | 42 +++++----------- widget/tests/test_imestate.html | 5 +- 80 files changed, 409 insertions(+), 634 deletions(-) diff --git a/accessible/tests/mochitest/elm/test_canvas.html b/accessible/tests/mochitest/elm/test_canvas.html index d1245ba1bbea..1082b4ab74bd 100644 --- a/accessible/tests/mochitest/elm/test_canvas.html +++ b/accessible/tests/mochitest/elm/test_canvas.html @@ -18,8 +18,6 @@ src="../layout.js"> + addA11yLoadEvent(function() { + SpecialPowers.pushPrefEnv({"set": [['canvas.hitregions.enabled', true]]}, doTest); + }); + + diff --git a/accessible/tests/mochitest/hittest/test_canvas_hitregion.html b/accessible/tests/mochitest/hittest/test_canvas_hitregion.html index 5fc12c9a85d6..fe1a53846131 100644 --- a/accessible/tests/mochitest/hittest/test_canvas_hitregion.html +++ b/accessible/tests/mochitest/hittest/test_canvas_hitregion.html @@ -13,8 +13,6 @@ src="../layout.js"> + addA11yLoadEvent(function() { + SpecialPowers.pushPrefEnv({"set": [['canvas.hitregions.enabled', true]]}, doTest); + }); + diff --git a/docshell/test/navigation/test_bug430723.html b/docshell/test/navigation/test_bug430723.html index ee9da6d160fe..55dd9f13c622 100644 --- a/docshell/test/navigation/test_bug430723.html +++ b/docshell/test/navigation/test_bug430723.html @@ -37,7 +37,6 @@ var gTallBlueBoxURI = "data:text/html;charset=utf-8;base64,PGh0bWw%2BPGhlYWQ%2BP //

This is a very tall blue box.

// - window.onload = runTest; var testWindow; @@ -45,8 +44,9 @@ var testNum = 0; var smoothScrollPref = "general.smoothScroll"; function runTest() { - SpecialPowers.setBoolPref(smoothScrollPref, false); - testWindow = window.open(gTallRedBoxURI, "testWindow", "width=300,height=300,location=yes,scrollbars=yes"); + SpecialPowers.pushPrefEnv({"set":[[smoothScrollPref, false]]}, function(){ + testWindow = window.open(gTallRedBoxURI, "testWindow", "width=300,height=300,location=yes,scrollbars=yes"); + }); } var nextTest =function() { @@ -124,7 +124,6 @@ var step3 =function() { "Page2Again: Ensure we can still scroll."); testWindow.close(); - SpecialPowers.clearUserPref(smoothScrollPref); window.SimpleTest.finish(); }, true); sendKey('DOWN', testWindow); @@ -137,4 +136,3 @@ SimpleTest.waitForExplicitFinish(); - diff --git a/dom/apps/tests/test_app_update.html b/dom/apps/tests/test_app_update.html index 8a2feb78dab3..c7e922edbca5 100644 --- a/dom/apps/tests/test_app_update.html +++ b/dom/apps/tests/test_app_update.html @@ -18,15 +18,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=826058 var gHostedManifestURL = gBaseURL + 'file_app.sjs?apptype=hosted&getmanifest=true'; var gCachedManifestURL = gBaseURL + 'file_app.sjs?apptype=cached&getmanifest=true'; var gTrustedManifestURL = gBaseURL + 'file_app.sjs?apptype=trusted&getmanifest=true'; - var gGenerator = runTest(); - + var gGenerator; // We need to set the trusted hosted app csp pref since it's only in // b2g.js for now. function setCSPPrefs() { - SpecialPowers.pushPrefEnv({'set': - [["security.apps.trusted.CSP.default", - "default-src *; object-src 'none'"]]}, - function() { gGenerator.next(); }); + SpecialPowers.pushPrefEnv({'set':[["security.apps.trusted.CSP.default", +"default-src *; object-src 'none'"], ["dom.mozBrowserFramesEnabled",true]]}, + function() { gGenerator = runTest(); gGenerator.next(); }); } function go() { @@ -64,10 +62,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=826058 function runTest() { // Set up. - SpecialPowers.setAllAppsLaunchable(true); - SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true); - // Test Bug 927699 - navigator.mozApps.install(url) lets NS_ERROR_FAILURE // onto the web var request = navigator.mozApps.install(""); @@ -324,7 +319,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=826058 } function finish() { - SpecialPowers.clearUserPref("dom.mozBrowserFramesEnabled"); SimpleTest.finish(); } diff --git a/dom/base/test/test_EventSource_redirects.html b/dom/base/test/test_EventSource_redirects.html index 0d18fa4706ab..c57c501e1e06 100644 --- a/dom/base/test/test_EventSource_redirects.html +++ b/dom/base/test/test_EventSource_redirects.html @@ -22,8 +22,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=716841 function doTest(test_id) { oldPrefVal = SpecialPowers.getBoolPref("dom.server-events.enabled"); - SpecialPowers.setBoolPref("dom.server-events.enabled", true); - ok(true, "here we go"); source = new EventSource("eventsource_redirect.resource"); @@ -49,8 +47,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=716841 } SimpleTest.waitForExplicitFinish(); - addLoadEvent(doTest); - + addLoadEvent(function() { + SpecialPowers.pushPrefEnv({"set": [['dom.server-events.enabled', true]]}, doTest); + }); diff --git a/dom/base/test/test_bug666604.html b/dom/base/test/test_bug666604.html index fc78ec4b4777..4f73c4075cd9 100644 --- a/dom/base/test/test_bug666604.html +++ b/dom/base/test/test_bug666604.html @@ -108,44 +108,32 @@ function test6() { activationListener = function() { ok(true, "Untrusted DOMActivate should activate a link"); - test7(); + SpecialPowers.pushPrefEnv({"set":[["dom.disable_open_during_load", false]]}, test7); } dispatchDOMActivate(testlink); } -var oldPref; function test7() { - oldPref = SpecialPowers.getBoolPref("dom.disable_open_during_load"); - SpecialPowers.setBoolPref("dom.disable_open_during_load", false); testlink.href = "javascript:opener.activationListener(); window.close();"; testlink.target = "_blank"; activationListener = function() { ok(true, "Click() should activate a link"); - setTimeout(test8, 0); + SpecialPowers.pushPrefEnv({"set":[["dom.disable_open_during_load", true]]}, test8); } testlink.click(); } function test8() { - SpecialPowers.setBoolPref("dom.disable_open_during_load", true); testlink.href = "javascript:opener.activationListener(); window.close();"; testlink.target = "_blank"; activationListener = function() { ok(false, "Click() should not activate a link"); - setTimeout(test9, 0); } - testlink.click(); - hitEventLoop(10, test9); -} - - -function test9() { - SpecialPowers.setBoolPref("dom.disable_open_during_load", oldPref); - SimpleTest.finish(); + testlink.click(); + SimpleTest.executeSoon(SimpleTest.finish); } - addLoadEvent(test1); diff --git a/dom/base/test/test_bug715041.xul b/dom/base/test/test_bug715041.xul index 89dddd11ba36..c269b461b2d9 100644 --- a/dom/base/test/test_bug715041.xul +++ b/dom/base/test/test_bug715041.xul @@ -19,8 +19,6 @@ target="_blank">Mozilla Bug 715041 Mozilla Bug 715041 AddShiftLocalEnabled = true; AddIdleObserverWithInvalidTimeEnabled = false; - caseZero(); - + SpecialPowers.pushPrefEnv({"set":[['dom.idle-observers-api.fuzz_time.disabled', true]]}, caseZero); ]]> diff --git a/dom/base/test/test_bug715041_removal.xul b/dom/base/test/test_bug715041_removal.xul index 2b77dd5949d6..1a61ed83d6f2 100644 --- a/dom/base/test/test_bug715041_removal.xul +++ b/dom/base/test/test_bug715041_removal.xul @@ -19,8 +19,6 @@ target="_blank">Mozilla Bug 715041 Mozilla Bug 715041 var RemoveHeadAfterLastLocalFiredEnabled = true; var RemoveHeadIdleObserverWhileIdleCase1Enabled = true; var RemoveLastAddLastEnabled = true; - - RemoveHeadIdleObserverWhileActive(); - + SpecialPowers.pushPrefEnv({"set":[['dom.idle-observers-api.fuzz_time.disabled', true]]}, RemoveHeadIdleObserverWhileActive); ]]> diff --git a/dom/base/test/test_child_process_shutdown_message.html b/dom/base/test/test_child_process_shutdown_message.html index e58bcc057cbf..ab785c21f292 100644 --- a/dom/base/test/test_child_process_shutdown_message.html +++ b/dom/base/test/test_child_process_shutdown_message.html @@ -117,15 +117,13 @@ function expectFrameProcessShutdown(iframe, frameMM, processMM, callback) { } function setUp() { - SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true); - SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", true); SpecialPowers.addPermission("browser", true, window.document); SpecialPowers.addPermission("embed-apps", true, window.document); - - // TODO: remove in bug 820712 - SpecialPowers.setBoolPref("network.disable.ipc.security", true); - - runNextTest(); + // TODO: remove network.disable.ipc.security in bug 820712 + SpecialPowers.pushPrefEnv({ + "set": [['dom.mozBrowserFramesEnabled', true], + ['dom.ipc.browser_frames.oop_by_default', true], + ['network.disable.ipc.security', true]]}, runNextTest); } function makeKillTest(isApp) function testKill() { @@ -147,12 +145,6 @@ function makeKillTest(isApp) function testKill() { } function tearDown() { - SpecialPowers.clearUserPref("dom.mozBrowserFramesEnabled"); - SpecialPowers.clearUserPref("dom.ipc.browser_frames.oop_by_default"); - - // TODO: remove in bug 820712 - SpecialPowers.clearUserPref("network.disable.ipc.security"); - SimpleTest.finish(); } diff --git a/dom/base/test/test_messagemanager_assertpermission.html b/dom/base/test/test_messagemanager_assertpermission.html index df3f9af46aa9..2a5becb68014 100644 --- a/dom/base/test/test_messagemanager_assertpermission.html +++ b/dom/base/test/test_messagemanager_assertpermission.html @@ -27,8 +27,6 @@ let gAppsService = SpecialPowers.Cc["@mozilla.org/AppsService;1"] .getService(SpecialPowers.Ci.nsIAppsService); function setUp() { - SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true); - SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", true); SpecialPowers.addPermission("browser", true, window.document); SpecialPowers.addPermission("embed-apps", true, window.document); @@ -36,7 +34,8 @@ function setUp() { SpecialPowers.addPermission("foobar", true, { url: APP_URL, appId: appId, isInBrowserElement: false }); - runNextTest(); + SpecialPowers.pushPrefEnv({"set":[['dom.mozBrowserFramesEnabled', true], + ['dom.ipc.browser_frames.oop_by_default', true]]}, runNextTest); } /** @@ -168,8 +167,6 @@ function testChildProcessMessageManager() { } function tearDown() { - SpecialPowers.clearUserPref("dom.mozBrowserFramesEnabled"); - SpecialPowers.clearUserPref("dom.ipc.browser_frames.oop_by_default"); SimpleTest.finish(); } diff --git a/dom/base/test/test_websocket_permessage_deflate.html b/dom/base/test/test_websocket_permessage_deflate.html index e2d70aa6acf5..83504b6c52fd 100644 --- a/dom/base/test/test_websocket_permessage_deflate.html +++ b/dom/base/test/test_websocket_permessage_deflate.html @@ -5,7 +5,7 @@ - + Mozilla Bug