Bug 918604 - Remove more enablePrivilege calls. r=jmaher

This commit is contained in:
Martijn Wargers 2013-09-25 19:32:20 +02:00
parent 161f96daee
commit dfe0e2b248
24 changed files with 55 additions and 116 deletions

View File

@ -24,7 +24,6 @@ SimpleTest.waitForExplicitFinish();
function testViewport() {
/* We need to access the document headers, which are chrome-only. */
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
/* Grab Viewport Metadata from the document header. */
var windowUtils = SpecialPowers.getDOMWindowUtils(window);

View File

@ -78,11 +78,11 @@ var gVideo = null;
var gTestedRemoved = false;
function eventHandler(event) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
//dump((gTestNum - 1) + ": " + event.type + "\n");
var video = event.target;
opener.is(event.type, video.expectedResult, video.testDescription +
(gTestedRemoved ? " (element not in document)" : " (element in document)"));
opener.postMessage({"result": (event.type == video.expectedResult),
"message": video.testDescription + (gTestedRemoved ? " (element not in document)" : " (element in document)")},
"http://mochi.test:8888");
// Make sure any extra events cause an error
video.expectedResult = "<none>";
nextTest();
@ -97,10 +97,9 @@ function createVideo() {
}
function load() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
opener.is(window.location.href,
"http://example.org/tests/content/media/test/file_access_controls.html",
"We must be on a example.org:80");
opener.postMessage({"result": (window.location.href == "http://example.org/tests/content/media/test/file_access_controls.html"),
"message": "We must be on a example.org:80"},
"http://mochi.test:8888");
nextTest();
}
@ -125,7 +124,7 @@ function nextTest() {
gVideo.parentNode.removeChild(gVideo);
gVideo = null;
opener.SpecialPowers.forceGC();
SpecialPowers.forceGC();
gVideo = createVideo();
gVideo.expectedResult = gTests[gTestNum].result;
@ -148,7 +147,7 @@ function nextTest() {
}
function done() {
opener.done();
opener.postMessage({"done": "true"}, "http://mochi.test:8888");
}
</script>

View File

@ -30,7 +30,22 @@ function done() {
addLoadEvent(run);
SimpleTest.waitForExplicitFinish();
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event)
{
if (event.origin !== "http://example.org") {
ok(false, "Received message from wrong domain");
return;
}
if (event.data.done == "true")
return done();
ok(event.data.result, event.data.message);
}
</script>
</pre>
</body>

View File

@ -34,7 +34,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479711
v._name + ":" + v.id + " is not ready before onload fired (" + v.readyState + ")");
}
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
for (i=0; i<testWindows.length; ++i) {
testWindows[i].close();
}
@ -94,9 +93,6 @@ document.body.appendChild(v);
v = createVideo(test.name, test.type, "3");
v.load();
// Load and move to another document.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// Open a new window for the following test. We open it here instead of in
// the event handler to ensure that our document load event doesn't fire while
// window.open is spinning the event loop.

View File

@ -27,9 +27,7 @@ setTimeout(function() { longTimerFired = true; }, 3600000);
// Trigger suspend and resume timeouts
(function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
var utils = SpecialPowers.getDOMWindowUtils(window);
utils.suspendTimeouts();
utils.resumeTimeouts();
})()

View File

@ -6,13 +6,9 @@
<script class="testbody" type="text/javascript">
function runSubTest()
{
// get ability to set innerWidth and height without setting a pref
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// Firefox doesn't support the metaviewport tag on desktop, so we force
// css viewport here using nsIDomWindowUtils
var cwu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);
var cwu = SpecialPowers.getDOMWindowUtils(window);
cwu.setCSSViewport(320, 320);
var oldWidth = window.innerWidth;

View File

@ -9,7 +9,7 @@
so instead We load it in a separate window.
-->
</head>
<body onload="runTest()">
<body onload="startTest()">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
var newWin = null;
@ -21,6 +21,10 @@
newWin.close();
SimpleTest.finish();
}
function startTest() {
SpecialPowers.pushPrefEnv({"set": [["dom.disable_window_move_resize", false]]}, runTest);
}
</script>
</body>
</html>

View File

