diff --git a/content/base/test/test_bug466409.html b/content/base/test/test_bug466409.html index 2ed44498f15e..04279b75d83c 100644 --- a/content/base/test/test_bug466409.html +++ b/content/base/test/test_bug466409.html @@ -21,12 +21,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=466409 function setUniversalDetector(detector) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var pref = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch); - - var olddetector = pref.getCharPref("intl.charset.detector"); - pref.setCharPref("intl.charset.detector", detector); + var olddetector = SpecialPowers.getCharPref("intl.charset.detector"); + SpecialPowers.setCharPref("intl.charset.detector", detector); return olddetector; } diff --git a/content/events/test/bug299673.js b/content/events/test/bug299673.js index 265e2a4a5f4a..cd32fdcc728f 100644 --- a/content/events/test/bug299673.js +++ b/content/events/test/bug299673.js @@ -2,7 +2,6 @@ var popup; function OpenWindow() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); log({},">>> OpenWindow"); popup = window.open("","Test"); @@ -50,7 +49,6 @@ document.onblur=function (event) { log(event,"top-doc") }; document.onchange=function (event) { log(event,"top-doc") }; function doTest1_rest2(expectedEventLog,focusAfterCloseId) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); try { is(document.activeElement, document.getElementById(focusAfterCloseId), "wrong element is focused after popup was closed"); is(result, expectedEventLog, "unexpected events"); @@ -62,7 +60,6 @@ function doTest1_rest2(expectedEventLog,focusAfterCloseId) { } } function doTest1_rest1(expectedEventLog,focusAfterCloseId) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); try { synthesizeKey("V", {}, popup); synthesizeKey("A", {}, popup); @@ -82,13 +79,10 @@ function doTest1_rest1(expectedEventLog,focusAfterCloseId) { } function doTest1(expectedEventLog,focusAfterCloseId) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); try { var select1 = document.getElementById('Select1'); select1.focus(); is(document.activeElement, select1, "select element should be focused"); - var wu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIDOMWindowUtils); synthesizeKey("VK_DOWN",{}); synthesizeKey("VK_TAB", {}); SimpleTest.waitForFocus(function () { doTest1_rest1(expectedEventLog,focusAfterCloseId); }, popup); @@ -101,18 +95,15 @@ function doTest1(expectedEventLog,focusAfterCloseId) { } function setPrefAndDoTest(expectedEventLog,focusAfterCloseId,prefValue) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var prefs = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch); - var origPrefValue = prefs.getIntPref("browser.link.open_newwindow"); + var origPrefValue = SpecialPowers.getIntPref("browser.link.open_newwindow"); var select1 = document.getElementById('Select1'); select1.blur(); result = ""; log({},"Test with browser.link.open_newwindow = "+prefValue); try { - prefs.setIntPref("browser.link.open_newwindow", prefValue); + SpecialPowers.setIntPref("browser.link.open_newwindow", prefValue); doTest1(expectedEventLog,focusAfterCloseId); } finally { - prefs.setIntPref("browser.link.open_newwindow", origPrefValue); + SpecialPowers.setIntPref("browser.link.open_newwindow", origPrefValue); } } diff --git a/content/events/test/test_bug226361.xhtml b/content/events/test/test_bug226361.xhtml index 1d368164769e..65364cd30e17 100644 --- a/content/events/test/test_bug226361.xhtml +++ b/content/events/test/test_bug226361.xhtml @@ -30,17 +30,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=226361 // accessibility.tabfocus must be set to value 7 before running test also // on a mac. function setOrRestoreTabFocus(newValue) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - const prefSvcContractID = "@mozilla.org/preferences-service;1"; - const prefSvcIID = Components.interfaces.nsIPrefService; - var prefs = Components.classes[prefSvcContractID].getService(prefSvcIID) - .getBranch("accessibility."); if (!newValue) { - if (prefs.prefHasUserValue("tabfocus")) { - prefs.clearUserPref("tabfocus"); - } + SpecialPowers.clearUserPref("accessibility.tabfocus"); } else { - prefs.setIntPref("tabfocus", newValue); + SpecialPowers.setIntPref("accessibility.tabfocus", newValue); } } diff --git a/content/events/test/test_bug238987.html b/content/events/test/test_bug238987.html index 4903aa364573..ec20f57b264b 100644 --- a/content/events/test/test_bug238987.html +++ b/content/events/test/test_bug238987.html @@ -34,15 +34,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=238987 // accessibility.tabfocus must be set to value 7 before running test also // on a mac. function setOrRestoreTabFocus(newValue) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - const prefSvcContractID = "@mozilla.org/preferences-service;1"; - const prefSvcIID = Components.interfaces.nsIPrefService; - var prefs = Components.classes[prefSvcContractID].getService(prefSvcIID) - .getBranch("accessibility."); if (!newValue) { - prefs.clearUserPref("tabfocus"); + SpecialPowers.clearUserPref("accessibility.tabfocus"); } else { - prefs.setIntPref("tabfocus", newValue); + SpecialPowers.setIntPref("accessibility.tabfocus", newValue); } } @@ -105,9 +100,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=238987 } function tab() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); + var utils = SpecialPowers.DOMWindowUtils; // Send tab key events. var key = Components.interfaces.nsIDOMKeyEvent.DOM_VK_TAB; utils.sendKeyEvent("keydown", key, 0, modifier); diff --git a/content/events/test/test_bug409604.html b/content/events/test/test_bug409604.html index d3e419aa78d5..6b416af51be4 100644 --- a/content/events/test/test_bug409604.html +++ b/content/events/test/test_bug409604.html @@ -92,15 +92,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=409604 // ui.key.contentAccess must be set to value 5 before running the test. function setOrRestoreContentAccess(newValue) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - const prefSvcContractID = "@mozilla.org/preferences-service;1"; - const prefSvcIID = Components.interfaces.nsIPrefService; - var prefs = Components.classes[prefSvcContractID].getService(prefSvcIID) - .getBranch("ui.key."); if (!newValue) { - prefs.clearUserPref("contentAccess"); + SpecialPowers.clearUserPref("ui.key.contentAccess"); } else { - prefs.setIntPref("contentAccess", newValue); + SpecialPowers.setIntPref("ui.key.contentAccess", newValue); } } @@ -134,10 +129,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=409604 } function pressAccessKey(key) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - // Send key events. - var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); + var utils = SpecialPowers.DOMWindowUtils; utils.sendKeyEvent("keydown", key, key, modifier); utils.sendKeyEvent("keypress", key, key, modifier); utils.sendKeyEvent("keyup", key, key, modifier); diff --git a/content/events/test/test_bug457672.html b/content/events/test/test_bug457672.html index 074e61e75ce1..6d1b32d611a5 100644 --- a/content/events/test/test_bug457672.html +++ b/content/events/test/test_bug457672.html @@ -24,15 +24,10 @@ SimpleTest.expectAssertions(1); var windowBlurCount = 0; function setUserPref(reset) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - const prefSvcContractID = "@mozilla.org/preferences-service;1"; - const prefSvcIID = Components.interfaces.nsIPrefService; - var prefs = Components.classes[prefSvcContractID].getService(prefSvcIID) - .getBranch("browser.link."); if (reset) { - prefs.clearUserPref("open_newwindow"); + SpecialPowers.clearUserPref("browser.link.open_newwindow"); } else { - prefs.setIntPref("open_newwindow", 3); + SpecialPowers.setIntPref("browser.link.open_newwindow", 3); } } diff --git a/content/events/test/test_bug563329.html b/content/events/test/test_bug563329.html index ce32f73dba87..79af82f8711f 100644 --- a/content/events/test/test_bug563329.html +++ b/content/events/test/test_bug563329.html @@ -39,10 +39,7 @@ function getTests() { function doTest() { // Enable context menus - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var prefs = Components.classes["@mozilla.org/preferences-service;1"]. - getService(Components.interfaces.nsIPrefBranch); - prefs.setBoolPref("ui.click_hold_context_menus", true); + SpecialPowers.setBoolPref("ui.click_hold_context_menus", true); target = document.getElementById("testTarget"); @@ -69,26 +66,20 @@ function doCheckDuration() { var duration = 50; // Change click hold delay - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var prefs = Components.classes["@mozilla.org/preferences-service;1"]. - getService(Components.interfaces.nsIPrefBranch); - prefs.setIntPref("ui.click_hold_context_menus.delay", duration); + SpecialPowers.setIntPref("ui.click_hold_context_menus.delay", duration); synthesizeMouse(target, 0, 0, {type: "mousedown"}); } function finishTest() { synthesizeKey("VK_ESCAPE", {}, window); - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var prefs = Components.classes["@mozilla.org/preferences-service;1"]. - getService(Components.interfaces.nsIPrefBranch); try { - prefs.clearUserPref("ui.click_hold_context_menus"); + SpecialPowers.clearUserPref("ui.click_hold_context_menus"); } catch(e) {} try { - prefs.clearUserPref("ui.click_hold_context_menus.delay"); + SpecialPowers.clearUserPref("ui.click_hold_context_menus.delay"); } catch(e) {} diff --git a/content/events/test/test_bug574663.html b/content/events/test/test_bug574663.html index 0cc5cf7607ce..1edc3f8819c6 100644 --- a/content/events/test/test_bug574663.html +++ b/content/events/test/test_bug574663.html @@ -57,7 +57,6 @@ function runTest() { winUtils.advanceTimeAndRefresh(1000); function nextTest() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); if (!outstandingTests.length) { winUtils.restoreNormalRefresh(); win.close(); @@ -74,7 +73,6 @@ function runTest() { winUtils.advanceTimeAndRefresh(1000); // force scrolling to happen setTimeout(function () { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); if (!ctrlKey) { let postfix = isMomentum ? ", even after releasing the touchpad" : ""; // Normal scroll: scroll @@ -102,27 +100,20 @@ function runTest() { function initPrefs() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var prefSvc = Components.classes["@mozilla.org/preferences-service;1"]. - getService(Components.interfaces.nsIPrefBranch); - prefSvc.setBoolPref("general.smoothScroll", false); + SpecialPowers.setBoolPref("general.smoothScroll", false); // Disables the app level scroll acceleration - prefSvc.setIntPref("mousewheel.acceleration.start", -1); - prefSvc.setBoolPref("mousewheel.system_scroll_override_on_root_content.enabled", false); + SpecialPowers.setIntPref("mousewheel.acceleration.start", -1); + SpecialPowers.setBoolPref("mousewheel.system_scroll_override_on_root_content.enabled", false); // Enable zooming for ctrl-scrolling - prefSvc.setIntPref("mousewheel.with_control.action", 3); + SpecialPowers.setIntPref("mousewheel.with_control.action", 3); } function clearPrefs() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var prefSvc = Components.classes["@mozilla.org/preferences-service;1"]. - getService(Components.interfaces.nsIPrefBranch); - - prefSvc.clearUserPref("general.smoothScroll"); - prefSvc.clearUserPref("mousewheel.acceleration.start"); - prefSvc.clearUserPref("mousewheel.system_scroll_override_on_root_content.enabled"); - prefSvc.clearUserPref("mousewheel.with_control.action"); + SpecialPowers.clearUserPref("general.smoothScroll"); + SpecialPowers.clearUserPref("mousewheel.acceleration.start"); + SpecialPowers.clearUserPref("mousewheel.system_scroll_override_on_root_content.enabled"); + SpecialPowers.clearUserPref("mousewheel.with_control.action"); } window.onload = function () { diff --git a/content/events/test/test_bug607464.html b/content/events/test/test_bug607464.html index e02edf3b50e8..945e35c739ab 100644 --- a/content/events/test/test_bug607464.html +++ b/content/events/test/test_bug607464.html @@ -72,29 +72,19 @@ function runTest() { function initPrefs() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var prefSvc = Components.classes["@mozilla.org/preferences-service;1"]. - getService(Components.interfaces.nsIPrefBranch); // Disables the app level scroll acceleration - prefSvc.setIntPref("mousewheel.acceleration.start", -1); - prefSvc.setBoolPref("mousewheel.system_scroll_override_on_root_content.enabled", false); + SpecialPowers.setIntPref("mousewheel.acceleration.start", -1); + SpecialPowers.setBoolPref("mousewheel.system_scroll_override_on_root_content.enabled", false); // Enables smooth scrolling - prefSvc.setBoolPref("general.smoothScroll", true); + SpecialPowers.setBoolPref("general.smoothScroll", true); } function clearPrefs() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var prefSvc = Components.classes["@mozilla.org/preferences-service;1"]. - getService(Components.interfaces.nsIPrefBranch); - - if (prefSvc.prefHasUserValue("mousewheel.acceleration.start")) - prefSvc.clearUserPref("mousewheel.acceleration.start"); - if (prefSvc.prefHasUserValue("mousewheel.system_scroll_override_on_root_content.enabled")) - prefSvc.clearUserPref("mousewheel.system_scroll_override_on_root_content.enabled"); - if (prefSvc.prefHasUserValue("general.smoothScroll")) - prefSvc.clearUserPref("general.smoothScroll"); + SpecialPowers.clearUserPref("mousewheel.acceleration.start"); + SpecialPowers.clearUserPref("mousewheel.system_scroll_override_on_root_content.enabled"); + SpecialPowers.clearUserPref("general.smoothScroll"); } window.onload = function () { diff --git a/content/events/test/test_clickevent_on_input.html b/content/events/test/test_clickevent_on_input.html index e7da1e3c14f5..21838b48684f 100644 --- a/content/events/test/test_clickevent_on_input.html +++ b/content/events/test/test_clickevent_on_input.html @@ -42,12 +42,8 @@ function runTests() function isEnabledMiddleClickPaste() { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - - var prefs = Components.classes["@mozilla.org/preferences-service;1"]. - getService(Components.interfaces.nsIPrefBranch); try { - return prefs.getBoolPref("middlemouse.paste"); + return SpecialPowers.getBoolPref("middlemouse.paste"); } catch (e) { return false; } diff --git a/content/html/content/test/test_bug583533.html b/content/html/content/test/test_bug583533.html index 9fd6ce2a4a54..1042b6f09fff 100644 --- a/content/html/content/test/test_bug583533.html +++ b/content/html/content/test/test_bug583533.html @@ -20,10 +20,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=583533 /** Test for Bug 583533 **/ - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - - var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]. - getService(Components.interfaces.nsIStringBundleService); + var sbs = SpecialPowers.Cc['@mozilla.org/intl/stringbundle;1']. + getService(SpecialPowers.Ci.nsIStringBundleService); var bundle = sbs.createBundle("chrome://global-platform/locale/platformKeys.properties"); var shiftText = bundle.GetStringFromName("VK_SHIFT"); @@ -32,9 +30,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=583533 var metaText = bundle.GetStringFromName("VK_META"); var separatorText = bundle.GetStringFromName("MODIFIER_SEPARATOR"); - var modifier = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch) - .getIntPref("ui.key.contentAccess"); + var modifier = SpecialPowers.getIntPref("ui.key.contentAccess"); var isShift; var isAlt; diff --git a/content/html/document/test/test_bug369370.html b/content/html/document/test/test_bug369370.html index cafbcbace879..52fd79ecd4eb 100644 --- a/content/html/document/test/test_bug369370.html +++ b/content/html/document/test/test_bug369370.html @@ -89,16 +89,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=369370 is(kidDoc.body.scrollTop, 0, "Checking scrollTop"); kidWin.close(); - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - prefs.clearUserPref("browser.enable_automatic_image_resizing"); + SpecialPowers.clearUserPref("browser.enable_automatic_image_resizing"); SimpleTest.finish(); } SimpleTest.waitForExplicitFinish(); - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - var prefs = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch); - prefs.setBoolPref("browser.enable_automatic_image_resizing", true); + SpecialPowers.setBoolPref("browser.enable_automatic_image_resizing", true); var kidWin = window.open("bug369370-popup.png", "bug369370", "width=400,height=300"); var kidDoc; // will init onload