Bug 843711 - Fix up new |Components| culprits in test suite. r=mccr8

This commit is contained in:
Bobby Holley 2013-02-25 10:43:03 -08:00
parent 36a231a8ac
commit 440bea3fd7
27 changed files with 48 additions and 86 deletions

View File

@ -18,7 +18,7 @@
<script class="testbody" type="application/javascript;version=1.7">
SimpleTest.waitForExplicitFinish();
const Ci = Components.interfaces;
const Ci = SpecialPowers.Ci;
let wrapperClickCount = 0;
function test1() {

View File

@ -24,10 +24,8 @@ let am = {
authMgr: null,
init: function() {
const {classes: Cc, interfaces: Ci} = SpecialPowers.wrap(Components);
this.authMgr = Cc["@mozilla.org/network/http-auth-manager;1"]
.getService(Components.interfaces.nsIHttpAuthManager)
this.authMgr = SpecialPowers.Cc["@mozilla.org/network/http-auth-manager;1"]
.getService(SpecialPowers.Ci.nsIHttpAuthManager)
},
addIdentity: function() {

View File

@ -15,7 +15,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=425013
<script type="text/javascript;version=1.7">
var missingPlugins = new Array();
var OBJLC = Components.interfaces.nsIObjectLoadingContent;
var OBJLC = SpecialPowers.Ci.nsIObjectLoadingContent;
function pluginBinding(event)
{

View File

@ -15,7 +15,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=429157
<script>
var missingPlugins = new Array();
const OBJLC = Components.interfaces.nsIObjectLoadingContent;
const OBJLC = SpecialPowers.Ci.nsIObjectLoadingContent;
function pluginBindingAttached(event)
{

View File

@ -19,7 +19,7 @@ function test(tag, type) {
"use strict";
info("testing " + tag + " tag with type " + type);
const OBJLC = Components.interfaces.nsIObjectLoadingContent;
const OBJLC = SpecialPowers.Ci.nsIObjectLoadingContent;
let obj = document.createElement(tag);
obj.type = type;
document.body.appendChild(obj);

View File

@ -16,14 +16,12 @@
<pre id="test">
<script class="testbody" type="application/javascript;version=1.8">
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = SpecialPowers.wrap(Components);
const APP_URL = "http://example.org";
const APP_MANIFEST = "http://example.org/manifest.webapp";
const CHILD_PROCESS_SHUTDOWN_MESSAGE = "child-process-shutdown";
let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIMessageBroadcaster);
let ppmm = SpecialPowers.Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(SpecialPowers.Ci.nsIMessageBroadcaster);
/**
* Load the example.org site in an <iframe mozbrowser>

View File

@ -15,18 +15,16 @@
<pre id="test">
<script class="testbody" type="application/javascript;version=1.8">
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = SpecialPowers.wrap(Components);
const APP_URL = "http://example.org";
const APP_MANIFEST = "http://example.org/manifest.webapp";
const CHILD_PROCESS_SHUTDOWN_MESSAGE = "child-process-shutdown";
let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIMessageBroadcaster);
let cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(Ci.nsISyncMessageSender);
let gAppsService = Cc["@mozilla.org/AppsService;1"]
.getService(Ci.nsIAppsService);
let ppmm = SpecialPowers.Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(SpecialPowers.Ci.nsIMessageBroadcaster);
let cpmm = SpecialPowers.Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(SpecialPowers.Ci.nsISyncMessageSender);
let gAppsService = SpecialPowers.Cc["@mozilla.org/AppsService;1"]
.getService(SpecialPowers.Ci.nsIAppsService);
function setUp() {
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);

View File

@ -45,8 +45,8 @@ var OPTIONS = {
SimpleTest.waitForExplicitFinish();
function detectDriverType() {
const Cc = SpecialPowers.wrap(Components).classes;
const Ci = SpecialPowers.wrap(Components).interfaces;
const Cc = SpecialPowers.Cc;
const Ci = SpecialPowers.Ci;
var doc = Cc["@mozilla.org/xmlextras/domparser;1"].createInstance(Ci.nsIDOMParser).parseFromString("<html/>", "text/html");
var canvas = doc.createElement("canvas");
@ -105,15 +105,15 @@ function start() {
if (kIsWindows) {
// code borrowed from browser/modules/test/browser_taskbar_preview.js
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var version = Components.classes["@mozilla.org/system-info;1"]
.getService(Components.interfaces.nsIPropertyBag2)
var version = SpecialPowers.Cc["@mozilla.org/system-info;1"]
.getService(SpecialPowers.Ci.nsIPropertyBag2)
.getProperty("version");
kIsWindowsVistaOrHigher = (parseFloat(version) >= 6.0);
}
function getEnv(env) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var envsvc = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);
var envsvc = SpecialPowers.Cc["@mozilla.org/process/environment;1"].getService(SpecialPowers.Ci.nsIEnvironment);
var val = envsvc.get(env);
if (val == "")
return null;

View File

@ -78,7 +78,7 @@ addLoadEvent(function() {
is(d.testAncestor, "ancestor",
"test1" + ": Empty field should not override ancestor binding");
var win = XPCNativeWrapper.unwrap(window);
var win = window;
win.counter = 0;
d.testEvalOnce;
d.testEvalOnce;

View File

@ -8,7 +8,7 @@ SimpleTest.waitForExplicitFinish();
function makeAllAppsLaunchable() {
var Webapps = {};
SpecialPowers.wrap(Components).utils.import("resource://gre/modules/Webapps.jsm", Webapps);
SpecialPowers.Cu.import("resource://gre/modules/Webapps.jsm", Webapps);
var appRegistry = SpecialPowers.wrap(Webapps.DOMApplicationRegistry);
var originalValue = appRegistry.allAppsLaunchable;

View File

@ -11,8 +11,8 @@
<script type="text/javascript;version=1.7">
function createNonUnicodeData() {
const Cc = SpecialPowers.wrap(Components).classes;
const Ci = SpecialPowers.wrap(Components).interfaces;
const Cc = SpecialPowers.Cc;
const Ci = SpecialPowers.Ci;
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
var testFile = dirSvc.get("ProfD", Ci.nsIFile);

View File

@ -10,7 +10,7 @@ var archiveReaderEnabled = false;
// and content mochitests (where the |Components| object is accessible only as
// SpecialPowers.Components). Expose Components if necessary here to make things
// work everywhere.
if (typeof Components === 'undefined')
if (typeof Components === 'undefined' && typeof SpecialPowers === 'object')
Components = SpecialPowers.Components;
function executeSoon(aFun)

View File

@ -30,13 +30,12 @@ var testCertApp = {
};
SpecialPowers.addPermission("permissions", true, document);
var comp = SpecialPowers.wrap(Components);
SpecialPowers.pushPrefEnv({ "set": [["dom.mozPermissionSettings.enabled", true]] },
function() {
SpecialPowers.removePermission("permissions", document);
});
comp.utils.import("resource://gre/modules/PermissionSettings.jsm");
SpecialPowers.Cu.import("resource://gre/modules/PermissionSettings.jsm");
var mozPermissions = window.navigator.mozPermissionSettings;
function permissionTest() {

View File

@ -21,8 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id={678695}
"use strict";
var comp = SpecialPowers.wrap(Components);
comp.utils.import("resource://gre/modules/SettingsChangeNotifier.jsm");
SpecialPowers.Cu.import("resource://gre/modules/SettingsChangeNotifier.jsm");
SpecialPowers.setBoolPref("dom.mozSettings.enabled", true);
SpecialPowers.addPermission("settings-write", true, document);
SpecialPowers.addPermission("settings-read", true, document);

View File

@ -1,6 +1,6 @@
function makeAllAppsLaunchable() {
var Webapps = {};
SpecialPowers.wrap(Components).utils.import("resource://gre/modules/Webapps.jsm", Webapps);
SpecialPowers.Cu.import("resource://gre/modules/Webapps.jsm", Webapps);
var appRegistry = SpecialPowers.wrap(Webapps.DOMApplicationRegistry);
var originalValue = appRegistry.allAppsLaunchable;

View File

@ -6,8 +6,8 @@
<iframe src=discardframe.htm></iframe>
</div>
<script>
const Ci = Components.interfaces;
const Cc = SpecialPowers.wrap(Components).classes;
const Ci = SpecialPowers.Ci;
const Cc = SpecialPowers.Cc;
function ImageDecoderObserverStub()
{

View File

@ -43,7 +43,6 @@ MOCHITEST_FILES = chrome_wrappers_helper.html \
bug504877_helper.html \
test_bug505915.html \
file_bug505915.html \
test_bug553407.html \
test_bug560351.html \
bug571849_helper.html \
test_bug585745.html \

View File

@ -17,7 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478438
return;
test.calledAlready = true;
var iwin = (new XPCNativeWrapper(document)).getElementById("f").contentWindow;
var iwin = document.getElementById("f").contentWindow;
function testOne(fn, onAllow, infinitive) {
try { fn(); onAllow("able " + infinitive, "") }

View File

@ -1,31 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=517163
-->
<head>
<title>Test for Bug 553407</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=553407">Mozilla Bug 553407</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 553407 **/
is(typeof new XPCNativeWrapper(location), "object", "XPCNativeWrapper(location) is an object")
is(typeof new XPCNativeWrapper(XMLHttpRequest), "function", "XPCNativeWrapper(XMLHttpRequest) is a function")
// We no longer support .wrappedJSObject on NW since for same-origin there is no wrapper in between.
// is(typeof new XPCNativeWrapper(location).wrappedJSObject, "object", "XPCNativeWrapper(location).wrappedJSObject is an object")
// is(typeof new XPCNativeWrapper(XMLHttpRequest).wrappedJSObject, "function", "XPCNativeWrapper(XMLHttpRequest).wrappedJSObject is a function")
ok("a".replace("a", new XPCNativeWrapper(location)).indexOf("mochi.test") >= 0, "XPCNativeWrappers can be used as the replacement value for .replace");
</script>
</pre>
</body>
</html>

View File

@ -24,10 +24,10 @@ function test()
option.text="Fubar";
sel.options.add(option);
try {
Components.lookupMethod(sel.options, "add")(option);
SpecialPowers.Components.lookupMethod(sel.options, "add")(option);
ok(true, "function call should not throw")
} catch(e) {
do_throw("this call should just work without any exceptions");
ok(false, "this call should just work without any exceptions");
}
SimpleTest.finish();
}

View File

@ -23,7 +23,7 @@ function do_test() {
const INVALID_POINTER = 0x80004003;
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
.getService(Components.interfaces.inIDOMUtils);
.getService(SpecialPowers.Ci.inIDOMUtils);
try {
utils.getCSSStyleRules(null);
ok(false, "expected an exception");

View File

@ -13,7 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=806192
<script type="application/javascript">
const utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
.getService(Components.interfaces.inIDOMUtils);
.getService(SpecialPowers.Ci.inIDOMUtils);
try {
var res = utils.getBindingURLs({});

View File

@ -26,7 +26,7 @@ SimpleTest.waitForExplicitFinish();
function clearAuthCache()
{
var authMgr = SpecialPowers.Cc['@mozilla.org/network/http-auth-manager;1']
.getService(Components.interfaces.nsIHttpAuthManager);
.getService(SpecialPowers.Ci.nsIHttpAuthManager);
authMgr.clearAll();
}

View File

@ -28,7 +28,7 @@ SimpleTest.waitForExplicitFinish();
function clearAuthCache()
{
var authMgr = SpecialPowers.Cc['@mozilla.org/network/http-auth-manager;1']
.getService(Components.interfaces.nsIHttpAuthManager);
.getService(SpecialPowers.Ci.nsIHttpAuthManager);
authMgr.clearAll();
}

View File

@ -163,8 +163,8 @@ function checkTest() {
}
}
const Ci = Components.interfaces;
const Cc = SpecialPowers.wrap(Components).classes;
const Ci = SpecialPowers.Ci;
const Cc = SpecialPowers.Cc;
ok(Ci != null, "Access Ci");
ok(Cc != null, "Access Cc");
@ -174,7 +174,7 @@ ok(pwmgr != null, "Access pwmgr");
pwmgr.removeAllLogins();
var nsLoginInfo = new SpecialPowers.wrap(Components).
var nsLoginInfo = new SpecialPowers.wrap(SpecialPowers.Components).
Constructor("@mozilla.org/login-manager/loginInfo;1",
Ci.nsILoginInfo, "init");
var login1 = new nsLoginInfo("http://mochi.test:8888", "http://mochi.test:8888", null,

View File

@ -33,7 +33,7 @@
const interfaces = [Ci.nsIObserver, Ci.nsISupports];
if (!interfaces.some( function(v) { return iid.equals(v) } ))
throw SpecialPowers.Components.results.NS_ERROR_NO_INTERFACE;
throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE;
return this;
},
@ -125,7 +125,7 @@
const interfaces = [Ci.nsIProtocolProxyCallback, Ci.nsISupports];
if (!interfaces.some( function(v) { return iid.equals(v) } ))
throw Components.results.NS_ERROR_NO_INTERFACE;
throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE;
return this;
},
@ -137,12 +137,10 @@
function startup() {
//need to allow for arbitrary network servers defined in PAC instead of a hardcoded moz-proxy.
var ios = SpecialPowers.wrap(Components)
.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var ios = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
.getService(SpecialPowers.Ci.nsIIOService);
var pps = SpecialPowers.wrap(Components)
.classes["@mozilla.org/network/protocol-proxy-service;1"]
var pps = SpecialPowers.Cc["@mozilla.org/network/protocol-proxy-service;1"]
.getService();
var uri = ios.newURI("http://example.com", null, null);

View File

@ -19,6 +19,10 @@
}
function CcDenied() {
// Once Components goes away in content, the question of whether or not
// Components.classes throws is not well-formed.
if (typeof Components === 'undefined')
return true;
try {
Components.classes;
return false;