@ -19,9 +19,6 @@
<pre id="test">
<script class="testbody" type="text/javascript;version=1.7">
// Enable full privledges for clipboard read/write operations.
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var content = document.getElementById("content");
var contentInput = document.getElementById("content-input");
var clipboardInitialValue = "empty";
@ -31,6 +28,7 @@ var clipboardInitialValue = "empty";
// test run don't cause a false-positive test.
var cb_text = "empty_" + Math.random();
setClipboardText(cb_text);
is(getClipboardText(), cb_text, "set/get clipboard text failed");
// Some test functions need to be run with delays.
@ -97,49 +95,13 @@ SimpleTest.waitForExplicitFinish();
window.focus();
function getLoadContext() {
return window.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
return SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
.getInterface(SpecialPowers.Ci.nsIWebNavigation)
.QueryInterface(SpecialPowers.Ci.nsILoadContext);
}
function getClipboardText() {
var trans = SpecialPowers.Cc["@mozilla.org/widget/transferable;1"]
.createInstance();
trans = trans.QueryInterface(SpecialPowers.Ci.nsITransferable);
trans.init(getLoadContext());
trans.addDataFlavor("text/unicode");
var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"]
.getService();
clipboard = clipboard.QueryInterface(SpecialPowers.Ci.nsIClipboard);
clipboard.getData(trans, clipboard.kGlobalClipboard);
var str = new Object();
var strLen = new Object();
try {
trans.getTransferData("text/unicode", str, strLen);
} catch(e) {
// NS_ERROR_FAILURE will occur if the transferable object has no
// text/unicode data in it. In that case, it's not an error:
if (e instanceof SpecialPowers.Ci.nsIXPCException &&
e.result == SpecialPowers.Cr.NS_ERROR_FAILURE) {
return null;
} else {
// if we don't know how to handle it then rethrow
throw e;
}
}
if (!str) return null;
str = str.value.QueryInterface(SpecialPowers.Ci.nsISupportsString);
if (!str) return null;
str = str.data.substring(0, strLen.value / 2);
if (!str) return null;
return str;
return SpecialPowers.getClipboardData("text/unicode");
}

View File

@ -1,7 +1,6 @@
function postMsg(message)
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var l = parent.window.location;
var l = SpecialPowers.wrap(parent.window.location);
parent.postMessage(message, l.protocol + "//" + l.host);
}

View File

