Bug 1433175 - remove by hands some variations of Cc,Ci,Cu definitions, r=Standard8.

This commit is contained in:
Florian Quèze 2018-02-28 18:51:34 +01:00
parent 6df7549a3e
commit c546946f86
17 changed files with 128 additions and 172 deletions

View File

@ -1,8 +1,3 @@
if (typeof Cc === "undefined")
Cc = Components.classes;
if (typeof Ci === "undefined")
Ci = Components.interfaces;
function destroy_transient_docshell() {
var docshell = Cc["@mozilla.org/docshell;1"].createInstance(Ci.nsIDocShell);
docshell.setOriginAttributes({privateBrowsingId : 1});

View File

@ -4,8 +4,6 @@
Cu.importGlobalProperties(["NodeFilter"]);
const C_i = Components.interfaces;
const UNORDERED_TYPE = 8; // XPathResult.ANY_UNORDERED_NODE_TYPE
/**
@ -58,7 +56,7 @@ function dumpFragment(aFragment) {
* @return nsIDOMNode The target node retrieved from the XPath.
*/
function evalXPathInDocumentFragment(aContextNode, aPath) {
Assert.ok(aContextNode instanceof C_i.nsIDOMDocumentFragment);
Assert.ok(aContextNode instanceof Ci.nsIDOMDocumentFragment);
Assert.ok(aContextNode.childNodes.length > 0);
if (aPath == ".") {
return aContextNode;
@ -150,8 +148,8 @@ function evalXPathInDocumentFragment(aContextNode, aPath) {
* @return Range object.
*/
function getRange(aSourceNode, aFragment) {
Assert.ok(aSourceNode instanceof C_i.nsIDOMElement);
Assert.ok(aFragment instanceof C_i.nsIDOMDocumentFragment);
Assert.ok(aSourceNode instanceof Ci.nsIDOMElement);
Assert.ok(aFragment instanceof Ci.nsIDOMDocumentFragment);
var doc = aSourceNode.ownerDocument;
var containerPath = aSourceNode.getAttribute("startContainer");
@ -179,7 +177,7 @@ function getParsedDocument(aPath) {
function processParsedDocument(doc) {
Assert.ok(doc.documentElement.localName != "parsererror");
Assert.ok(doc instanceof C_i.nsIDOMDocument);
Assert.ok(doc instanceof Ci.nsIDOMDocument);
// Clean out whitespace.
var walker = doc.createTreeWalker(doc,
@ -362,7 +360,7 @@ function do_miscellaneous_tests(doc) {
// Text range manipulation.
if ((endOffset > startOffset) &&
(startContainer == endContainer) &&
(startContainer instanceof C_i.nsIDOMText)) {
(startContainer instanceof Ci.nsIDOMText)) {
// Invalid start node
try {
baseRange.setStart(null, 0);
@ -388,7 +386,7 @@ function do_miscellaneous_tests(doc) {
}
// Invalid index
var newOffset = startContainer instanceof C_i.nsIDOMText ?
var newOffset = startContainer instanceof Ci.nsIDOMText ?
startContainer.nodeValue.length + 1 :
startContainer.childNodes.length + 1;
try {
@ -444,14 +442,14 @@ function do_miscellaneous_tests(doc) {
// Requested by smaug: A range involving a comment as a document child.
doc = parser.parseFromString("<!-- foo --><foo/>", "application/xml");
Assert.ok(doc instanceof C_i.nsIDOMDocument);
Assert.ok(doc instanceof Ci.nsIDOMDocument);
Assert.equal(doc.childNodes.length, 2);
baseRange = doc.createRange();
baseRange.setStart(doc.firstChild, 1);
baseRange.setEnd(doc.firstChild, 2);
var frag = baseRange.extractContents();
Assert.equal(frag.childNodes.length, 1);
Assert.ok(frag.firstChild instanceof C_i.nsIDOMComment);
Assert.ok(frag.firstChild instanceof Ci.nsIDOMComment);
Assert.equal(frag.firstChild.nodeValue, "f");
/* smaug also requested attribute tests. Sadly, those are not yet supported

View File

@ -19,11 +19,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=817284
<![CDATA[
/** Test for Bug 817284 **/
var cu = Components.utils;
var sb = cu.Sandbox("http://example.com", { wantGlobalProperties: ["XMLHttpRequest"] });
var sb = Cu.Sandbox("http://example.com", { wantGlobalProperties: ["XMLHttpRequest"] });
// Test event handler calls
var xhr = cu.evalInSandbox(
var xhr = Cu.evalInSandbox(
'var xhr = new XMLHttpRequest();\
var called = false;\
xhr.onload = function() { called = true; };\
@ -32,7 +31,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=817284
var e = document.createEvent("Events");
e.initEvent("load", false, false);
xhr.dispatchEvent(e);
is(cu.evalInSandbox('called', sb), true, "Event handler should have been called");
is(Cu.evalInSandbox('called', sb), true, "Event handler should have been called");
]]>
</script>
</window>

View File

@ -50,8 +50,7 @@ function doTests()
var f = document.getElementById("f");
var fBounds = f.getBoundingClientRect();
const CI = Components.interfaces;
var fshell = f.contentWindow.QueryInterface(CI.nsIInterfaceRequestor).getInterface(CI.nsIWebNavigation).QueryInterface(CI.nsIDocShell);
var fshell = f.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell);
var fmudv = fshell.contentViewer;
isRounded(f.contentWindow.mozInnerScreenX,

View File

@ -1,6 +1,4 @@
var Ci = Components.interfaces,
Cc = Components.classes,
CC = Components.Constructor;
var CC = Components.Constructor;
var converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter);
converter.charset = "UTF-8";

View File

@ -1,35 +1,34 @@
function run_test() {
var cu = Components.utils;
var sbMaster = cu.Sandbox(["http://www.a.com",
var sbMaster = Cu.Sandbox(["http://www.a.com",
"http://www.b.com",
"http://www.d.com"]);
var sbSubset = cu.Sandbox(["http://www.d.com",
var sbSubset = Cu.Sandbox(["http://www.d.com",
"http://www.a.com"]);
var sbA = cu.Sandbox("http://www.a.com");
var sbB = cu.Sandbox("http://www.b.com");
var sbC = cu.Sandbox("http://www.c.com");
var sbA = Cu.Sandbox("http://www.a.com");
var sbB = Cu.Sandbox("http://www.b.com");
var sbC = Cu.Sandbox("http://www.c.com");
sbMaster.objA = cu.evalInSandbox("var obj = {prop1:200}; obj", sbA);
sbMaster.objB = cu.evalInSandbox("var obj = {prop1:200}; obj", sbB);
sbMaster.objC = cu.evalInSandbox("var obj = {prop1:200}; obj", sbC);
sbMaster.objOwn = cu.evalInSandbox("var obj = {prop1:200}; obj", sbMaster);
sbMaster.objA = Cu.evalInSandbox("var obj = {prop1:200}; obj", sbA);
sbMaster.objB = Cu.evalInSandbox("var obj = {prop1:200}; obj", sbB);
sbMaster.objC = Cu.evalInSandbox("var obj = {prop1:200}; obj", sbC);
sbMaster.objOwn = Cu.evalInSandbox("var obj = {prop1:200}; obj", sbMaster);
sbMaster.objSubset = cu.evalInSandbox("var obj = {prop1:200}; obj", sbSubset);
sbA.objMaster = cu.evalInSandbox("var obj = {prop1:200}; obj", sbMaster);
sbSubset.objMaster = cu.evalInSandbox("var obj = {prop1:200}; obj", sbMaster);
sbMaster.objSubset = Cu.evalInSandbox("var obj = {prop1:200}; obj", sbSubset);
sbA.objMaster = Cu.evalInSandbox("var obj = {prop1:200}; obj", sbMaster);
sbSubset.objMaster = Cu.evalInSandbox("var obj = {prop1:200}; obj", sbMaster);
var ret;
ret = cu.evalInSandbox("objA.prop1", sbMaster);
ret = Cu.evalInSandbox("objA.prop1", sbMaster);
Assert.equal(ret, 200);
ret = cu.evalInSandbox("objB.prop1", sbMaster);
ret = Cu.evalInSandbox("objB.prop1", sbMaster);
Assert.equal(ret, 200);
ret = cu.evalInSandbox("objSubset.prop1", sbMaster);
ret = Cu.evalInSandbox("objSubset.prop1", sbMaster);
Assert.equal(ret, 200);
function evalAndCatch(str, sb) {
try {
ret = cu.evalInSandbox(str, sb);
ret = Cu.evalInSandbox(str, sb);
Assert.ok(false, "unexpected pass")
} catch (e) {
Assert.ok(e.message && e.message.includes("Permission denied to access property"));
@ -41,7 +40,7 @@ function run_test() {
evalAndCatch("objMaster.prop1", sbSubset);
// Bug 777705:
sbMaster.Components = cu.getComponentsForScope(sbMaster);
sbMaster.Components = Cu.getComponentsForScope(sbMaster);
Cu.evalInSandbox("Components.interfaces", sbMaster);
Assert.ok(true);
}

View File

@ -1,6 +1,4 @@
var cu = Components.utils;
cu.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var httpserver = new HttpServer();
var httpserver2 = new HttpServer();
@ -10,7 +8,7 @@ var redirectpath = "/redirect";
var negativetestpath = "/negative";
var httpbody = "<?xml version='1.0' ?><root>0123456789</root>";
var sb = cu.Sandbox(["http://www.example.com",
var sb = Cu.Sandbox(["http://www.example.com",
"http://localhost:4444/redirect",
"http://localhost:4444/simple",
"http://localhost:4446/redirect"],
@ -58,8 +56,8 @@ function run_test()
httpserver3.start(4446);
// Test sync XHR sending
cu.evalInSandbox('var createXHR = ' + createXHR.toString(), sb);
var res = cu.evalInSandbox('var sync = createXHR("4444/simple"); sync.send(null); sync', sb);
Cu.evalInSandbox('var createXHR = ' + createXHR.toString(), sb);
var res = Cu.evalInSandbox('var sync = createXHR("4444/simple"); sync.send(null); sync', sb);
Assert.ok(checkResults(res));
var principal = res.responseXML.nodePrincipal;
@ -69,8 +67,8 @@ function run_test()
// negative test sync XHR sending (to ensure that the xhr do not have chrome caps, see bug 779821)
try {
cu.evalInSandbox('var createXHR = ' + createXHR.toString(), sb);
var res = cu.evalInSandbox('var sync = createXHR("4445/negative"); sync.send(null); sync', sb);
Cu.evalInSandbox('var createXHR = ' + createXHR.toString(), sb);
var res = Cu.evalInSandbox('var sync = createXHR("4445/negative"); sync.send(null); sync', sb);
Assert.equal(false, true, "XHR created from sandbox should not have chrome caps");
} catch (e) {
Assert.ok(true);
@ -80,8 +78,8 @@ function run_test()
// This request bounces to server 2 and then back to server 1. Neither of
// these servers support CORS, but if the expanded principal is used as the
// triggering principal, this should work.
cu.evalInSandbox('var createXHR = ' + createXHR.toString(), sb);
var res = cu.evalInSandbox('var sync = createXHR("4444/redirect"); sync.send(null); sync', sb);
Cu.evalInSandbox('var createXHR = ' + createXHR.toString(), sb);
var res = Cu.evalInSandbox('var sync = createXHR("4444/redirect"); sync.send(null); sync', sb);
Assert.ok(checkResults(res));
var principal = res.responseXML.nodePrincipal;
@ -101,7 +99,7 @@ function run_test()
// make sure that there are no permission errors related to nsEP. For that
// we need to clone the function into the sandbox and make a few things
// available for it.
cu.evalInSandbox('var checkResults = ' + checkResults.toSource(), sb);
Cu.evalInSandbox('var checkResults = ' + checkResults.toSource(), sb);
sb.equal = equal;
sb.httpbody = httpbody;
@ -110,7 +108,7 @@ function run_test()
finish();
}
var async = cu.evalInSandbox('var async = createXHR("4444/simple", true);' +
var async = Cu.evalInSandbox('var async = createXHR("4444/simple", true);' +
'async.addEventListener("readystatechange", ' +
changeListener.toString() + ', false);' +
'async', sb);

View File

@ -1,8 +1,6 @@
function run_test() {
var cu = Components.utils;
var sb = cu.Sandbox(this,
{wantComponents: false});
var sb = Cu.Sandbox(this, {wantComponents: false});
var rv = cu.evalInSandbox("this.Components", sb);
var rv = Cu.evalInSandbox("this.Components", sb);
Assert.equal(rv, undefined);
}

View File

@ -18,9 +18,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467669
SimpleTest.waitForExplicitFinish();
function RunTest() {
const CI = Components.interfaces;
const CC = Components.classes;
const kIsLinux = navigator.platform.indexOf("Linux") == 0;
const kIsMac = navigator.platform.indexOf("Mac") == 0;
const kIsWin = navigator.platform.indexOf("Win") == 0;

View File

@ -16,9 +16,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=695639
SimpleTest.waitForExplicitFinish();
function RunTest() {
const CI = Components.interfaces;
const CC = Components.classes;
var rng = document.createRange();
var elem, fonts, f;

View File

@ -4,9 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var CC = Components.classes;
const CI = Components.interfaces;
const NS_GFXINFO_CONTRACTID = "@mozilla.org/gfx/info;1";
var gContainingWindow = null;
@ -30,7 +27,7 @@ this.OnRecordingLoad = function OnRecordingLoad(win) {
gBrowser = gContainingWindow.document.getElementById("browser");
var gfxInfo = (NS_GFXINFO_CONTRACTID in CC) && CC[NS_GFXINFO_CONTRACTID].getService(CI.nsIGfxInfo);
var gfxInfo = (NS_GFXINFO_CONTRACTID in Cc) && Cc[NS_GFXINFO_CONTRACTID].getService(Ci.nsIGfxInfo);
var info = gfxInfo.getInfo();
dump(info.AzureContentBackend + "\n");
if (info.AzureContentBackend == "none") {

View File

@ -7,14 +7,10 @@
var EXPORTED_SYMBOLS = ["ReadTopManifest", "CreateUrls"];
var CC = Components.classes;
const CI = Components.interfaces;
const CU = Components.utils;
CU.import("chrome://reftest/content/globals.jsm", this);
CU.import("chrome://reftest/content/reftest.jsm", this);
CU.import("resource://gre/modules/Services.jsm");
CU.import("resource://gre/modules/NetUtil.jsm");
Cu.import("chrome://reftest/content/globals.jsm", this);
Cu.import("chrome://reftest/content/reftest.jsm", this);
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
const NS_SCRIPTSECURITYMANAGER_CONTRACTID = "@mozilla.org/scriptsecuritymanager;1";
const NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX = "@mozilla.org/network/protocol;1?name=";
@ -49,8 +45,8 @@ function ReadManifest(aURL, aFilter)
}
g.manifestsLoaded[aURL.spec] = aFilter[1];
var secMan = CC[NS_SCRIPTSECURITYMANAGER_CONTRACTID]
.getService(CI.nsIScriptSecurityManager);
var secMan = Cc[NS_SCRIPTSECURITYMANAGER_CONTRACTID]
.getService(Ci.nsIScriptSecurityManager);
var listURL = aURL;
var channel = NetUtil.newChannel({uri: aURL, loadUsingSystemPrincipal: true});
@ -293,7 +289,7 @@ function ReadManifest(aURL, aFilter)
var incURI = g.ioService.newURI(items[1], null, listURL);
secMan.checkLoadURIWithPrincipal(principal, incURI,
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
ReadManifest(incURI, aFilter);
}
} else if (items[0] == TYPE_LOAD || items[0] == TYPE_SCRIPT) {
@ -380,8 +376,8 @@ function ReadManifest(aURL, aFilter)
function getStreamContent(inputStream)
{
var streamBuf = "";
var sis = CC["@mozilla.org/scriptableinputstream;1"].
createInstance(CI.nsIScriptableInputStream);
var sis = Cc["@mozilla.org/scriptableinputstream;1"].
createInstance(Ci.nsIScriptableInputStream);
sis.init(inputStream);
var available;
@ -395,15 +391,15 @@ function getStreamContent(inputStream)
// Build the sandbox for fails-if(), etc., condition evaluation.
function BuildConditionSandbox(aURL) {
var sandbox = new Cu.Sandbox(aURL.spec);
var xr = CC[NS_XREAPPINFO_CONTRACTID].getService(CI.nsIXULRuntime);
var appInfo = CC[NS_XREAPPINFO_CONTRACTID].getService(CI.nsIXULAppInfo);
var xr = Cc[NS_XREAPPINFO_CONTRACTID].getService(Ci.nsIXULRuntime);
var appInfo = Cc[NS_XREAPPINFO_CONTRACTID].getService(Ci.nsIXULAppInfo);
sandbox.isDebugBuild = g.debug.isDebugBuild;
var prefs = CC["@mozilla.org/preferences-service;1"].
getService(CI.nsIPrefBranch);
var env = CC["@mozilla.org/process/environment;1"].
getService(CI.nsIEnvironment);
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
var env = Cc["@mozilla.org/process/environment;1"].
getService(Ci.nsIEnvironment);
sandbox.xulRuntime = CU.cloneInto({widgetToolkit: xr.widgetToolkit, OS: xr.OS, XPCOMABI: xr.XPCOMABI}, sandbox);
sandbox.xulRuntime = Cu.cloneInto({widgetToolkit: xr.widgetToolkit, OS: xr.OS, XPCOMABI: xr.XPCOMABI}, sandbox);
var testRect = g.browser.getBoundingClientRect();
sandbox.smallScreen = false;
@ -411,7 +407,7 @@ function BuildConditionSandbox(aURL) {
sandbox.smallScreen = true;
}
var gfxInfo = (NS_GFXINFO_CONTRACTID in CC) && CC[NS_GFXINFO_CONTRACTID].getService(CI.nsIGfxInfo);
var gfxInfo = (NS_GFXINFO_CONTRACTID in Cc) && Cc[NS_GFXINFO_CONTRACTID].getService(Ci.nsIGfxInfo);
let readGfxInfo = function (obj, key) {
if (g.contentGfxInfo && (key in g.contentGfxInfo)) {
return g.contentGfxInfo[key];
@ -471,7 +467,7 @@ function BuildConditionSandbox(aURL) {
sandbox.transparentScrollbars = xr.widgetToolkit == "gtk3";
if (sandbox.Android) {
var sysInfo = CC["@mozilla.org/system-info;1"].getService(CI.nsIPropertyBag2);
var sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
// This is currently used to distinguish Android 4.0.3 (SDK version 15)
// and later from Android 2.x
@ -520,8 +516,8 @@ sandbox.compareRetainedDisplayLists = g.compareRetainedDisplayLists;
sandbox.release_or_beta = false;
#endif
var hh = CC[NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX + "http"].
getService(CI.nsIHttpProtocolHandler);
var hh = Cc[NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX + "http"].
getService(Ci.nsIHttpProtocolHandler);
var httpProps = ["userAgent", "appName", "appVersion", "vendor",
"vendorSub", "product", "productSub", "platform",
"oscpu", "language", "misc"];
@ -549,7 +545,7 @@ sandbox.compareRetainedDisplayLists = g.compareRetainedDisplayLists;
}
sandbox.gpuProcessForceEnabled = prefs.getBoolPref("layers.gpu-process.force-enabled", false);
sandbox.prefs = CU.cloneInto({
sandbox.prefs = Cu.cloneInto({
getBoolPref: function(p) { return prefs.getBoolPref(p); },
getIntPref: function(p) { return prefs.getIntPref(p); }
}, sandbox, { cloneFunctions: true });
@ -569,7 +565,7 @@ sandbox.compareRetainedDisplayLists = g.compareRetainedDisplayLists;
if (!g.dumpedConditionSandbox) {
g.logger.info("Dumping JSON representation of sandbox");
g.logger.info(JSON.stringify(CU.waiveXrays(sandbox)));
g.logger.info(JSON.stringify(Cu.waiveXrays(sandbox)));
g.dumpedConditionSandbox = true;
}
@ -640,7 +636,7 @@ function ExtractRange(matches, startIndex, defaultMin = 0) {
}
function ServeTestBase(aURL, depth) {
var listURL = aURL.QueryInterface(CI.nsIFileURL);
var listURL = aURL.QueryInterface(Ci.nsIFileURL);
var directory = listURL.file.parent;
// Allow serving a tree that's an ancestor of the directory containing
@ -656,8 +652,8 @@ function ServeTestBase(aURL, depth) {
var path = "/" + Date.now() + "/" + g.count;
g.server.registerDirectory(path + "/", directory);
var secMan = CC[NS_SCRIPTSECURITYMANAGER_CONTRACTID]
.getService(CI.nsIScriptSecurityManager);
var secMan = Cc[NS_SCRIPTSECURITYMANAGER_CONTRACTID]
.getService(Ci.nsIScriptSecurityManager);
var testbase = g.ioService.newURI("http://localhost:" + g.httpServerPort +
path + dirPath);
@ -668,8 +664,8 @@ function ServeTestBase(aURL, depth) {
}
function CreateUrls(test) {
let secMan = CC[NS_SCRIPTSECURITYMANAGER_CONTRACTID]
.getService(CI.nsIScriptSecurityManager);
let secMan = Cc[NS_SCRIPTSECURITYMANAGER_CONTRACTID]
.getService(Ci.nsIScriptSecurityManager);
let manifestURL = g.ioService.newURI(test.manifest);
let principal = secMan.createCodebasePrincipal(manifestURL, {});
@ -685,7 +681,7 @@ function CreateUrls(test) {
var testURI = g.ioService.newURI(file, null, testbase);
secMan.checkLoadURIWithPrincipal(principal, testURI,
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
return testURI;
}

View File

@ -4,11 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var CC = Components.classes;
const CI = Components.interfaces;
const CR = Components.results;
const CU = Components.utils;
const XHTML_NS = "http://www.w3.org/1999/xhtml";
const DEBUG_CONTRACTID = "@mozilla.org/xpcom/debug;1";
@ -21,9 +16,9 @@ const IO_SERVICE_CONTRACTID = "@mozilla.org/network/io-service;1"
// "<!--CLEAR-->"
const BLANK_URL_FOR_CLEARING = "data:text/html;charset=UTF-8,%3C%21%2D%2DCLEAR%2D%2D%3E";
CU.import("resource://gre/modules/Timer.jsm");
CU.import("chrome://reftest/content/AsyncSpellCheckTestHelper.jsm");
CU.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Timer.jsm");
Cu.import("chrome://reftest/content/AsyncSpellCheckTestHelper.jsm");
Cu.import("resource://gre/modules/Services.jsm");
var gBrowserIsRemote;
var gIsWebRenderEnabled;
@ -66,12 +61,12 @@ function markupDocumentViewer() {
}
function webNavigation() {
return docShell.QueryInterface(CI.nsIWebNavigation);
return docShell.QueryInterface(Ci.nsIWebNavigation);
}
function windowUtilsForWindow(w) {
return w.QueryInterface(CI.nsIInterfaceRequestor)
.getInterface(CI.nsIDOMWindowUtils);
return w.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
}
function windowUtils() {
@ -111,8 +106,8 @@ function OnInitialLoad()
{
removeEventListener("load", OnInitialLoad, true);
gDebug = CC[DEBUG_CONTRACTID].getService(CI.nsIDebug2);
var env = CC[ENVIRONMENT_CONTRACTID].getService(CI.nsIEnvironment);
gDebug = Cc[DEBUG_CONTRACTID].getService(Ci.nsIDebug2);
var env = Cc[ENVIRONMENT_CONTRACTID].getService(Ci.nsIEnvironment);
gVerbose = !!env.get("MOZ_REFTEST_VERBOSE");
RegisterMessageListeners();
@ -205,7 +200,7 @@ function doPrintMode(contentRootElement) {
function setupPrintMode() {
var PSSVC =
CC[PRINTSETTINGS_CONTRACTID].getService(CI.nsIPrintSettingsService);
Cc[PRINTSETTINGS_CONTRACTID].getService(Ci.nsIPrintSettingsService);
var ps = PSSVC.newPrintSettings;
ps.paperWidth = 5;
ps.paperHeight = 3;
@ -247,11 +242,11 @@ function printToPdf(callback) {
}
let fileName = "reftest-print.pdf";
let file = Services.dirsvc.get("TmpD", CI.nsIFile);
let file = Services.dirsvc.get("TmpD", Ci.nsIFile);
file.append(fileName);
file.createUnique(file.NORMAL_FILE_TYPE, 0o644);
let PSSVC = CC[PRINTSETTINGS_CONTRACTID].getService(CI.nsIPrintSettingsService);
let PSSVC = Cc[PRINTSETTINGS_CONTRACTID].getService(Ci.nsIPrintSettingsService);
let ps = PSSVC.newPrintSettings;
ps.printSilent = true;
ps.showPrintProgress = false;
@ -259,24 +254,24 @@ function printToPdf(callback) {
ps.printBGColors = true;
ps.printToFile = true;
ps.toFileName = file.path;
ps.printFrameType = CI.nsIPrintSettings.kFramesAsIs;
ps.outputFormat = CI.nsIPrintSettings.kOutputFormatPDF;
ps.printFrameType = Ci.nsIPrintSettings.kFramesAsIs;
ps.outputFormat = Ci.nsIPrintSettings.kOutputFormatPDF;
if (isPrintSelection) {
ps.printRange = CI.nsIPrintSettings.kRangeSelection;
ps.printRange = Ci.nsIPrintSettings.kRangeSelection;
} else if (printRange) {
ps.printRange = CI.nsIPrintSettings.kRangeSpecifiedPageRange;
ps.printRange = Ci.nsIPrintSettings.kRangeSpecifiedPageRange;
let range = printRange.split('-');
ps.startPageRange = +range[0] || 1;
ps.endPageRange = +range[1] || 1;
}
let webBrowserPrint = content.QueryInterface(CI.nsIInterfaceRequestor)
.getInterface(CI.nsIWebBrowserPrint);
let webBrowserPrint = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebBrowserPrint);
webBrowserPrint.print(ps, {
onStateChange: function(webProgress, request, stateFlags, status) {
if (stateFlags & CI.nsIWebProgressListener.STATE_STOP &&
stateFlags & CI.nsIWebProgressListener.STATE_IS_NETWORK) {
if (stateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
stateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
callback(status, file.path);
}
},
@ -497,8 +492,8 @@ function FlushRendering() {
var anyPendingPaintsGeneratedInDescendants = false;
function flushWindow(win) {
var utils = win.QueryInterface(CI.nsIInterfaceRequestor)
.getInterface(CI.nsIDOMWindowUtils);
var utils = win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
var afterPaintWasPending = utils.isMozAfterPaintPending;
var root = win.document.documentElement;
@ -670,7 +665,7 @@ function WaitForTestEnd(contentRootElement, inPrintMode, spellCheckedElements) {
LogInfo("MakeProgress: STATE_WAITING_FOR_APZ_FLUSH");
gFailureReason = "timed out waiting for APZ flush to complete";
var os = CC[NS_OBSERVER_SERVICE_CONTRACTID].getService(CI.nsIObserverService);
var os = Cc[NS_OBSERVER_SERVICE_CONTRACTID].getService(Ci.nsIObserverService);
var flushWaiter = function(aSubject, aTopic, aData) {
if (aTopic) LogInfo("MakeProgress: apz-repaints-flushed fired");
os.removeObserver(flushWaiter, "apz-repaints-flushed");
@ -1166,7 +1161,7 @@ function SendAssertionCount(numAssertions)
function SendContentReady()
{
let gfxInfo = (NS_GFXINFO_CONTRACTID in CC) && CC[NS_GFXINFO_CONTRACTID].getService(CI.nsIGfxInfo);
let gfxInfo = (NS_GFXINFO_CONTRACTID in Cc) && Cc[NS_GFXINFO_CONTRACTID].getService(Ci.nsIGfxInfo);
let info = gfxInfo.getInfo();
// The webrender check has to be separate from the d2d checks

View File

@ -11,27 +11,22 @@ var EXPORTED_SYMBOLS = [
"getTestPlugin"
];
var CC = Components.classes;
const CI = Components.interfaces;
const CR = Components.results;
const CU = Components.utils;
CU.import("resource://gre/modules/FileUtils.jsm");
CU.import("chrome://reftest/content/globals.jsm", this);
CU.import("chrome://reftest/content/httpd.jsm", this);
CU.import("chrome://reftest/content/manifest.jsm", this);
CU.import("chrome://reftest/content/StructuredLog.jsm", this);
CU.import("resource://gre/modules/Services.jsm");
CU.import("resource://gre/modules/NetUtil.jsm");
CU.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("chrome://reftest/content/globals.jsm", this);
Cu.import("chrome://reftest/content/httpd.jsm", this);
Cu.import("chrome://reftest/content/manifest.jsm", this);
Cu.import("chrome://reftest/content/StructuredLog.jsm", this);
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyGetter(this, "OS", function() {
const { OS } = CU.import("resource://gre/modules/osfile.jsm");
const { OS } = Cu.import("resource://gre/modules/osfile.jsm");
return OS;
});
XPCOMUtils.defineLazyGetter(this, "PDFJS", function() {
const { require } = CU.import("resource://gre/modules/commonjs/toolkit/require.js", {});
const { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
return {
main: require('resource://pdf.js/build/pdf.js'),
worker: require('resource://pdf.js/build/pdf.worker.js')
@ -133,7 +128,7 @@ function IDForEventTarget(event)
}
function getTestPlugin(aName) {
var ph = CC["@mozilla.org/plugin/host;1"].getService(CI.nsIPluginHost);
var ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
var tags = ph.getPluginTags();
// Find the test plugin
@ -148,19 +143,19 @@ function getTestPlugin(aName) {
function OnRefTestLoad(win)
{
g.crashDumpDir = CC[NS_DIRECTORY_SERVICE_CONTRACTID]
.getService(CI.nsIProperties)
.get("ProfD", CI.nsIFile);
g.crashDumpDir = Cc[NS_DIRECTORY_SERVICE_CONTRACTID]
.getService(Ci.nsIProperties)
.get("ProfD", Ci.nsIFile);
g.crashDumpDir.append("minidumps");
g.pendingCrashDumpDir = CC[NS_DIRECTORY_SERVICE_CONTRACTID]
.getService(CI.nsIProperties)
.get("UAppData", CI.nsIFile);
g.pendingCrashDumpDir = Cc[NS_DIRECTORY_SERVICE_CONTRACTID]
.getService(Ci.nsIProperties)
.get("UAppData", Ci.nsIFile);
g.pendingCrashDumpDir.append("Crash Reports");
g.pendingCrashDumpDir.append("pending");
var env = CC["@mozilla.org/process/environment;1"].
getService(CI.nsIEnvironment);
var env = Cc["@mozilla.org/process/environment;1"].
getService(Ci.nsIEnvironment);
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
@ -207,8 +202,8 @@ function OnRefTestLoad(win)
let plugin2 = getTestPlugin("Second Test Plug-in");
if (plugin1 && plugin2) {
g.testPluginEnabledStates = [plugin1.enabledState, plugin2.enabledState];
plugin1.enabledState = CI.nsIPluginTag.STATE_ENABLED;
plugin2.enabledState = CI.nsIPluginTag.STATE_ENABLED;
plugin1.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
plugin2.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
} else {
logger.warning("Could not get test plugin tags.");
}
@ -289,12 +284,12 @@ function InitAndStartRefTests()
}
#endif
g.windowUtils = g.containingWindow.QueryInterface(CI.nsIInterfaceRequestor).getInterface(CI.nsIDOMWindowUtils);
g.windowUtils = g.containingWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
if (!g.windowUtils || !g.windowUtils.compareCanvases)
throw "nsIDOMWindowUtils inteface missing";
g.ioService = CC[IO_SERVICE_CONTRACTID].getService(CI.nsIIOService);
g.debug = CC[DEBUG_CONTRACTID].getService(CI.nsIDebug2);
g.ioService = Cc[IO_SERVICE_CONTRACTID].getService(Ci.nsIIOService);
g.debug = Cc[DEBUG_CONTRACTID].getService(Ci.nsIDebug2);
RegisterProcessCrashObservers();
@ -580,11 +575,11 @@ function BuildUseCounts()
// Return true iff this window is focused when this function returns.
function Focus()
{
var fm = CC["@mozilla.org/focus-manager;1"].getService(CI.nsIFocusManager);
var fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
fm.focusedWindow = g.containingWindow;
#ifdef XP_MACOSX
try {
var dock = CC["@mozilla.org/widget/macdocksupport;1"].getService(CI.nsIMacDockSupport);
var dock = Cc["@mozilla.org/widget/macdocksupport;1"].getService(Ci.nsIMacDockSupport);
dock.activateApplication(true);
} catch(ex) {
}
@ -774,8 +769,8 @@ function DoneTests()
}
function onStopped() {
let appStartup = CC["@mozilla.org/toolkit/app-startup;1"].getService(CI.nsIAppStartup);
appStartup.quit(CI.nsIAppStartup.eForceQuit);
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
appStartup.quit(Ci.nsIAppStartup.eForceQuit);
}
if (g.server) {
g.server.stop(onStopped);
@ -1263,7 +1258,7 @@ function FindUnexpectedCrashDumpFiles()
let foundCrashDumpFile = false;
while (entries.hasMoreElements()) {
let file = entries.getNext().QueryInterface(CI.nsIFile);
let file = entries.getNext().QueryInterface(Ci.nsIFile);
let path = String(file.path);
if (path.match(/\.(dmp|extra)$/) && !g.unexpectedCrashDumpFiles[path]) {
if (!foundCrashDumpFile) {
@ -1289,7 +1284,7 @@ function RemovePendingCrashDumpFiles()
let entries = g.pendingCrashDumpDir.directoryEntries;
while (entries.hasMoreElements()) {
let file = entries.getNext().QueryInterface(CI.nsIFile);
let file = entries.getNext().QueryInterface(Ci.nsIFile);
if (file.isFile()) {
file.remove(false);
logger.info("This test left pending crash dumps; deleted "+file.path);
@ -1555,7 +1550,7 @@ function RecvUpdateWholeCanvasForInvalidation()
function OnProcessCrashed(subject, topic, data)
{
var id;
subject = subject.QueryInterface(CI.nsIPropertyBag2);
subject = subject.QueryInterface(Ci.nsIPropertyBag2);
if (topic == "plugin-crashed") {
id = subject.getPropertyAsAString("pluginDumpID");
} else if (topic == "ipc:content-shutdown") {
@ -1569,8 +1564,8 @@ function OnProcessCrashed(subject, topic, data)
function RegisterProcessCrashObservers()
{
var os = CC[NS_OBSERVER_SERVICE_CONTRACTID]
.getService(CI.nsIObserverService);
var os = Cc[NS_OBSERVER_SERVICE_CONTRACTID]
.getService(Ci.nsIObserverService);
os.addObserver(OnProcessCrashed, "plugin-crashed");
os.addObserver(OnProcessCrashed, "ipc:content-shutdown");
}

View File

@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Ci = Components.interfaces, Cc = Components.classes, Cu = Components.utils, Cr = Components.results;
ChromeUtils.import("resource://gre/modules/Messaging.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");

View File

@ -2,9 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const CC = Components.classes;
const CI = Components.interfaces;
const TPS_ID = "tps@mozilla.org";
const TPS_CMDLINE_CONTRACTID = "@mozilla.org/commandlinehandler/general-startup;1?type=tps";
const TPS_CMDLINE_CLSID = Components.ID("{4e5bd3f0-41d3-11df-9879-0800200c9a66}");

View File

@ -526,12 +526,11 @@
if (!this._spellCheckInitialized) {
this._spellCheckInitialized = true;
const CI = Components.interfaces;
if (ChromeUtils.getClassName(document) != "XULDocument")
return null;
var textbox = document.getBindingParent(this);
if (!textbox || !(textbox instanceof CI.nsIDOMXULTextBoxElement))
if (!textbox || !(textbox instanceof Ci.nsIDOMXULTextBoxElement))
return null;
try {