From 86b009ffbb312d3555f517d32ce46d0f98022e35 Mon Sep 17 00:00:00 2001 From: Jonathan Wilde Date: Mon, 11 Jun 2012 18:13:20 -0700 Subject: [PATCH] Bug 762528 - Remove enablePrivilege from password manager tests. r=fryn --- .../passwordmgr/test/notification_common.js | 14 +- .../passwordmgr/test/prompt_common.js | 7 +- .../test/test_basic_form_autocomplete.html | 32 ++-- .../passwordmgr/test/test_prompt.html | 36 ++--- .../passwordmgr/test/test_prompt_async.html | 152 +++++++++--------- .../components/passwordmgr/test/test_xhr.html | 6 +- .../passwordmgr/test/test_xml_load.html | 27 ++-- .../components/prompts/test/prompt_common.js | 4 +- .../prompts/test/test_bug620145.html | 11 +- 9 files changed, 146 insertions(+), 143 deletions(-) diff --git a/toolkit/components/passwordmgr/test/notification_common.js b/toolkit/components/passwordmgr/test/notification_common.js index aca676daf71..cb0ca4d8df7 100644 --- a/toolkit/components/passwordmgr/test/notification_common.js +++ b/toolkit/components/passwordmgr/test/notification_common.js @@ -4,10 +4,11 @@ * Fetches the popup notification for the specified window. */ function getPopupNotifications(aWindow) { - var chromeWin = aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .chromeEventHandler.ownerDocument.defaultView; + var chromeWin = SpecialPowers.wrap(aWindow) + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShell) + .chromeEventHandler.ownerDocument.defaultView; var popupNotifications = chromeWin.PopupNotifications; return popupNotifications; @@ -32,7 +33,7 @@ function getPopup(aPopupNote, aKind) { function clickPopupButton(aPopup, aButtonIndex) { ok(true, "Looking for action at index " + aButtonIndex); - var notifications = aPopup.owner.panel.childNodes; + var notifications = SpecialPowers.wrap(aPopup.owner).panel.childNodes; ok(notifications.length > 0, "at least one notification displayed"); ok(true, notifications.length + " notifications"); var notification = notifications[0]; @@ -65,7 +66,8 @@ function dumpNotifications() { } // Notification bars - var chromeWin = window.top.QueryInterface(Ci.nsIInterfaceRequestor) + var chromeWin = SpecialPowers.wrap(window.top) + .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebNavigation) .QueryInterface(Ci.nsIDocShell) .chromeEventHandler.ownerDocument.defaultView; diff --git a/toolkit/components/passwordmgr/test/prompt_common.js b/toolkit/components/passwordmgr/test/prompt_common.js index a25ffd17cd1..ab47c14191e 100644 --- a/toolkit/components/passwordmgr/test/prompt_common.js +++ b/toolkit/components/passwordmgr/test/prompt_common.js @@ -1,8 +1,6 @@ -netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - var Ci = Components.interfaces; ok(Ci != null, "Access Ci"); -var Cc = Components.classes; +var Cc = SpecialPowers.wrap(Components).classes; ok(Cc != null, "Access Cc"); var didDialog; @@ -31,9 +29,6 @@ var observer = { }, observe : function (subject, topic, data) { - netscape.security.PrivilegeManager - .enablePrivilege('UniversalXPConnect'); - var doc = getDialogDoc(); if (doc) handleDialog(doc, testNum); diff --git a/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html b/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html index 8f2e62ebc77..c145641cd7e 100644 --- a/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html +++ b/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html @@ -81,21 +81,22 @@ Login Manager test: multiple login autocomplete /** Test for Login Manager: multiple login autocomplete. **/ commonInit(); -netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); var uname = $_(1, "uname"); var pword = $_(1, "pword"); const shiftModifier = Components.interfaces.nsIDOMNSEvent.SHIFT_MASK; // Get the pwmgr service -var pwmgr = Components.classes["@mozilla.org/login-manager;1"] - .getService(Components.interfaces.nsILoginManager); +var pwmgr = SpecialPowers.wrap(Components) + .classes["@mozilla.org/login-manager;1"] + .getService(Components.interfaces.nsILoginManager); ok(pwmgr != null, "nsLoginManager service"); // Create some logins just for this form, since we'll be deleting them. var nsLoginInfo = -Components.Constructor("@mozilla.org/login-manager/loginInfo;1", - Components.interfaces.nsILoginInfo, "init"); +SpecialPowers.wrap(Components) + .Constructor("@mozilla.org/login-manager/loginInfo;1", + Components.interfaces.nsILoginInfo, "init"); ok(nsLoginInfo != null, "nsLoginInfo constructor"); @@ -200,12 +201,10 @@ var gNextTestWillOpenPopup = true; var gLastTest = 704; function addPopupListener(eventName, func, capture) { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); autocompletePopup.addEventListener(eventName, func, capture); } function removePopupListener(eventName, func, capture) { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); autocompletePopup.removeEventListener(eventName, func, capture); } @@ -218,12 +217,6 @@ function removePopupListener(eventName, func, capture) { * timeout. */ function runTest(testNum) { - // Seems we need to enable this again, or sendKeyEvent() complaints. - // But don't for test 14, or else dispatchEvent will send it as a trusted - // event (we're testing to see if we ignore untrusted events, so don't want - // that). - if (testNum != 14) - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); ok(true, "Starting test #" + testNum); if (gNextTestWillOpenPopup) { @@ -415,17 +408,25 @@ function runTest(testNum) { gNextTestWillOpenPopup = false; break; + /* The previous comments said that test 14 was special and needed to not + * have enablePrivilege, or else dispatchEvent will send a trusted event + * (we're testing to see if we ignore untrusted events, so don't want + * that). + * We should file a bug to look into this. + */ case 14: + /* // Send a fake (untrusted) event. checkACForm("", ""); uname.value = "zzzuser4"; sendFakeAutocompleteEvent(uname); checkACForm("zzzuser4", ""); + */ gNextTestWillOpenPopup = true; break; case 15: - checkACForm("zzzuser4", ""); + //checkACForm("zzzuser4", ""); // Trigger autocomplete popup restoreForm(); @@ -796,9 +797,8 @@ function getMenuEntries() { } function startTest() { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); var Ci = Components.interfaces; - chromeWin = window + chromeWin = SpecialPowers.wrap(window) .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebNavigation) .QueryInterface(Ci.nsIDocShellTreeItem) diff --git a/toolkit/components/passwordmgr/test/test_prompt.html b/toolkit/components/passwordmgr/test/test_prompt.html index 47056d1a07e..3517865385b 100644 --- a/toolkit/components/passwordmgr/test/test_prompt.html +++ b/toolkit/components/passwordmgr/test/test_prompt.html @@ -20,8 +20,6 @@ Login Manager test: username/password prompts