@ -15,7 +15,6 @@ window.addEventListener("message", onMessageReceived, false);
function onMessageReceived(event)
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
switch (event.data)
{
@ -32,8 +31,8 @@ function onMessageReceived(event)
masterFrame.postMessage("step", masterFrameOrigin);
else if (slaveFrame)
slaveFrame.postMessage("step", slaveFrameOrigin);
else if (masterFrame.slaveFrame)
masterFrame.slaveFrame.postMessage("step", slaveFrameOrigin);
else if (SpecialPowers.wrap(masterFrame).slaveFrame)
SpecialPowers.wrap(masterFrame).slaveFrame.postMessage("step", slaveFrameOrigin);
callMasterFrame = !callMasterFrame;
break;

View File

@ -22,8 +22,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=384147
SimpleTest.waitForExplicitFinish();
// netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var editor = document.getElementById("editor");
editor.innerHTML = "<ol><li>Item 1</li><li>Item 2</li><ol><li>Item 3</li></ol></ol><ul><li>Item 4</li><li>Item 5</li></ul>";

View File

@ -20,7 +20,6 @@ SimpleTest.waitForFocus(runTests);
function runTests()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var container = document.getElementById("display");

View File

@ -1,13 +1,12 @@
<!DOCTYPE HTML>
<html><head>
<title>Test for bug 455992</title>
<style src="/tests/SimpleTest/test.css" type="text/css"></style>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script class="testbody" type="application/javascript">
function runTest() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
function select(id) {
var e = document.getElementById(id);

View File

@ -1,13 +1,12 @@
<!DOCTYPE HTML>
<html><head>
<title>Test for bug 456244</title>
<style src="/tests/SimpleTest/test.css" type="text/css"></style>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script class="testbody" type="application/javascript">
function runTest() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
function select(id) {
var e = document.getElementById(id);

View File

@ -26,9 +26,9 @@ addLoadEvent(runTest);
var gMisspeltWords;
function getEditor() {
var Ci = Components.interfaces;
var Ci = SpecialPowers.Ci;
var win = window;
var editingSession = win.QueryInterface(Ci.nsIInterfaceRequestor)
var editingSession = SpecialPowers.wrap(win).QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIEditingSession);
@ -42,7 +42,6 @@ function getSpellCheckSelection() {
}
function append(str) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var edit = document.getElementById("edit");
var editor = getEditor();
@ -76,7 +75,6 @@ function runTest() {
}
function isSpellingCheckOk() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var sel = getSpellCheckSelection();
var numWords = sel.rangeCount;

View File

@ -1,13 +1,12 @@
<!DOCTYPE HTML>
<html><head>
<title>Test for bug 487524</title>
<style src="/tests/SimpleTest/test.css" type="text/css"></style>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script class="testbody" type="application/javascript">
function runTest() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
function setupIframe(e,html,focus_id) {
var doc = e.contentDocument;

View File

@ -28,8 +28,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=489202
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils);
var utils = SpecialPowers.getDOMWindowUtils(window);
var Cc = Components.classes;
var Ci = Components.interfaces;
@ -40,8 +39,6 @@ function getLoadContext() {
}
function runTest() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var trans = Cc["@mozilla.org/widget/transferable;1"]
.createInstance(Ci.nsITransferable);
trans.init(getLoadContext());

View File

@ -12,19 +12,10 @@
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var viewer =
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell)
.contentViewer
.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
viewer.fullZoom = 2;
SpecialPowers.setFullZoom(window, 2);
var p = window;
var w = window.open("about:blank", "", "width=200,height=100");
@ -34,8 +25,7 @@ SimpleTest.waitForFocus(function() {
ok(w.innerHeight <= 202 && w.innerHeight >= 198,
"height (" + w.innerHeight + ") should be around twice what was requested (100)");
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
viewer.fullZoom = 1;
SpecialPowers.setFullZoom(window, 1);
w.close();
SimpleTest.finish();
}, w, true);

View File

@ -21,8 +21,6 @@ SimpleTest.waitForExplicitFinish();
function checkFirst()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var iframeelem = document.getElementById('test-iframe');
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');

View File

@ -21,18 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=614392
SimpleTest.waitForExplicitFinish();
window.onload = function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var img = SpecialPowers.wrap(document.getElementsByTagName("img")[0]);
var container = img
.QueryInterface(Components.interfaces.nsIImageLoadingContent)
.getRequest(Components.interfaces.nsIImageLoadingContent.CURRENT_REQUEST)
.QueryInterface(SpecialPowers.Ci.nsIImageLoadingContent)
.getRequest(SpecialPowers.Ci.nsIImageLoadingContent.CURRENT_REQUEST)
.image;
container.animationMode =
Components.interfaces.imgIContainer.kDontAnimMode;
SpecialPowers.Ci.imgIContainer.kDontAnimMode;
is(container.animationMode,
Components.interfaces.imgIContainer.kDontAnimMode,
SpecialPowers.Ci.imgIContainer.kDontAnimMode,
"yay, our animationMode tweak took effect (and we didn't crash!)");
SimpleTest.finish();

View File

@ -22,7 +22,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=878037
SimpleTest.waitForExplicitFinish();
window.onload = function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var img = document.getElementById("animated");
var content = img.QueryInterface(Components.interfaces.nsIImageLoadingContent);

View File

@ -22,13 +22,12 @@ badCertListener.prototype = {
},
QueryInterface: function(aIID) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
if (aIID.equals(Components.interfaces.nsIBadCertListener2) ||
aIID.equals(Components.interfaces.nsIInterfaceRequestor) ||
aIID.equals(Components.interfaces.nsISupports))
if (aIID.equals(SpecialPowers.Ci.nsIBadCertListener2) ||
aIID.equals(SpecialPowers.Ci.nsIInterfaceRequestor) ||
aIID.equals(SpecialPowers.Ci.nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE;
},
notifyCertProblem: function(socketInfo, sslStatus, targetHost) {

View File

@ -18,9 +18,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=362788
<![CDATA[
/** Test for Bug 362788 **/
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cc = SpecialPowers.Cc;
var Ci = SpecialPowers.Ci;
var lib = Cc["@mozilla.org/url-classifier/jslib;1"]
.getService().wrappedJSObject;
ok(!!lib, "unable to get wrapped js object");

View File

@ -160,7 +160,6 @@ function starttest() {
var querySelectedText = synthesizeQuerySelectedText();
ok(querySelectedText, "query selected text event result is null");
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); //get permission to check members of querySelectedText
ok(querySelectedText.succeeded, "query selected text event failed");
is(querySelectedText.offset, 1,
"query selected text event returns wrong offset");