Bug 775868, part 1: make tests access DomWinUtils via SpecialPowers. r=smaug

This commit is contained in:
Andrew McCreight 2012-09-10 12:43:45 -07:00
parent f904bb0432
commit e833ece4f7
11 changed files with 12 additions and 37 deletions

View File

@ -13,8 +13,7 @@ const Services = Cu.import("resource://gre/modules/Services.jsm").Services;
const DOMIdentity = Cu.import("resource://gre/modules/DOMIdentity.jsm")
.DOMIdentity;
let util = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let util = SpecialPowers.getDOMWindowUtils(window);
let outerWinId = util.outerWindowID;
const identity = navigator.id || navigator.mozId;

View File

@ -51,9 +51,7 @@ function registerMockPromptService()
// leave the modal state -- this is done to trigger the necessary
// accounting for triggering the "stop showing more prompts" code for
// abusive pages.
var winUtils = this.domWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
var winUtils = SpecialPowers.getDOMWindowUtils(this.domWindow);
var w = winUtils.enterModalStateWithWindow();
winUtils.leaveModalStateWithWindow(w);
},

View File

@ -25,10 +25,7 @@
<script type="application/javascript;version=1.8">
// Enable privileges so we can use nsIDOMWindowUtils interface
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var domWindowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
var domWindowUtils = SpecialPowers.getDOMWindowUtils(window);
/*
nsIDOMElement elementFromPoint(in long aX,

View File

@ -24,12 +24,9 @@
}
function testScrollXY() {
// Enable privileges so we can use nsIDOMWindowUtils interface
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
let iframe = document.getElementById("iframe");
let cwindow = iframe.contentWindow;
let domWindowUtils = cwindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
let domWindowUtils = SpecialPowers.getDOMWindowUtils(cwindow);
function checkGetScrollXYState(flush, vals, testName) {
let scrollX = {}, scrollY = {};
@ -64,8 +61,7 @@
function testHiddenIframe() {
let iframe = document.getElementById("hidden-iframe");
let cwindow = iframe.contentWindow;
let domWindowUtils = cwindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
let domWindowUtils = SpecialPowers.getDOMWindowUtils(cwindow);
// make sure getScrollXY doesn't throw
let scrollX = {}, scrollY = {};

View File

@ -38,9 +38,7 @@ addLoadEvent(function test() {
var
CI = Components.interfaces,
WinUtils = window
.QueryInterface(CI.nsIInterfaceRequestor)
.getInterface(CI.nsIDOMWindowUtils),
WinUtils = SpecialPowers.getDOMWindowUtils(window),
sec = netscape.security,
eSelect = $("eSelect"),
IDOMEvent = CI.nsIDOMEvent,
@ -48,7 +46,6 @@ addLoadEvent(function test() {
timeout = 0 // Choose a larger value like 500 ms if you want to see what's happening.
function keypressOnSelect(key, modifiers) {
sec.PrivilegeManager.enablePrivilege("UniversalXPConnect")
WinUtils.focus(eSelect)
WinUtils.sendKeyEvent("keyup", key, 0, modifiers, WinUtils.KEY_FLAG_PREVENT_DEFAULT)
WinUtils.sendKeyEvent("keypress", key, 0, modifiers, WinUtils.KEY_FLAG_PREVENT_DEFAULT)
@ -66,7 +63,6 @@ addLoadEvent(function test() {
// This timeout and the following are necessary to let the sent events take effect.
setTimeout(cont1, timeout)
function cont1() {
sec.PrivilegeManager.enablePrivilege("UniversalXPConnect")
// Move the mouse over option 3 (90 = 3 (rows) * 24 (row height) + 18).
WinUtils.sendMouseEvent("mousemove", 355, 90, 0, 0, 0, true)
setTimeout(cont2, timeout)
@ -77,7 +73,6 @@ addLoadEvent(function test() {
setTimeout(cont3, timeout)
}
function cont3() {
sec.PrivilegeManager.enablePrivilege("UniversalXPConnect")
is(eSelect.value, "3", "Select's value should be 3 after hovering over option 3 and pressing " + keyString + ".")
is(eSelect.onchangeCount, 1, "Onchange should have fired once.")

View File

@ -30,8 +30,7 @@ SimpleTest.waitForExplicitFinish();
var testNum = 0;
var dialogNum = 0;
var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);
var utils = SpecialPowers.getDOMWindowUtils(window);
function hasTabModalPrompts() {
var prefName = "prompts.tab_modal.enabled";

View File

@ -52,8 +52,7 @@ function startPopupTests(tests)
document.addEventListener("DOMMenuBarInactive", eventOccurred, false);
gPopupTests = tests;
gWindowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
gWindowUtils = SpecialPowers.getDOMWindowUtils(window);
goNext();
}
@ -84,15 +83,11 @@ function is(left, right, message) {
}
function disableNonTestMouse(aDisable) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
gWindowUtils.disableNonTestMouseEvents(aDisable);
}
function eventOccurred(event)
{
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
if (gPopupTests.length <= gTestIndex) {
ok(false, "Extra " + event.type + " event fired");
return;

View File

@ -147,8 +147,7 @@ function call_sequentially() {
function setup_provisioning(identity, afterSetupCallback, doneProvisioningCallback, callerCallbacks) {
IDService.reset();
let util = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let util = SpecialPowers.getDOMWindowUtils(window);
let provId = util.outerWindowID;
IDService.IDP._provisionFlows[provId] = {

View File

@ -28,8 +28,7 @@ SimpleTest.waitForExplicitFinish();
const DOMIdentity = Cu.import("resource://gre/modules/DOMIdentity.jsm")
.DOMIdentity;
let outerWinId = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
let outerWinId = SpecialPowers.getDOMWindowUtils(window).outerWindowID;
function run_next_auth_test() {
// Reset the DOM state then run the next test

View File

@ -28,8 +28,7 @@ SimpleTest.waitForExplicitFinish();
const DOMIdentity = Cu.import("resource://gre/modules/DOMIdentity.jsm")
.DOMIdentity;
let outerWinId = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
let outerWinId = SpecialPowers.getDOMWindowUtils(window).outerWindowID;
function check_provision_flow_done(provId) {
do_check_null(IdentityProvider._provisionFlows[provId]);

View File

@ -28,8 +28,7 @@ SimpleTest.waitForExplicitFinish();
const DOMIdentity = Cu.import("resource://gre/modules/DOMIdentity.jsm")
.DOMIdentity;
let outerWinId = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
let outerWinId = SpecialPowers.getDOMWindowUtils(window).outerWindowID;
// Reset the DOM state then run the next test
function run_next_rp_test() {