Bug 1149966 - Remove enablePrivilege calls from remaining mochitest. r?jmaher
MozReview-Commit-ID: D7KglhS4PCw
--- a/accessible/tests/crashtests/448064.xhtml
+++ b/accessible/tests/crashtests/448064.xhtml
@@ -27,40 +27,37 @@ function dumpAccessibleNode(aNode, level
msg += " noName ";
}
dump(msg + '\n');
}
function dumpAccessibleTree(aNode, level) {
-netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
level = level || 0;
dumpAccessibleNode(aNode, level);
try {
var child = aNode.firstChild;
while (child) {
dumpAccessibleTree(child, level + 1);
child = child.nextSibling;
}
} catch (e) {
dump("Error visiting child nodes: " + e + '\n');
}
}
function A(o) {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var acc = Components.classes['@mozilla.org/accessibilityService;1']
- .getService(Components.interfaces.nsIAccessibilityService);
+ var acc = SpecialPowers.Cc['@mozilla.org/accessibilityService;1']
+ .getService(SpecialPowers.Ci.nsIAccessibilityService);
return acc.getAccessibleFor(o);
}
function beginAccessible() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
dumpAccessibleTree(A(document),0);
}
setTimeout(beginAccessible, 100);
setTimeout(doe, 200);
function doe() {
document.getElementById('mw_a').appendChild(document.getElementById('mw_b'));
--- a/dom/tests/mochitest/bugs/bug346659-opener-echoer.html
+++ b/dom/tests/mochitest/bugs/bug346659-opener-echoer.html
@@ -1,6 +1,6 @@
<script>
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- window.opener.opener.postMessage(window.opener.testNum + " - " + window.x, "http://mochi.test:8888");
- window.opener.close();
- window.close();
+ var win = SpecialPowers.wrap(window).wrappedJSObject;
+ win.opener.opener.postMessage(win.opener.testNum + " - " + win.x, "http://mochi.test:8888");
+ win.opener.close();
+ win.close();
</script>
--- a/dom/tests/mochitest/bugs/bug346659-parent-echoer.html
+++ b/dom/tests/mochitest/bugs/bug346659-parent-echoer.html
@@ -1,5 +1,5 @@
<script>
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- window.parent.opener.postMessage(window.parent.testNum + " - " + window.x, "http://mochi.test:8888");
- window.parent.close();
+ var win = SpecialPowers.wrap(window).wrappedJSObject;
+ win.parent.opener.postMessage(win.parent.testNum + " - " + win.x, "http://mochi.test:8888");
+ win.parent.close();
</script>
--- a/dom/tests/mochitest/bugs/test_bug346659.html
+++ b/dom/tests/mochitest/bugs/test_bug346659.html
@@ -32,24 +32,21 @@ function handleCmd(evt) {
var cmd;
try {
cmd = JSON.parse(evt.data);
} catch (e) {
// Not json
return false;
}
- // Grab privileges so we can access cross-domain windows
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-
if ("load" in cmd) {
var testNum = cmd.load;
- var win = wins[testNum];
+ var win = SpecialPowers.wrap(wins[testNum]).wrappedJSObject;
win.childWin.x = testNum;
- if (win.childWin.opener == win) {
+ if (SpecialPowers.unwrap(win.childWin.opener) == SpecialPowers.unwrap(win)) {
if ("xsite" in cmd) {
var loc = r(window.location.href, "bug346659-opener-echoer.html");
} else {
var loc = r(win.location.href, "bug346659-opener-echoer.html");
}
} else {
if ("xsite" in cmd) {
var loc = r(window.location.href, "bug346659-parent-echoer.html");
--- a/dom/tests/mochitest/bugs/test_bug61098.html
+++ b/dom/tests/mochitest/bugs/test_bug61098.html
@@ -24,22 +24,21 @@ https://bugzilla.mozilla.org/show_bug.cg
SimpleTest.waitForExplicitFinish();
var mockPromptServiceRegisterer, mockPromptFactoryRegisterer;
var promptState;
function registerMockPromptService()
{
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var XPCOMUtils = SpecialPowers.Cu.import("resource://gre/modules/XPCOMUtils.jsm").XPCOMUtils;
var Ci = SpecialPowers.Ci;
function MockPrompt(aDOMWindow) {
- this.domWindow = aDOMWindow;
+ this.domWindow = SpecialPowers.unwrap(aDOMWindow);
}
MockPrompt.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPrompt]),
domWindow : null,
_toggleModalState: function()
--- a/embedding/test/test_bug449141.html
+++ b/embedding/test/test_bug449141.html
@@ -87,16 +87,15 @@ function persistDocument(aDoc) {
folder,
aDoc.contentType,
encodingFlags, kWrapColumn);
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var srcDoc = document.getElementById('source').contentDocument;
persistDocument(srcDoc);
});
</script>
</pre>
</body>
</html>
--- a/testing/mochitest/tests/SimpleTest/MockObjects.js
+++ b/testing/mochitest/tests/SimpleTest/MockObjects.js
@@ -32,59 +32,64 @@ MockObjectRegisterer.prototype = {
* restore the original component. Usually, you should use a try-catch block
* to ensure that unregister() is called.
*/
register: function MOR_register() {
if (this._originalFactory)
throw new Exception("Invalid object state when calling register()");
// Define a factory that creates a new object using the given constructor.
+ var isChrome = location.protocol == "chrome:";
var providedConstructor = this._replacementCtor;
this._mockFactory = {
createInstance: function MF_createInstance(aOuter, aIid) {
if (aOuter != null)
throw SpecialPowers.Cr.NS_ERROR_NO_AGGREGATION;
- return new providedConstructor().QueryInterface(aIid);
+ var inst = new providedConstructor();
+ if (!isChrome) {
+ var QI = inst.QueryInterface;
+ inst = SpecialPowers.wrapCallbackObject(inst);
+ inst.QueryInterface = QI;
+ }
+ return inst.QueryInterface(aIid);
}
};
+ if (!isChrome) {
+ this._mockFactory = SpecialPowers.wrapCallbackObject(this._mockFactory);
+ }
- var retVal = SpecialPowers.swapFactoryRegistration(this._cid, this._contractID, this._mockFactory, this._originalFactory);
+ var retVal = SpecialPowers.swapFactoryRegistration(null, this._contractID, this._mockFactory, this._originalFactory);
if ('error' in retVal) {
throw new Exception("ERROR: " + retVal.error);
+ } else if (!isChrome) {
+ this._originalFactory = SpecialPowers.wrap(retVal).originalFactory;
} else {
- this._cid = retVal.cid;
this._originalFactory = retVal.originalFactory;
}
},
/**
* Restores the original factory.
*/
unregister: function MOR_unregister() {
if (!this._originalFactory)
throw new Exception("Invalid object state when calling unregister()");
// Free references to the mock factory.
- SpecialPowers.swapFactoryRegistration(this._cid, this._contractID, this._mockFactory, this._originalFactory);
+ SpecialPowers.swapFactoryRegistration(null, this._contractID, this._originalFactory, this._mockFactory);
// Allow registering a mock factory again later.
- this._cid = null;
this._originalFactory = null;
this._mockFactory = null;
},
// --- Private methods and properties ---
/**
* The factory of the component being replaced.
*/
_originalFactory: null,
/**
- * The CID under which the mock contractID was registered.
- */
- _cid: null,
-
- /**
* The nsIFactory that was automatically generated by this object.
*/
_mockFactory: null
}
--- a/toolkit/components/satchel/test/subtst_form_submission_1.html
+++ b/toolkit/components/satchel/test/subtst_form_submission_1.html
@@ -13,18 +13,17 @@
<form id="subform2" onsubmit="return checkSubmit(100)">
<input id="subtest2" type="text" name="subtest2">
<button type="submit">Submit</button>
</form>
<script>
function checkSubmit(num) {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- return parent.checkSubmit(num);
+ return SpecialPowers.wrap(parent).wrappedJSObject.checkSubmit(num);
}
function clickButton(num) {
if (num == 21)
document.querySelectorAll("button")[0].click();
else if (num == 100)
document.querySelectorAll("button")[1].click();
}
--- a/toolkit/components/satchel/test/test_form_submission.html
+++ b/toolkit/components/satchel/test/test_form_submission.html
@@ -360,17 +360,16 @@ function startTest() {
// submit the first form.
var button = getFormSubmitButton(1);
button.click();
}
// Called by each form's onsubmit handler.
function checkSubmit(formNum) {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
ok(true, "form " + formNum + " submitted");
numSubmittedForms++;
// Check for expected storage state.
switch (formNum) {
// Test 1-24 should not save anything.
case 1:
@@ -496,17 +495,17 @@ function submitForm(formNum) {
setTimeout(function() {
checkObserver.waitForChecks(function() {
var nextFormNum = formNum == 24 ? 100 : (formNum + 1);
// Submit the next form. Special cases are Forms 21 and 100, which happen
// from an HTTPS domain in an iframe.
if (nextFormNum == 21 || nextFormNum == 100) {
ok(true, "submitting iframe test " + nextFormNum);
- document.getElementById("iframe").contentWindow.clickButton(nextFormNum);
+ SpecialPowers.wrap(document.getElementById("iframe").contentWindow).wrappedJSObject.clickButton(nextFormNum);
} else {
var button = getFormSubmitButton(nextFormNum);
button.click();
}
});
}, 0);
return false; // cancel current form submission
--- a/widget/tests/chrome.ini
+++ b/widget/tests/chrome.ini
@@ -11,16 +11,19 @@ support-files = window_bug429954.xul
[test_bug444800.xul]
subsuite = clipboard
[test_bug478536.xul]
skip-if = true # Bug 561929
support-files = window_bug478536.xul
[test_bug517396.xul]
[test_bug538242.xul]
support-files = window_bug538242.xul
+[test_bug565392.html]
+subsuite = clipboard
+skip-if = toolkit != "windows"
[test_bug593307.xul]
support-files = window_bug593307_offscreen.xul window_bug593307_centerscreen.xul
[test_bug1151186.html]
skip-if = os == 'linux' && debug #Bug 1176038
[test_keycodes.xul]
[test_wheeltransaction.xul]
support-files = window_wheeltransaction.xul
[test_imestate.html]
--- a/widget/tests/mochitest.ini
+++ b/widget/tests/mochitest.ini
@@ -1,12 +1,9 @@
[DEFAULT]
support-files = utils.js
[test_assign_event_data.html]
subsuite = clipboard
skip-if = toolkit == "cocoa" # Mac: Bug 933303
-[test_bug565392.html]
-subsuite = clipboard
-skip-if = toolkit != "windows" || e10s # Bug 1267406
[test_picker_no_crash.html]
skip-if = toolkit != "windows" || e10s # Bug 1267491
support-files = window_picker_no_crash_child.html
--- a/widget/tests/test_bug565392.html
+++ b/widget/tests/test_bug565392.html
@@ -1,30 +1,29 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=565392
-->
<head>
<title>Test for Bug 565392</title>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=565392">Mozilla Bug 565392</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 565392 **/
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
const Cc = SpecialPowers.Cc;
const Ci = SpecialPowers.Ci;
var ds = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties);
var dir1 = ds.get("ProfD", Ci.nsIFile);
var clipboard = Cc["@mozilla.org/widget/clipboard;1"]
.getService(Ci.nsIClipboard);