Bug 789494 - Rip enablePrivilege out of misbehaving mochitests. r=mccr8

This commit is contained in:
Bobby Holley 2012-09-07 11:28:56 -07:00
parent 5832a14c90
commit 1743880368
12 changed files with 32 additions and 55 deletions

View File

@ -21,14 +21,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=448602
function runTests() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
/*
Disabled due to lack of present support for JSD in JM
var jsdIDebuggerService = Components.interfaces.jsdIDebuggerService;
var jsd = Components.classes['@mozilla.org/js/jsd/debugger-service;1']
.getService(jsdIDebuggerService);
*/
var els = Components.classes["@mozilla.org/eventlistenerservice;1"]
var els = SpecialPowers.wrap(Components).classes["@mozilla.org/eventlistenerservice;1"]
.getService(Components.interfaces.nsIEventListenerService);
// Event listener info tests
@ -107,7 +106,7 @@ function runTests() {
var l2 = document.getElementById("testlevel2");
var l3 = document.getElementById("testlevel3");
var textnode = l3.firstChild;
var chain = els.getEventTargetChainFor(textnode, {});
var chain = SpecialPowers.unwrap(els.getEventTargetChainFor(textnode, {}));
ok(chain.length > 3, "Too short event target chain.");
is(chain[0], textnode, "Wrong chain item (1)");
is(chain[1], l3, "Wrong chain item (2)");

View File

@ -33,7 +33,6 @@ SimpleTest.waitForExplicitFinish();
* In other words, they obey the interface that |hold| expects its |accessor|
* parameter to obey.
*/
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var popupMax = makePrefAccessor("dom.popup_maximum"),
popupEvents = makePrefAccessor("dom.popup_allowed_events"),
blockPopups = makePrefAccessor("dom.disable_open_during_load"),
@ -134,7 +133,6 @@ function check_sanity() {
}
setTimeout(function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
check_sanity();
hold(blockPopups, true, run_tests);
SimpleTest.finish();

View File

@ -52,13 +52,11 @@ function alter_file(uri, file) {
(function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
var prefService = SpecialPowers.wrap(Components).classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService),
pm = Components.classes["@mozilla.org/permissionmanager;1"]
pm = SpecialPowers.wrap(Components).classes["@mozilla.org/permissionmanager;1"]
.getService(Components.interfaces.nsIPermissionManager),
ioService = Components.classes["@mozilla.org/network/io-service;1"]
ioService = SpecialPowers.wrap(Components).classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
ALLOW_ACTION = pm.ALLOW_ACTION;
@ -100,7 +98,7 @@ function alter_file(uri, file) {
makePopupPrivAccessor = function(uri) {
uri = ioService.newURI(uri, null, null);
var principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
var principal = SpecialPowers.wrap(Components).classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(uri);

View File

@ -6,6 +6,7 @@
<script type="text/javascript">
const DOM_QUOTA_REACHED = 2152924150;
const Cc = SpecialPowers.wrap(Components).classes;
function checkException(func, exc)
{
@ -22,12 +23,10 @@ function checkException(func, exc)
function doStep()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var io = Components.classes["@mozilla.org/network/io-service;1"]
var io = Cc["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var uri = io.newURI(window.location, "", null);
var cp = Components.classes["@mozilla.org/cookie/permission;1"]
var cp = Cc["@mozilla.org/cookie/permission;1"]
.getService(Components.interfaces.nsICookiePermission);
cp.setAccess(uri, Components.interfaces.nsICookiePermission.ACCESS_SESSION);

View File

@ -9,12 +9,10 @@
function startTest()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var io = Components.classes["@mozilla.org/network/io-service;1"]
var io = SpecialPowers.wrap(Components).classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var uri = io.newURI(window.location, "", null);
var cp = Components.classes["@mozilla.org/cookie/permission;1"]
var cp = SpecialPowers.wrap(Components).classes["@mozilla.org/cookie/permission;1"]
.getService(Components.interfaces.nsICookiePermission);
cp.setAccess(uri, Components.interfaces.nsICookiePermission.ACCESS_DENY);

View File

@ -19,12 +19,10 @@ function startTest()
localStorage.setItem("persistent1", "persistent value 1");
localStorage.setItem("persistent2", "persistent value 2");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var io = Components.classes["@mozilla.org/network/io-service;1"]
var io = SpecialPowers.wrap(Components).classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var uri = io.newURI(window.location, "", null);
var cp = Components.classes["@mozilla.org/cookie/permission;1"]
var cp = SpecialPowers.wrap(Components).classes["@mozilla.org/cookie/permission;1"]
.getService(Components.interfaces.nsICookiePermission);
cp.setAccess(uri, Components.interfaces.nsICookiePermission.ACCESS_SESSION);

View File

@ -9,12 +9,10 @@
function startTest()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var io = Components.classes["@mozilla.org/network/io-service;1"]
var io = SpecialPowers.wrap(Components).classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var uri = io.newURI(window.location, "", null);
var cp = Components.classes["@mozilla.org/cookie/permission;1"]
var cp = SpecialPowers.wrap(Components).classes["@mozilla.org/cookie/permission;1"]
.getService(Components.interfaces.nsICookiePermission);
is(localStorage.getItem("session only"), "session value", "Value present when cookies in session-only mode");

View File

@ -7,9 +7,7 @@
<script type="text/javascript">
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
Components.utils.import("resource://gre/modules/Services.jsm");
window.Services = SpecialPowers.Services;
// Set cookies behavior to "always reject".
Services.prefs.setIntPref("network.cookie.cookieBehavior", 2);

View File

@ -8,27 +8,27 @@
<script type="text/javascript">
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
const Cc = SpecialPowers.wrap(Components).classes;
var currentTest = 1;
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
var prefs = Cc["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var io = Components.classes["@mozilla.org/network/io-service;1"]
var io = Cc["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var uri = io.newURI(window.location, "", null);
var cp = Components.classes["@mozilla.org/cookie/permission;1"]
var cp = Cc["@mozilla.org/cookie/permission;1"]
.getService(Components.interfaces.nsICookiePermission);
var quota, quotaOffline;
function addOfflineApp(url)
{
var permissionManager = Components.classes["@mozilla.org/permissionmanager;1"]
var permissionManager = Cc["@mozilla.org/permissionmanager;1"]
.getService(Components.interfaces.nsIPermissionManager);
var uri = Components.classes["@mozilla.org/network/io-service;1"]
var uri = Cc["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService)
.newURI(url, null, null);
var principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
var principal = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(uri);
@ -38,12 +38,12 @@ function addOfflineApp(url)
function removeOfflineApp(url)
{
var permissionManager = Components.classes["@mozilla.org/permissionmanager;1"]
var permissionManager = Cc["@mozilla.org/permissionmanager;1"]
.getService(Components.interfaces.nsIPermissionManager);
var uri = Components.classes["@mozilla.org/network/io-service;1"]
var uri = Cc["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService)
.newURI(url, null, null);
var principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
var principal = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(uri);
@ -54,8 +54,6 @@ function doNextTest()
{
slave = frame;
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
switch (currentTest)
{
// Initialy setup the quota to testing value of 1024B and

View File

@ -27,10 +27,9 @@ window.fileInputGotClick = false;
// 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)
var prefs = SpecialPowers.wrap(Components).classes[prefSvcContractID].getService(prefSvcIID)
.getBranch("accessibility.");
if (!newValue) {
prefs.clearUserPref("tabfocus");
@ -40,9 +39,7 @@ function setOrRestoreTabFocus(newValue) {
}
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, 0);
@ -51,7 +48,6 @@ function tab() {
}
function test() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// Try to find the 'Browse...' using tabbing.
var i = 0;
while (!window.oTarget && i < 100) {
@ -67,11 +63,11 @@ function test() {
}
ok(window.oTarget instanceof HTMLInputElement, "Should have focused an input element!")
ok(window.oTarget.type == "button", "Should have focused 'Browse...' button!");
ok(SpecialPowers.wrap(window.oTarget).type == "button", "Should have focused 'Browse...' button!");
var e = document.createEvent("mouseevents");
e.initMouseEvent("click", true, true, window, 0, 1, 1, 1, 1,
false, false, false, false, 0, null);
window.oTarget.dispatchEvent(e);
SpecialPowers.wrap(window.oTarget).dispatchEvent(e);
ok(window.fileInputGotClick,
"File input should have got a click event, but not open the file dialog.");
setOrRestoreTabFocus(0);

View File

@ -16,8 +16,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=619644
<script class="testbody" type="text/javascript">
function hasTabModalPrompts() {
var prefName = "prompts.tab_modal.enabled";
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
Components.utils.import("resource://gre/modules/Services.jsm");
Services = SpecialPowers.Services;
return Services.prefs.getPrefType(prefName) == Services.prefs.PREF_BOOL &&
Services.prefs.getBoolPref(prefName);
}

View File

@ -1,14 +1,12 @@
(function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// Set cache size to something large
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
var prefService = SpecialPowers.wrap(Components).classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var branch = prefService.getBranch("media.");
var oldSize = branch.getIntPref("cache_size");
branch.setIntPref("cache_size", 40000);
window.addEventListener("unload", function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
branch.setIntPref("cache_size", oldSize);
}, false);
})();