Bug 1230373 - Enable mozilla/use-services for browser/components/ r=mossop

MozReview-Commit-ID: 9m9iss3jUJJ
This commit is contained in:
Mark Banner
2017-10-11 15:43:51 +01:00
parent 65c34bf3e9
commit 4de85b3d5b
61 changed files with 235 additions and 505 deletions

View File

@@ -5,5 +5,7 @@ module.exports = {
// XXX Bug 1326071 - This should be reduced down - probably to 20 or to
// be removed & synced with the mozilla/recommended value.
"complexity": ["error", 61],
"mozilla/use-services": "error",
}
};

View File

@@ -14,7 +14,6 @@ add_task(async function() {
// longer, we skip this for now.
];
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
for (let cid in Cc) {
let result = cid.match(/@mozilla.org\/network\/protocol\/about;1\?what\=(.*)$/);
if (!result) {
@@ -25,7 +24,7 @@ add_task(async function() {
let contract = "@mozilla.org/network/protocol/about;1?what=" + aboutType;
try {
let am = Cc[contract].getService(Ci.nsIAboutModule);
let uri = ios.newURI("about:" + aboutType);
let uri = Services.io.newURI("about:" + aboutType);
let flags = am.getURIFlags(uri);
if (!(flags & Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT) &&
networkURLs.indexOf(aboutType) == -1) {

View File

@@ -121,18 +121,13 @@ add_task(async function test_quota_clearStoragesForPrincipal() {
}
// Using quota manager to clear all indexed DB for a given domain.
let qms = Cc["@mozilla.org/dom/quota-manager-service;1"].
getService(Ci.nsIQuotaManagerService);
let caUtils = {};
let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
scriptLoader.loadSubScript("chrome://global/content/contentAreaUtils.js",
Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js",
caUtils);
let httpURI = caUtils.makeURI("http://" + TEST_HOST);
let httpPrincipal = Services.scriptSecurityManager
.createCodebasePrincipal(httpURI, {});
qms.clearStoragesForPrincipal(httpPrincipal, null, true);
Services.qms.clearStoragesForPrincipal(httpPrincipal, null, true);
for (let userContextId of Object.keys(USER_CONTEXTS)) {
// Open our tab in the given user context.

View File

@@ -7,10 +7,6 @@ const { classes: Cc, Constructor: CC, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/ForgetAboutSite.jsm");
Cu.import("resource://gre/modules/Services.jsm");
let {HttpServer} = Cu.import("resource://testing-common/httpd.js", {});
let LoadContextInfo = Cc["@mozilla.org/load-context-info-factory;1"]
.getService(Ci.nsILoadContextInfoFactory);
let css = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
const USER_CONTEXTS = [
"default",
@@ -72,18 +68,16 @@ function getCookiesForOA(host, userContextId) {
}
function createURI(uri) {
let ioServ = Cc["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
return ioServ.newURI(uri);
return Services.io.newURI(uri);
}
function getCacheStorage(where, lci, appcache) {
if (!lci) lci = LoadContextInfo.default;
if (!lci) lci = Services.loadContextInfo.default;
switch (where) {
case "disk": return css.diskCacheStorage(lci, false);
case "memory": return css.memoryCacheStorage(lci);
case "appcache": return css.appCacheStorage(lci, appcache);
case "pin": return css.pinningCacheStorage(lci);
case "disk": return Services.cache2.diskCacheStorage(lci, false);
case "memory": return Services.cache2.memoryCacheStorage(lci);
case "appcache": return Services.cache2.appCacheStorage(lci, appcache);
case "pin": return Services.cache2.pinningCacheStorage(lci);
}
return null;
}
@@ -166,19 +160,19 @@ async function test_cache_cleared() {
await OpenCacheEntry("http://" + TEST_HOST + "/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
LoadContextInfo.custom(false, {userContextId}));
Services.loadContextInfo.custom(false, {userContextId}));
await OpenCacheEntry("http://" + TEST_HOST + "/",
"memory",
Ci.nsICacheStorage.OPEN_NORMALLY,
LoadContextInfo.custom(false, {userContextId}));
Services.loadContextInfo.custom(false, {userContextId}));
}
// Check that caches have been set correctly.
for (let userContextId of Object.keys(USER_CONTEXTS)) {
let mem = getCacheStorage("memory", LoadContextInfo.custom(false, {userContextId}));
let disk = getCacheStorage("disk", LoadContextInfo.custom(false, {userContextId}));
let mem = getCacheStorage("memory", Services.loadContextInfo.custom(false, {userContextId}));
let disk = getCacheStorage("disk", Services.loadContextInfo.custom(false, {userContextId}));
Assert.ok(mem.exists(createURI("http://" + TEST_HOST + "/"), ""), "The memory cache has been set correctly");
Assert.ok(disk.exists(createURI("http://" + TEST_HOST + "/"), ""), "The disk cache has been set correctly");
@@ -189,8 +183,8 @@ async function test_cache_cleared() {
// Check that do caches be removed or not?
for (let userContextId of Object.keys(USER_CONTEXTS)) {
let mem = getCacheStorage("memory", LoadContextInfo.custom(false, {userContextId}));
let disk = getCacheStorage("disk", LoadContextInfo.custom(false, {userContextId}));
let mem = getCacheStorage("memory", Services.loadContextInfo.custom(false, {userContextId}));
let disk = getCacheStorage("disk", Services.loadContextInfo.custom(false, {userContextId}));
Assert.ok(!mem.exists(createURI("http://" + TEST_HOST + "/"), ""), "The memory cache is cleared");
Assert.ok(!disk.exists(createURI("http://" + TEST_HOST + "/"), ""), "The disk cache is cleared");

View File

@@ -31,13 +31,11 @@ DistributionCustomizer.prototype = {
// For parallel xpcshell testing purposes allow loading the distribution.ini
// file from the profile folder through an hidden pref.
let loadFromProfile = Services.prefs.getBoolPref("distribution.testing.loadFromProfile", false);
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
let iniFile;
try {
iniFile = loadFromProfile ? dirSvc.get("ProfD", Ci.nsIFile)
: dirSvc.get("XREAppDist", Ci.nsIFile);
iniFile = loadFromProfile ? Services.dirsvc.get("ProfD", Ci.nsIFile)
: Services.dirsvc.get("XREAppDist", Ci.nsIFile);
if (loadFromProfile) {
iniFile.leafName = "distribution";
}
@@ -100,30 +98,6 @@ DistributionCustomizer.prototype = {
return this._language;
},
get _prefSvc() {
let svc = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService);
this.__defineGetter__("_prefSvc", () => svc);
return this._prefSvc;
},
get _prefs() {
let branch = this._prefSvc.getBranch(null);
this.__defineGetter__("_prefs", () => branch);
return this._prefs;
},
get _ioSvc() {
let svc = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
this.__defineGetter__("_ioSvc", () => svc);
return this._ioSvc;
},
_makeURI: function DIST__makeURI(spec) {
return this._ioSvc.newURI(spec);
},
async _parseBookmarksSection(parentGuid, section) {
let keys = Array.from(enumerate(this._ini.getKeys(section))).sort();
let re = /^item\.(\d+)\.(\w+)\.?(\w*)/;
@@ -211,8 +185,8 @@ DistributionCustomizer.prototype = {
// Don't bother updating the livemark contents on creation.
let parentId = await PlacesUtils.promiseItemId(parentGuid);
await PlacesUtils.livemarks.addLivemark({
feedURI: this._makeURI(item.feedLink),
siteURI: this._makeURI(item.siteLink),
feedURI: Services.io.newURI(item.feedLink),
siteURI: Services.io.newURI(item.siteLink),
parentId, index, title: item.title
});
break;
@@ -236,13 +210,13 @@ DistributionCustomizer.prototype = {
if (item.icon && item.iconData) {
try {
let faviconURI = this._makeURI(item.icon);
let faviconURI = Services.io.newURI(item.icon);
PlacesUtils.favicons.replaceFaviconDataFromDataURL(
faviconURI, item.iconData, 0,
Services.scriptSecurityManager.getSystemPrincipal());
PlacesUtils.favicons.setAndFetchFaviconForPage(
this._makeURI(item.link), faviconURI, false,
Services.io.newURI(item.link), faviconURI, false,
PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE, null,
Services.scriptSecurityManager.getSystemPrincipal());
} catch (e) {
@@ -278,8 +252,8 @@ DistributionCustomizer.prototype = {
// nsPrefService loads very early. Reload prefs so we can set
// distribution defaults during the prefservice:after-app-defaults
// notification (see applyPrefDefaults below)
this._prefSvc.QueryInterface(Ci.nsIObserver);
this._prefSvc.observe(null, "reload-default-prefs", null);
Services.prefs.QueryInterface(Ci.nsIObserver)
.observe(null, "reload-default-prefs", null);
},
_bookmarksApplied: false,
@@ -313,7 +287,7 @@ DistributionCustomizer.prototype = {
this._ini.getString("Global", "id") + ".bookmarksProcessed";
}
let bmProcessed = this._prefs.getBoolPref(bmProcessedPref, false);
let bmProcessed = Services.prefs.getBoolPref(bmProcessedPref, false);
if (!bmProcessed) {
if (sections.BookmarksMenu)
@@ -322,7 +296,7 @@ DistributionCustomizer.prototype = {
if (sections.BookmarksToolbar)
await this._parseBookmarksSection(PlacesUtils.bookmarks.toolbarGuid,
"BookmarksToolbar");
this._prefs.setBoolPref(bmProcessedPref, true);
Services.prefs.setBoolPref(bmProcessedPref, true);
}
},
@@ -489,9 +463,7 @@ DistributionCustomizer.prototype = {
let prefDefaultsApplied = this._prefDefaultsApplied || !this._ini;
if (this._customizationsApplied && this._bookmarksApplied &&
prefDefaultsApplied) {
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
os.notifyObservers(null, DISTRIBUTION_CUSTOMIZATION_COMPLETE_TOPIC);
Services.obs.notifyObservers(null, DISTRIBUTION_CUSTOMIZATION_COMPLETE_TOPIC);
}
}
};

View File

@@ -625,12 +625,11 @@ XPCOMUtils.defineLazyGetter(this.DownloadsCommon, "error", () => {
* Returns true if we are executing on Windows Vista or a later version.
*/
XPCOMUtils.defineLazyGetter(DownloadsCommon, "isWinVistaOrHigher", function() {
let os = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
let os = Services.appinfo.OS;
if (os != "WINNT") {
return false;
}
let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
return parseFloat(sysInfo.getProperty("version")) >= 6;
return parseFloat(Services.sysinfo.getProperty("version")) >= 6;
});
// DownloadsData

View File

@@ -17,10 +17,8 @@ add_task(async function test_indicatorDrop() {
ok(downloadButton, "download button present");
await promiseButtonShown(downloadButton.id);
let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
let EventUtils = {};
scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
Services.scriptloader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
async function task_drop(urls) {
let dragData = [[{type: "text/plain", data: urls.join("\n")}]];

View File

@@ -12,10 +12,8 @@ registerCleanupFunction(async function() {
});
add_task(async function test_indicatorDrop() {
let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
let EventUtils = {};
scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
Services.scriptloader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
async function drop(win, urls) {
let dragData = [[{type: "text/plain", data: urls.join("\n")}]];

View File

@@ -311,8 +311,7 @@ initDevTools = function() {
"Only local tab are currently supported by the WebExtensions DevTools API.";
let scriptError = Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError);
scriptError.init(msg, null, null, null, null, Ci.nsIScriptError.warningFlag, "content javascript");
let consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
consoleService.logMessage(scriptError);
Services.console.logMessage(scriptError);
return;
}

View File

@@ -5,11 +5,6 @@
// The ext-* files are imported into the same scopes.
/* import-globals-from ext-browser.js */
XPCOMUtils.defineLazyGetter(this, "strBundle", function() {
const stringSvc = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
return stringSvc.createBundle("chrome://global/locale/extensions.properties");
});
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PromiseUtils",
@@ -17,6 +12,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "PromiseUtils",
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "strBundle", function() {
return Services.strings.createBundle("chrome://global/locale/extensions.properties");
});
var {
ExtensionError,
} = ExtensionUtils;

View File

@@ -48,13 +48,10 @@ add_task(async function testIndexedDB() {
await extension.awaitMessage("indexedDBCreated");
await extension.awaitMessage("indexedDBCreated");
let qms = SpecialPowers.Cc["@mozilla.org/dom/quota-manager-service;1"]
.getService(Ci.nsIQuotaManagerService);
function getOrigins() {
return new Promise(resolve => {
let origins = [];
qms.getUsage(request => {
Services.qms.getUsage(request => {
for (let i = 0; i < request.result.length; ++i) {
if (request.result[i].origin.startsWith("http://mochi.test") ||
request.result[i].origin.startsWith("http://example.com")) {

View File

@@ -66,8 +66,7 @@ function makeWidgetId(id) {
}
var focusWindow = async function focusWindow(win) {
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
if (fm.activeWindow == win) {
if (Services.focus.activeWindow == win) {
return;
}

View File

@@ -91,17 +91,6 @@ function getPrefReaderForType(t) {
}
}
function safeGetCharPref(pref, defaultValue) {
var prefs =
Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
try {
return prefs.getCharPref(pref);
} catch (e) {
}
return defaultValue;
}
function FeedConverter() {
}
FeedConverter.prototype = {
@@ -193,11 +182,11 @@ FeedConverter.prototype = {
getService(Ci.nsIFeedResultService);
if (!this._forcePreviewPage && result.doc) {
let feed = result.doc.QueryInterface(Ci.nsIFeed);
let handler = safeGetCharPref(getPrefActionForType(feed.type), "ask");
let handler = Services.prefs.getCharPref(getPrefActionForType(feed.type), "ask");
if (handler != "ask") {
if (handler == "reader")
handler = safeGetCharPref(getPrefReaderForType(feed.type), "bookmarks");
handler = Services.prefs.getCharPref(getPrefReaderForType(feed.type), "bookmarks");
switch (handler) {
case "web":
let wccr =
@@ -230,9 +219,6 @@ FeedConverter.prototype = {
}
}
let ios =
Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
let chromeChannel;
// handling a redirect, hence forwarding the loadInfo from the old channel
@@ -250,8 +236,8 @@ FeedConverter.prototype = {
feedService.addFeedResult(result);
// Now load the actual XUL document.
let aboutFeedsURI = ios.newURI("about:feeds");
chromeChannel = ios.newChannelFromURIWithLoadInfo(aboutFeedsURI, loadInfo);
let aboutFeedsURI = Services.io.newURI("about:feeds");
chromeChannel = Services.io.newChannelFromURIWithLoadInfo(aboutFeedsURI, loadInfo);
chromeChannel.originalURI = result.uri;
// carry the origin attributes from the channel that loaded the feed.
@@ -259,7 +245,7 @@ FeedConverter.prototype = {
Services.scriptSecurityManager.createCodebasePrincipal(aboutFeedsURI,
loadInfo.originAttributes);
} else {
chromeChannel = ios.newChannelFromURIWithLoadInfo(result.uri, loadInfo);
chromeChannel = Services.io.newChannelFromURIWithLoadInfo(result.uri, loadInfo);
}
chromeChannel.loadGroup = this._request.loadGroup;
@@ -374,7 +360,7 @@ FeedResultService.prototype = {
feedReader = "default";
}
let handler = safeGetCharPref(getPrefActionForType(feedType), "bookmarks");
let handler = Services.prefs.getCharPref(getPrefActionForType(feedType), "bookmarks");
if (handler == "ask" || handler == "reader")
handler = feedReader;
@@ -477,10 +463,7 @@ function GenericProtocolHandler() {
}
GenericProtocolHandler.prototype = {
_init(scheme) {
let ios =
Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
this._http = ios.getProtocolHandler("http");
this._http = Services.io.getProtocolHandler("http");
this._scheme = scheme;
},
@@ -553,9 +536,7 @@ GenericProtocolHandler.prototype = {
newChannel2(aUri, aLoadInfo) {
let inner = aUri.QueryInterface(Ci.nsINestedURI).innerURI;
let channel = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService).
newChannelFromURIWithLoadInfo(inner, aLoadInfo);
let channel = Services.io.newChannelFromURIWithLoadInfo(inner, aLoadInfo);
const schemeId = this._getTelemetrySchemeId();
Services.telemetry.getHistogramById("FEED_PROTOCOL_USAGE").add(schemeId);

View File

@@ -17,10 +17,7 @@ const FEEDWRITER_CID = Components.ID("{49bb6593-3aff-4eb3-a068-2712c28bd58e}");
const FEEDWRITER_CONTRACTID = "@mozilla.org/browser/feeds/result-writer;1";
function LOG(str) {
let prefB = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
let shouldLog = prefB.getBoolPref("feeds.log", false);
let shouldLog = Services.prefs.getBoolPref("feeds.log", false);
if (shouldLog)
dump("*** Feeds: " + str + "\n");
@@ -33,10 +30,8 @@ function LOG(str) {
* @returns an nsIURI object, or null if the creation of the URI failed.
*/
function makeURI(aURLSpec, aCharset) {
let ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
try {
return ios.newURI(aURLSpec, aCharset);
return Services.io.newURI(aURLSpec, aCharset);
} catch (ex) { }
return null;
@@ -124,12 +119,10 @@ FeedWriter.prototype = {
* The URI spec to set as the href
*/
_safeSetURIAttribute(element, attribute, uri) {
let secman = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager);
const flags = Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL;
try {
// TODO Is this necessary?
secman.checkLoadURIStrWithPrincipal(this._feedPrincipal, uri, flags);
Services.scriptSecurityManager.checkLoadURIStrWithPrincipal(this._feedPrincipal, uri, flags);
// checkLoadURIStrWithPrincipal will throw if the link URI should not be
// loaded, either because our feedURI isn't allowed to load it or per
// the rules specified in |flags|, so we'll never "linkify" the link...
@@ -144,9 +137,7 @@ FeedWriter.prototype = {
__bundle: null,
get _bundle() {
if (!this.__bundle) {
this.__bundle = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
createBundle(URI_BUNDLE);
this.__bundle = Services.strings.createBundle(URI_BUNDLE);
}
return this.__bundle;
},
@@ -492,9 +483,7 @@ FeedWriter.prototype = {
* @returns moz-icon url of the given file as a string
*/
_getFileIconURL(file) {
let ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
let fph = ios.getProtocolHandler("file")
let fph = Services.io.getProtocolHandler("file")
.QueryInterface(Ci.nsIFileProtocolHandler);
let urlSpec = fph.getURLSpecFromFile(file);
return "moz-icon://" + urlSpec + "?size=16";
@@ -801,9 +790,7 @@ FeedWriter.prototype = {
this._document = window.document;
this._handlersList = this._document.getElementById("handlersMenuList");
let secman = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager);
this._feedPrincipal = secman.createCodebasePrincipal(this._feedURI, {});
this._feedPrincipal = Services.scriptSecurityManager.createCodebasePrincipal(this._feedURI, {});
LOG("Subscribe Preview: feed uri = " + this._window.location.href);

View File

@@ -1,5 +1,6 @@
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
var Cr = Components.results;
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
Cu.import("resource://gre/modules/Services.jsm");

View File

@@ -2,13 +2,13 @@ var Cu = Components.utils;
Cu.import("resource://gre/modules/NetUtil.jsm");
function run_test() {
var feedFeedURI = ios.newURI("feed://example.com/feed.xml");
var httpFeedURI = ios.newURI("feed:http://example.com/feed.xml");
var httpURI = ios.newURI("http://example.com/feed.xml");
var feedFeedURI = Services.io.newURI("feed://example.com/feed.xml");
var httpFeedURI = Services.io.newURI("feed:http://example.com/feed.xml");
var httpURI = Services.io.newURI("http://example.com/feed.xml");
var httpsFeedURI =
ios.newURI("feed:https://example.com/feed.xml");
var httpsURI = ios.newURI("https://example.com/feed.xml");
Services.io.newURI("feed:https://example.com/feed.xml");
var httpsURI = Services.io.newURI("https://example.com/feed.xml");
var feedChannel = NetUtil.newChannel({
uri: feedFeedURI,
@@ -36,8 +36,8 @@ function run_test() {
do_check_true(httpsURI.equals(httpsChannel.URI));
// check that we throw creating feed: URIs from file and ftp
Assert.throws(function() { ios.newURI("feed:ftp://example.com/feed.xml"); },
Assert.throws(function() { Services.io.newURI("feed:ftp://example.com/feed.xml"); },
"Should throw an exception when trying to create a feed: URI with an ftp: inner");
Assert.throws(function() { ios.newURI("feed:file:///var/feed.xml"); },
Assert.throws(function() { Services.io.newURI("feed:file:///var/feed.xml"); },
"Should throw an exception when trying to create a feed: URI with a file: inner");
}

View File

@@ -1,7 +1,7 @@
function run_test() {
var success = false;
try {
ios.newURI("feed:javascript:alert('hi');");
Services.io.newURI("feed:javascript:alert('hi');");
} catch (e) {
success = e.result == Cr.NS_ERROR_MALFORMED_URI;
}
@@ -10,7 +10,7 @@ function run_test() {
success = false;
try {
ios.newURI("feed:data:text/html,hi");
Services.io.newURI("feed:data:text/html,hi");
} catch (e) {
success = e.result == Cr.NS_ERROR_MALFORMED_URI;
}
@@ -19,7 +19,7 @@ function run_test() {
success = false;
try {
ios.newURI("pcast:javascript:alert('hi');");
Services.io.newURI("pcast:javascript:alert('hi');");
} catch (e) {
success = e.result == Cr.NS_ERROR_MALFORMED_URI;
}
@@ -28,7 +28,7 @@ function run_test() {
success = false;
try {
ios.newURI("pcast:data:text/html,hi");
Services.io.newURI("pcast:data:text/html,hi");
} catch (e) {
success = e.result == Cr.NS_ERROR_MALFORMED_URI;
}

View File

@@ -58,8 +58,7 @@ var MigrationWizard = { /* exported MigrationWizard */
},
uninit() {
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
var os = Services.obs;
os.removeObserver(this, "Migration:Started");
os.removeObserver(this, "Migration:ItemBeforeMigrate");
os.removeObserver(this, "Migration:ItemAfterMigrate");
@@ -419,22 +418,16 @@ var MigrationWizard = { /* exported MigrationWizard */
if (this._newHomePage) {
try {
// set homepage properly
var prefSvc = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var prefBranch = prefSvc.getBranch(null);
if (this._newHomePage == "DEFAULT") {
prefBranch.clearUserPref("browser.startup.homepage");
Services.prefs.clearUserPref("browser.startup.homepage");
} else {
prefBranch.setStringPref("browser.startup.homepage",
Services.prefs.setStringPref("browser.startup.homepage",
this._newHomePage);
}
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
var prefFile = dirSvc.get("ProfDS", Components.interfaces.nsIFile);
var prefFile = Services.dirsvc.get("ProfDS", Components.interfaces.nsIFile);
prefFile.append("prefs.js");
prefSvc.savePrefFile(prefFile);
Services.prefs.savePrefFile(prefFile);
} catch (ex) {
dump(ex);
}
@@ -477,9 +470,7 @@ var MigrationWizard = { /* exported MigrationWizard */
type = "misc. data";
break;
}
Cc["@mozilla.org/consoleservice;1"]
.getService(Ci.nsIConsoleService)
.logStringMessage("some " + type + " did not successfully migrate.");
Services.console.logStringMessage("some " + type + " did not successfully migrate.");
Services.telemetry.getKeyedHistogramById("FX_MIGRATION_ERRORS")
.add(this._source, Math.log2(numericType));
break;

View File

@@ -981,9 +981,7 @@ BrowserGlue.prototype = {
// Call trackStartupCrashEnd here in case the delayed call on startup hasn't
// yet occurred (see trackStartupCrashEnd caller in browser.js).
try {
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
.getService(Ci.nsIAppStartup);
appStartup.trackStartupCrashEnd();
Services.startup.trackStartupCrashEnd();
} catch (e) {
Cu.reportError("Could not end startup crash tracking in quit-application-granted: " + e);
}
@@ -1381,15 +1379,13 @@ BrowserGlue.prototype = {
if (!actions || actions.indexOf("silent") != -1)
return;
var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
getService(Ci.nsIURLFormatter);
var appName = gBrandBundle.GetStringFromName("brandShortName");
function getNotifyString(aPropData) {
var propValue = update.getProperty(aPropData.propName);
if (!propValue) {
if (aPropData.prefName)
propValue = formatter.formatURLPref(aPropData.prefName);
propValue = Services.urlFormatter.formatURLPref(aPropData.prefName);
else if (aPropData.stringParams)
propValue = gBrowserBundle.formatStringFromName(aPropData.stringName,
aPropData.stringParams,
@@ -1696,9 +1692,7 @@ BrowserGlue.prototype = {
var accessKey = placesBundle.GetStringFromName("lockPromptInfoButton.accessKey");
var helpTopic = "places-locked";
var url = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
getService(Components.interfaces.nsIURLFormatter).
formatURLPref("app.support.baseURL");
var url = Services.urlFormatter.formatURLPref("app.support.baseURL");
url += helpTopic;
var win = RecentWindow.getMostRecentBrowserWindow();

View File

@@ -127,9 +127,7 @@ async function doInit(aMode) {
["network.predictor.enable-prefetch", false]]});
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
Services.cache2.clear();
randomSuffix = Math.random();
stopObservingChannels = startObservingChannels(aMode);

View File

@@ -254,16 +254,12 @@ add_task(async function setup() {
// A clean up function to prevent affecting other tests.
registerCleanupFunction(() => {
// Clear all cookies.
let cookieMgr = Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager);
cookieMgr.removeAll();
Services.cookies.removeAll();
// Clear all image caches and network caches.
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
Services.cache2.clear();
});
add_task(async function test_favicon_firstParty() {
@@ -271,9 +267,7 @@ add_task(async function test_favicon_firstParty() {
// Clear all image caches and network caches before running the test.
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
Services.cache2.clear();
// Clear Places favicon caches.
await clearAllPlacesFavicons();
@@ -292,9 +286,7 @@ add_task(async function test_favicon_cache_firstParty() {
// Clear all image caches and network caches before running the test.
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
Services.cache2.clear();
// Start to observer the event of that favicon has been fully loaded and cached.
let promiseForFaviconLoaded = waitOnFaviconLoaded(THIRD_PARTY_SITE + TEST_FAVICON_CACHE_URI);

View File

@@ -211,16 +211,12 @@ add_task(async function setup() {
// A clean up function to prevent affecting other tests.
registerCleanupFunction(() => {
// Clear all cookies.
let cookieMgr = Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager);
cookieMgr.removeAll();
Services.cookies.removeAll();
// Clear all image caches and network caches.
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
Services.cache2.clear();
// Clear Places favicon caches.
clearAllPlacesFavicons();
@@ -231,9 +227,7 @@ add_task(async function test_favicon_userContextId() {
clearAllImageCaches();
// Clear all network caches.
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
Services.cache2.clear();
// Clear Places favicon caches.
await clearAllPlacesFavicons();
@@ -246,9 +240,7 @@ add_task(async function test_thirdPartyFavicon_userContextId() {
clearAllImageCaches();
// Clear all network caches.
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
Services.cache2.clear();
// Clear Places favicon caches.
await clearAllPlacesFavicons();

View File

@@ -141,7 +141,6 @@ add_task(async function test_aboutURL() {
"credits",
];
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
for (let cid in Cc) {
let result = cid.match(/@mozilla.org\/network\/protocol\/about;1\?what\=(.*)$/);
if (!result) {
@@ -152,7 +151,7 @@ add_task(async function test_aboutURL() {
let contract = "@mozilla.org/network/protocol/about;1?what=" + aboutType;
try {
let am = Cc[contract].getService(Ci.nsIAboutModule);
let uri = ios.newURI("about:" + aboutType);
let uri = Services.io.newURI("about:" + aboutType);
let flags = am.getURIFlags(uri);
// We load pages with URI_SAFE_FOR_UNTRUSTED_CONTENT set, this means they

View File

@@ -61,9 +61,7 @@ function doBefore() {
imageCache.clearCache(true);
imageCache.clearCache(false);
info("XXX clearning network cache");
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
Services.cache2.clear();
}
// the test function does nothing on purpose.

View File

@@ -70,9 +70,7 @@ function checkCacheExists(aShouldExist) {
}
add_task(async function setup() {
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
Services.cache2.clear();
});
// This will set the cookies and the cache.

View File

@@ -717,8 +717,7 @@ this.PlacesUIUtils = {
var uri = PlacesUtils._uri(aURINode.uri);
if (uri.schemeIs("javascript") || uri.schemeIs("data")) {
const BRANDING_BUNDLE_URI = "chrome://branding/locale/brand.properties";
var brandShortName = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
var brandShortName = Services.strings.
createBundle(BRANDING_BUNDLE_URI).
GetStringFromName("brandShortName");
@@ -861,8 +860,7 @@ this.PlacesUIUtils = {
var messageKey = "tabs.openWarningMultipleBranded";
var openKey = "tabs.openButtonMultiple";
const BRANDING_BUNDLE_URI = "chrome://branding/locale/brand.properties";
var brandShortName = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
var brandShortName = Services.strings.
createBundle(BRANDING_BUNDLE_URI).
GetStringFromName("brandShortName");

View File

@@ -620,9 +620,7 @@ var gEditItemOverlay = {
this._firstEditedField = aNewField;
// set the pref
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
prefs.setCharPref("browser.bookmarks.editDialog.firstEditField", aNewField);
Services.prefs.setCharPref("browser.bookmarks.editDialog.firstEditField", aNewField);
},
async onNamePickerChange() {

View File

@@ -476,9 +476,7 @@ var PlacesOrganizer = {
* Prompts for a file and restores bookmarks to those in the file.
*/
onRestoreBookmarksFromFile: function PO_onRestoreBookmarksFromFile() {
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
let backupsDir = dirSvc.get("Desk", Ci.nsIFile);
let backupsDir = Services.dirsvc.get("Desk", Ci.nsIFile);
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
let fpCallback = aResult => {
if (aResult != Ci.nsIFilePicker.returnCancel) {
@@ -507,9 +505,7 @@ var PlacesOrganizer = {
}
// confirm ok to delete existing bookmarks
var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService);
if (!prompts.confirm(null,
if (!Services.prompt.confirm(null,
PlacesUIUtils.getString("bookmarksRestoreAlertTitle"),
PlacesUIUtils.getString("bookmarksRestoreAlert")))
return;
@@ -527,9 +523,7 @@ var PlacesOrganizer = {
var brandShortName = document.getElementById("brandStrings").
getString("brandShortName");
Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService).
alert(window, brandShortName, aMsg);
Services.prompt.alert(window, brandShortName, aMsg);
},
/**
@@ -538,9 +532,7 @@ var PlacesOrganizer = {
* of those items.
*/
backupBookmarks: function PO_backupBookmarks() {
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
let backupsDir = dirSvc.get("Desk", Ci.nsIFile);
let backupsDir = Services.dirsvc.get("Desk", Ci.nsIFile);
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
let fpCallback = function fpCallback_done(aResult) {
if (aResult != Ci.nsIFilePicker.returnCancel) {

View File

@@ -36,8 +36,6 @@ const DIALOG_URL_MINIMAL_UI = "chrome://browser/content/places/bookmarkPropertie
Cu.import("resource:///modules/RecentWindow.jsm");
var win = RecentWindow.getMostRecentBrowserWindow();
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
function add_bookmark(url) {
return PlacesUtils.bookmarks.insert({
@@ -421,7 +419,7 @@ function open_properties_dialog(test) {
function windowObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowopened")
return;
ww.unregisterNotification(windowObserver);
Services.ww.unregisterNotification(windowObserver);
let observerWindow = aSubject.QueryInterface(Ci.nsIDOMWindow);
waitForFocus(async () => {
// Ensure overlay is loaded
@@ -435,7 +433,7 @@ function open_properties_dialog(test) {
}
}, observerWindow);
}
ww.registerNotification(windowObserver);
Services.ww.registerNotification(windowObserver);
var command = null;
switch (test.action) {

View File

@@ -3,9 +3,7 @@
// Instead of loading EventUtils.js into the test scope in browser-test.js for all tests,
// we only need EventUtils.js for a few files which is why we are using loadSubScript.
var EventUtils = {};
this._scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
Services.scriptloader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
add_task(async function test() {
// Make sure the bookmarks bar is visible and restore its state on cleanup.

View File

@@ -3,6 +3,8 @@
* 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/. */
/* import-globals-from ../../base/content/utilityOverlay.js */
var gConnectionsDialog = {
beforeAccept() {
var proxyTypePref = document.getElementById("network.proxy.type");
@@ -99,11 +101,8 @@ var gConnectionsDialog = {
var typedURL = document.getElementById("networkProxyAutoconfigURL").value;
var proxyTypeCur = document.getElementById("network.proxy.type").value;
var prefs =
Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
var pacURL = prefs.getCharPref("network.proxy.autoconfig_url");
var proxyType = prefs.getIntPref("network.proxy.type");
var pacURL = Services.prefs.getCharPref("network.proxy.autoconfig_url");
var proxyType = Services.prefs.getIntPref("network.proxy.type");
var disableReloadPref =
document.getElementById("pref.advanced.proxies.disable_button.reload");
@@ -168,10 +167,9 @@ var gConnectionsDialog = {
doAutoconfigURLFixup() {
var autoURL = document.getElementById("networkProxyAutoconfigURL");
var autoURLPref = document.getElementById("network.proxy.autoconfig_url");
var URIFixup = Components.classes["@mozilla.org/docshell/urifixup;1"]
.getService(Components.interfaces.nsIURIFixup);
try {
autoURLPref.value = autoURL.value = URIFixup.createFixupURI(autoURL.value, 0).spec;
autoURLPref.value = autoURL.value =
Services.uriFixup.createFixupURI(autoURL.value, 0).spec;
} catch (ex) {}
},

View File

@@ -16,18 +16,14 @@ XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService",
"resource://gre/modules/ContextualIdentityService.jsm");
var gCookiesWindow = {
_cm: Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager),
_hosts: {},
_hostOrder: [],
_tree: null,
_bundle: null,
init() {
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.addObserver(this, "cookie-changed");
os.addObserver(this, "perm-changed");
Services.obs.addObserver(this, "cookie-changed");
Services.obs.addObserver(this, "perm-changed");
this._bundle = document.getElementById("bundlePreferences");
this._tree = document.getElementById("cookiesList");
@@ -47,10 +43,8 @@ var gCookiesWindow = {
},
uninit() {
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.removeObserver(this, "cookie-changed");
os.removeObserver(this, "perm-changed");
Services.obs.removeObserver(this, "cookie-changed");
Services.obs.removeObserver(this, "perm-changed");
},
_populateList(aInitialLoad) {
@@ -475,7 +469,7 @@ var gCookiesWindow = {
},
_loadCookies() {
var e = this._cm.enumerator;
var e = Services.cookies.enumerator;
var hostCount = { value: 0 };
this._hosts = {};
this._hostOrder = [];
@@ -576,13 +570,11 @@ var gCookiesWindow = {
},
performDeletion: function gCookiesWindow_performDeletion(deleteItems) {
var psvc = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var blockFutureCookies = false;
if (psvc.prefHasUserValue("network.cookie.blockFutureCookies"))
blockFutureCookies = psvc.getBoolPref("network.cookie.blockFutureCookies");
if (Services.prefs.prefHasUserValue("network.cookie.blockFutureCookies"))
blockFutureCookies = Services.prefs.getBoolPref("network.cookie.blockFutureCookies");
for (let item of deleteItems) {
this._cm.remove(item.host, item.name, item.path,
Services.cookies.remove(item.host, item.name, item.path,
blockFutureCookies, item.originAttributes);
}
},
@@ -722,7 +714,7 @@ var gCookiesWindow = {
this._tree.treeBoxObject.rowCountChanged(0, -rowCount);
this.performDeletion(deleteItems);
} else {
this._cm.removeAll();
Services.cookies.removeAll();
}
this._updateRemoveAllButton();
this.focusFilterBox();

View File

@@ -16,7 +16,6 @@ Components.utils.import("resource://gre/modules/Downloads.jsm");
Components.utils.import("resource://gre/modules/FileUtils.jsm");
Components.utils.import("resource:///modules/ShellService.jsm");
Components.utils.import("resource:///modules/TransientPrefs.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/AppConstants.jsm");
Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
Components.utils.import("resource://gre/modules/LoadContextInfo.jsm");
@@ -149,9 +148,6 @@ var gMainPane = {
return this._filter = document.getElementById("filter");
},
_prefSvc: Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch),
_mimeSvc: Cc["@mozilla.org/mime;1"].
getService(Ci.nsIMIMEService),
@@ -161,9 +157,6 @@ var gMainPane = {
_handlerSvc: Cc["@mozilla.org/uriloader/handler-service;1"].
getService(Ci.nsIHandlerService),
_ioSvc: Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService),
_backoffIndex: 0,
/**
@@ -239,9 +232,7 @@ var gMainPane = {
if (AppConstants.platform == "win") {
// Functionality for "Show tabs in taskbar" on Windows 7 and up.
try {
let sysInfo = Cc["@mozilla.org/system-info;1"].
getService(Ci.nsIPropertyBag2);
let ver = parseFloat(sysInfo.getProperty("version"));
let ver = parseFloat(Services.sysinfo.getProperty("version"));
let showTabsInTaskbar = document.getElementById("showTabsInTaskbar");
showTabsInTaskbar.hidden = ver < 6.1;
} catch (ex) { }
@@ -399,22 +390,22 @@ var gMainPane = {
// Observe preferences that influence what we display so we can rebuild
// the view when they change.
this._prefSvc.addObserver(PREF_SHOW_PLUGINS_IN_LIST, this);
this._prefSvc.addObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this);
this._prefSvc.addObserver(PREF_FEED_SELECTED_APP, this);
this._prefSvc.addObserver(PREF_FEED_SELECTED_WEB, this);
this._prefSvc.addObserver(PREF_FEED_SELECTED_ACTION, this);
this._prefSvc.addObserver(PREF_FEED_SELECTED_READER, this);
Services.prefs.addObserver(PREF_SHOW_PLUGINS_IN_LIST, this);
Services.prefs.addObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this);
Services.prefs.addObserver(PREF_FEED_SELECTED_APP, this);
Services.prefs.addObserver(PREF_FEED_SELECTED_WEB, this);
Services.prefs.addObserver(PREF_FEED_SELECTED_ACTION, this);
Services.prefs.addObserver(PREF_FEED_SELECTED_READER, this);
this._prefSvc.addObserver(PREF_VIDEO_FEED_SELECTED_APP, this);
this._prefSvc.addObserver(PREF_VIDEO_FEED_SELECTED_WEB, this);
this._prefSvc.addObserver(PREF_VIDEO_FEED_SELECTED_ACTION, this);
this._prefSvc.addObserver(PREF_VIDEO_FEED_SELECTED_READER, this);
Services.prefs.addObserver(PREF_VIDEO_FEED_SELECTED_APP, this);
Services.prefs.addObserver(PREF_VIDEO_FEED_SELECTED_WEB, this);
Services.prefs.addObserver(PREF_VIDEO_FEED_SELECTED_ACTION, this);
Services.prefs.addObserver(PREF_VIDEO_FEED_SELECTED_READER, this);
this._prefSvc.addObserver(PREF_AUDIO_FEED_SELECTED_APP, this);
this._prefSvc.addObserver(PREF_AUDIO_FEED_SELECTED_WEB, this);
this._prefSvc.addObserver(PREF_AUDIO_FEED_SELECTED_ACTION, this);
this._prefSvc.addObserver(PREF_AUDIO_FEED_SELECTED_READER, this);
Services.prefs.addObserver(PREF_AUDIO_FEED_SELECTED_APP, this);
Services.prefs.addObserver(PREF_AUDIO_FEED_SELECTED_WEB, this);
Services.prefs.addObserver(PREF_AUDIO_FEED_SELECTED_ACTION, this);
Services.prefs.addObserver(PREF_AUDIO_FEED_SELECTED_READER, this);
setEventListener("filter", "command", gMainPane.filter);
setEventListener("handlersView", "select",
@@ -451,9 +442,7 @@ var gMainPane = {
]);
// Notify observers that the UI is now ready
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService)
.notifyObservers(window, "main-pane-loaded");
Services.obs.notifyObservers(window, "main-pane-loaded");
},
preInit() {
@@ -512,7 +501,7 @@ var gMainPane = {
document.getElementById("browserContainersbox").setAttribute("data-hidden-from-search", "true");
return;
}
this._prefSvc.addObserver(PREF_CONTAINERS_EXTENSION, this);
Services.prefs.addObserver(PREF_CONTAINERS_EXTENSION, this);
const link = document.getElementById("browserContainersLearnMore");
link.href = Services.urlFormatter.formatURLPref("app.support.baseURL") + "containers";
@@ -573,9 +562,7 @@ var gMainPane = {
onGetStarted(aEvent) {
if (AppConstants.MOZ_DEV_EDITION) {
const Cc = Components.classes, Ci = Components.interfaces;
let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator);
let win = wm.getMostRecentWindow("navigator:browser");
let win = Services.wm.getMostRecentWindow("navigator:browser");
fxAccounts.getSignedInUser().then(data => {
if (win) {
@@ -760,9 +747,7 @@ var gMainPane = {
var tabs = [];
const Cc = Components.classes, Ci = Components.interfaces;
var wm = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator);
win = wm.getMostRecentWindow("navigator:browser");
win = Services.wm.getMostRecentWindow("navigator:browser");
if (win && win.document.documentElement
.getAttribute("windowtype") == "navigator:browser") {
@@ -1333,24 +1318,24 @@ var gMainPane = {
destroy() {
window.removeEventListener("unload", this);
this._prefSvc.removeObserver(PREF_SHOW_PLUGINS_IN_LIST, this);
this._prefSvc.removeObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this);
this._prefSvc.removeObserver(PREF_FEED_SELECTED_APP, this);
this._prefSvc.removeObserver(PREF_FEED_SELECTED_WEB, this);
this._prefSvc.removeObserver(PREF_FEED_SELECTED_ACTION, this);
this._prefSvc.removeObserver(PREF_FEED_SELECTED_READER, this);
Services.prefs.removeObserver(PREF_SHOW_PLUGINS_IN_LIST, this);
Services.prefs.removeObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this);
Services.prefs.removeObserver(PREF_FEED_SELECTED_APP, this);
Services.prefs.removeObserver(PREF_FEED_SELECTED_WEB, this);
Services.prefs.removeObserver(PREF_FEED_SELECTED_ACTION, this);
Services.prefs.removeObserver(PREF_FEED_SELECTED_READER, this);
this._prefSvc.removeObserver(PREF_VIDEO_FEED_SELECTED_APP, this);
this._prefSvc.removeObserver(PREF_VIDEO_FEED_SELECTED_WEB, this);
this._prefSvc.removeObserver(PREF_VIDEO_FEED_SELECTED_ACTION, this);
this._prefSvc.removeObserver(PREF_VIDEO_FEED_SELECTED_READER, this);
Services.prefs.removeObserver(PREF_VIDEO_FEED_SELECTED_APP, this);
Services.prefs.removeObserver(PREF_VIDEO_FEED_SELECTED_WEB, this);
Services.prefs.removeObserver(PREF_VIDEO_FEED_SELECTED_ACTION, this);
Services.prefs.removeObserver(PREF_VIDEO_FEED_SELECTED_READER, this);
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_APP, this);
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_WEB, this);
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_ACTION, this);
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_READER, this);
Services.prefs.removeObserver(PREF_AUDIO_FEED_SELECTED_APP, this);
Services.prefs.removeObserver(PREF_AUDIO_FEED_SELECTED_WEB, this);
Services.prefs.removeObserver(PREF_AUDIO_FEED_SELECTED_ACTION, this);
Services.prefs.removeObserver(PREF_AUDIO_FEED_SELECTED_READER, this);
this._prefSvc.removeObserver(PREF_CONTAINERS_EXTENSION, this);
Services.prefs.removeObserver(PREF_CONTAINERS_EXTENSION, this);
},
@@ -1507,9 +1492,9 @@ var gMainPane = {
this._visibleTypeDescriptionCount = {};
// Get the preferences that help determine what types to show.
var showPlugins = this._prefSvc.getBoolPref(PREF_SHOW_PLUGINS_IN_LIST);
var showPlugins = Services.prefs.getBoolPref(PREF_SHOW_PLUGINS_IN_LIST);
var hidePluginsWithoutExtensions =
this._prefSvc.getBoolPref(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS);
Services.prefs.getBoolPref(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS);
for (let type in this._handledTypes) {
// Yield before processing each handler info object to avoid monopolizing
@@ -2248,7 +2233,7 @@ var gMainPane = {
},
_getIconURLForFile(aFile) {
var fph = this._ioSvc.getProtocolHandler("file").
var fph = Services.io.getProtocolHandler("file").
QueryInterface(Ci.nsIFileProtocolHandler);
var urlSpec = fph.getURLSpecFromFile(aFile);
@@ -2256,7 +2241,7 @@ var gMainPane = {
},
_getIconURLForWebApp(aWebAppURITemplate) {
var uri = this._ioSvc.newURI(aWebAppURITemplate);
var uri = Services.io.newURI(aWebAppURITemplate);
// Unfortunately we can't use the favicon service to get the favicon,
// because the service looks in the annotations table for a record with
@@ -2265,7 +2250,7 @@ var gMainPane = {
// they'll only visit URLs derived from that template (i.e. with %s
// in the template replaced by the URL of the content being handled).
if (/^https?$/.test(uri.scheme) && this._prefSvc.getBoolPref("browser.chrome.favicons"))
if (/^https?$/.test(uri.scheme) && Services.prefs.getBoolPref("browser.chrome.favicons"))
return uri.prePath + "/favicon.ico";
return "";
@@ -2485,9 +2470,7 @@ var gMainPane = {
var currentDirPref = document.getElementById("browser.download.dir");
// Used in defining the correct path to the folder icon.
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var fph = ios.getProtocolHandler("file")
var fph = Services.io.getProtocolHandler("file")
.QueryInterface(Components.interfaces.nsIFileProtocolHandler);
var iconUrlSpec;
@@ -2538,9 +2521,7 @@ var gMainPane = {
async _getDownloadsFolder(aFolder) {
switch (aFolder) {
case "Desktop":
var fileLoc = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
return fileLoc.get("Desk", Components.interfaces.nsIFile);
return Services.dirsvc.get("Desk", Components.interfaces.nsIFile);
case "Downloads":
let downloadsDir = await Downloads.getSystemDownloadsDirectory();
return new FileUtils.File(downloadsDir);
@@ -2741,9 +2722,6 @@ HandlerInfoWrapper.prototype = {
_handlerSvc: Cc["@mozilla.org/uriloader/handler-service;1"].
getService(Ci.nsIHandlerService),
_prefSvc: Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch),
_categoryMgr: Cc["@mozilla.org/categorymanager;1"].
getService(Ci.nsICategoryManager),
@@ -2940,8 +2918,8 @@ HandlerInfoWrapper.prototype = {
_getDisabledPluginTypes() {
var types = "";
if (this._prefSvc.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES))
types = this._prefSvc.getCharPref(PREF_DISABLED_PLUGIN_TYPES);
if (Services.prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES))
types = Services.prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES);
// Only split if the string isn't empty so we don't end up with an array
// containing a single empty string.
@@ -2957,7 +2935,7 @@ HandlerInfoWrapper.prototype = {
if (disabledPluginTypes.indexOf(this.type) == -1)
disabledPluginTypes.push(this.type);
this._prefSvc.setCharPref(PREF_DISABLED_PLUGIN_TYPES,
Services.prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES,
disabledPluginTypes.join(","));
// Update the category manager so existing browser windows update.
@@ -2972,7 +2950,7 @@ HandlerInfoWrapper.prototype = {
var type = this.type;
disabledPluginTypes = disabledPluginTypes.filter(v => v != type);
this._prefSvc.setCharPref(PREF_DISABLED_PLUGIN_TYPES,
Services.prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES,
disabledPluginTypes.join(","));
// Update the category manager so existing browser windows update.

View File

@@ -254,7 +254,6 @@ function confirmRestartPrompt(aRestartToEnable, aDefaultButtonIndex,
"featureDisableRequiresRestart",
[brandName]);
let title = bundle.getFormattedString("shouldRestartTitle", [brandName]);
let prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService);
// Set up the first (index 0) button:
let button0Text = bundle.getFormattedString("okToRestartButton", [brandName]);
@@ -295,7 +294,7 @@ function confirmRestartPrompt(aRestartToEnable, aDefaultButtonIndex,
break;
}
let buttonIndex = prompts.confirmEx(window, title, msg, buttonFlags,
let buttonIndex = Services.prompt.confirmEx(window, title, msg, buttonFlags,
button0Text, button1Text, button2Text,
null, {});

View File

@@ -322,9 +322,7 @@ var gPrivacyPane = {
]);
// Notify observers that the UI is now ready
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService)
.notifyObservers(window, "privacy-pane-loaded");
Services.obs.notifyObservers(window, "privacy-pane-loaded");
},
// TRACKING PROTECTION MODE
@@ -582,9 +580,7 @@ var gPrivacyPane = {
true, false);
if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) {
pref.value = autoStart.hasAttribute("checked");
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
.getService(Ci.nsIAppStartup);
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
return;
}
@@ -1002,10 +998,8 @@ var gPrivacyPane = {
var secmodDB = Cc["@mozilla.org/security/pkcs11moduledb;1"].
getService(Ci.nsIPKCS11ModuleDB);
if (secmodDB.isFIPSEnabled) {
var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService);
var bundle = document.getElementById("bundlePreferences");
promptService.alert(window,
Services.prompt.alert(window,
bundle.getString("pw_change_failed_title"),
bundle.getString("pw_change2empty_in_fips_mode"));
this._initMasterPasswordUI();
@@ -1250,9 +1244,7 @@ var gPrivacyPane = {
*/
clearCache() {
try {
var cache = Components.classes["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Components.interfaces.nsICacheStorageService);
cache.clear();
Services.cache2.clear();
} catch (ex) { }
this.updateActualCacheSize();
},
@@ -1332,10 +1324,7 @@ var gPrivacyPane = {
actualSizeLabel.textContent = prefStrBundle.getString("actualDiskCacheSizeCalculated");
try {
var cacheService =
Components.classes["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Components.interfaces.nsICacheStorageService);
cacheService.asyncGetDiskConsumption(this.observer);
Services.cache2.asyncGetDiskConsumption(this.observer);
} catch (e) { }
},
@@ -1486,11 +1475,7 @@ var gPrivacyPane = {
};
try {
var cacheService =
Components.classes["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Components.interfaces.nsICacheStorageService);
var storage = cacheService.appCacheStorage(LoadContextInfo.default, null);
storage.asyncVisitStorage(visitor, false);
Services.cache2.asyncVisitStorage(visitor, false);
} catch (e) { }
},
@@ -1529,9 +1514,6 @@ var gPrivacyPane = {
* Updates the list of offline applications
*/
updateOfflineApps() {
var pm = Components.classes["@mozilla.org/permissionmanager;1"]
.getService(Components.interfaces.nsIPermissionManager);
var list = document.getElementById("offlineAppsList");
while (list.firstChild) {
list.firstChild.remove();
@@ -1548,7 +1530,7 @@ var gPrivacyPane = {
var bundle = document.getElementById("bundlePreferences");
var enumerator = pm.enumerator;
var enumerator = Services.perms.enumerator;
while (enumerator.hasMoreElements()) {
var perm = enumerator.getNext().QueryInterface(Components.interfaces.nsIPermission);
if (perm.type == "offline-app" &&
@@ -1574,24 +1556,20 @@ var gPrivacyPane = {
var origin = item.getAttribute("origin");
var principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin);
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var flags = prompts.BUTTON_TITLE_IS_STRING * prompts.BUTTON_POS_0 +
prompts.BUTTON_TITLE_CANCEL * prompts.BUTTON_POS_1;
var flags = Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0 +
Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1;
var bundle = document.getElementById("bundlePreferences");
var title = bundle.getString("offlineAppRemoveTitle");
var prompt = bundle.getFormattedString("offlineAppRemovePrompt", [principal.URI.prePath]);
var confirm = bundle.getString("offlineAppRemoveConfirm");
var result = prompts.confirmEx(window, title, prompt, flags, confirm,
var result = Services.prompt.confirmEx(window, title, prompt, flags, confirm,
null, null, null, {});
if (result != 0)
return;
// get the permission
var pm = Components.classes["@mozilla.org/permissionmanager;1"]
.getService(Components.interfaces.nsIPermissionManager);
var perm = pm.getPermissionObject(principal, "offline-app", true);
var perm = Services.perms.getPermissionObject(principal, "offline-app", true);
if (perm) {
// clear offline cache entries
try {
@@ -1607,7 +1585,7 @@ var gPrivacyPane = {
}
} catch (e) { }
pm.removePermission(perm);
Services.perms.removePermission(perm);
}
list.removeChild(item);
gPrivacyPane.offlineAppSelected();

View File

@@ -156,9 +156,7 @@ var gSyncPane = {
this.updateWeavePrefs();
// Notify observers that the UI is now ready
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService)
.notifyObservers(window, "sync-pane-loaded");
Services.obs.notifyObservers(window, "sync-pane-loaded");
},
_toggleComputerNameControls(editMode) {

View File

@@ -11,11 +11,8 @@ function initTest() {
const searchTerm = "example";
const dummyTerm = "elpmaxe";
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager);
// delete all cookies (might be left over from other tests)
cm.removeAll();
Services.cookies.removeAll();
// data for cookies
var vals = [[searchTerm + ".com", dummyTerm, dummyTerm], // match
@@ -29,15 +26,13 @@ function initTest() {
// matches must correspond to above data
const matches = 6;
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var cookieSvc = Components.classes["@mozilla.org/cookieService;1"]
.getService(Components.interfaces.nsICookieService);
var v;
// inject cookies
for (v in vals) {
let [host, name, value] = vals[v];
var cookieUri = ios.newURI("http://" + host);
var cookieUri = Services.io.newURI("http://" + host);
cookieSvc.setCookieString(cookieUri, null, name + "=" + value + ";", null);
}
@@ -55,13 +50,9 @@ function isDisabled(win, expectation) {
}
function runTest(win, searchTerm, cookies, matches) {
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager);
// number of cookies should match injected cookies
var injectedCookies = 0,
injectedEnumerator = cm.enumerator;
injectedEnumerator = Services.cookies.enumerator;
while (injectedEnumerator.hasMoreElements()) {
injectedCookies++;
injectedEnumerator.getNext();
@@ -127,7 +118,7 @@ function runTest(win, searchTerm, cookies, matches) {
// check that datastore is also at 0
var remainingCookies = 0,
remainingEnumerator = cm.enumerator;
remainingEnumerator = Services.cookies.enumerator;
while (remainingEnumerator.hasMoreElements()) {
remainingCookies++;
remainingEnumerator.getNext();
@@ -141,4 +132,3 @@ function runTest(win, searchTerm, cookies, matches) {
win.close();
finish();
}

View File

@@ -65,16 +65,16 @@ var testRunner = {
{
expectPermObservancesDuringTestFunction: true,
test(params) {
let uri = params.ioService.newURI("http://test.com");
params.pm.add(uri, "popup", Ci.nsIPermissionManager.DENY_ACTION);
let uri = Services.io.newURI("http://test.com");
Services.perms.add(uri, "popup", Ci.nsIPermissionManager.DENY_ACTION);
is(params.tree.view.rowCount, 0, "adding unrelated permission should not change display");
params.btnApplyChanges.doCommand();
},
observances: [{ type: "popup", origin: "http://test.com", data: "added",
capability: Ci.nsIPermissionManager.DENY_ACTION }],
cleanUp(params) {
let uri = params.ioService.newURI("http://test.com");
params.pm.remove(uri, "popup");
let uri = Services.io.newURI("http://test.com");
Services.perms.remove(uri, "popup");
},
},
{
@@ -179,8 +179,8 @@ var testRunner = {
expectPermObservancesDuringTestFunction: true,
test(params) {
for (let URL of ["http://a", "http://z", "http://b"]) {
let URI = params.ioService.newURI(URL);
params.pm.add(URI, "cookie", Ci.nsIPermissionManager.ALLOW_ACTION);
let URI = Services.io.newURI(URL);
Services.perms.add(URI, "cookie", Ci.nsIPermissionManager.ALLOW_ACTION);
}
is(params.tree.view.rowCount, 3, "Three permissions should be present");
@@ -211,8 +211,8 @@ var testRunner = {
"site should be sorted. 'a' should be third");
for (let URL of ["http://a", "http://z", "http://b"]) {
let uri = params.ioService.newURI(URL);
params.pm.remove(uri, "cookie");
let uri = Services.io.newURI(URL);
Services.perms.remove(uri, "cookie");
}
},
},
@@ -251,10 +251,6 @@ var testRunner = {
btnBlock: doc.getElementById("btnBlock"),
btnApplyChanges: doc.getElementById("btnApplyChanges"),
btnRemove: doc.getElementById("removePermission"),
pm: Cc["@mozilla.org/permissionmanager;1"]
.getService(Ci.nsIPermissionManager),
ioService: Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService),
allowText: win.gPermissionManager._getCapabilityString(
Ci.nsIPermissionManager.ALLOW_ACTION),
denyText: win.gPermissionManager._getCapabilityString(
@@ -289,7 +285,7 @@ var testRunner = {
"property: \"origin\" should be equal");
}
os.removeObserver(permObserver, "perm-changed");
Services.obs.removeObserver(permObserver, "perm-changed");
let testCase = testRunner.tests[testRunner._currentTest];
if (!testCase.expectPermObservancesDuringTestFunction) {
@@ -303,10 +299,7 @@ var testRunner = {
},
};
let os = Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
os.addObserver(permObserver, "perm-changed");
Services.obs.addObserver(permObserver, "perm-changed");
if (testRunner._currentTest == 0) {
is(params.tree.view.rowCount, 0, "no cookie exceptions");

View File

@@ -4,19 +4,17 @@ const PM_URL = "chrome://passwordmgr/content/passwordManager.xul";
var passwordsDialog;
add_task(async function test_setup() {
let pwmgr = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager);
pwmgr.removeAllLogins();
Services.logins.removeAllLogins();
// add login data
let nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1",
Ci.nsILoginInfo, "init");
let login = new nsLoginInfo("http://example.com/", "http://example.com/", null,
"user", "password", "u1", "p1");
pwmgr.addLogin(login);
Services.logins.addLogin(login);
registerCleanupFunction(async function() {
pwmgr.removeAllLogins();
Services.logins.removeAllLogins();
});
});

View File

@@ -1,6 +1,3 @@
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
@@ -8,7 +5,7 @@ if (jar) {
rootDir = "file://" + tmpdir.path + "/";
}
/* import-globals-from privacypane_tests_perwindow.js */
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
run_test_subset([
test_pane_visibility,

View File

@@ -1,5 +1,3 @@
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
@@ -7,7 +5,7 @@ if (jar) {
rootDir = "file://" + tmpdir.path + "/";
}
/* import-globals-from privacypane_tests_perwindow.js */
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
run_test_subset([
test_custom_retention("rememberHistory", "remember"),

View File

@@ -1,7 +1,5 @@
requestLongerTimeout(2);
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
@@ -9,8 +7,8 @@ if (jar) {
rootDir = "file://" + tmpdir.path + "/";
}
/* import-globals-from privacypane_tests_perwindow.js */
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
let runtime = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
let runtime = Services.appInfo;
run_test_subset([
test_custom_retention("acceptCookies", "remember"),

View File

@@ -1,5 +1,3 @@
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
@@ -7,7 +5,7 @@ if (jar) {
rootDir = "file://" + tmpdir.path + "/";
}
/* import-globals-from privacypane_tests_perwindow.js */
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
run_test_subset([
test_locbar_suggestion_retention("history", true),

View File

@@ -1,5 +1,3 @@
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
@@ -7,7 +5,7 @@ if (jar) {
rootDir = "file://" + tmpdir.path + "/";
}
/* import-globals-from privacypane_tests_perwindow.js */
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
Services.scriptloader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
run_test_subset([
// history mode should be initialized to remember

View File

@@ -66,12 +66,10 @@ document.addEventListener("DOMContentLoaded", function() {
document.getElementById("startTour")
.addEventListener("click", dontShowIntroPanelAgain);
let formatURLPref = Cc["@mozilla.org/toolkit/URLFormatterService;1"]
.getService(Ci.nsIURLFormatter).formatURLPref;
document.getElementById("startTour").setAttribute("href",
formatURLPref("privacy.trackingprotection.introURL"));
Services.urlFormatter.formatURLPref("privacy.trackingprotection.introURL"));
document.getElementById("learnMore").setAttribute("href",
formatURLPref("app.support.baseURL") + "private-browsing");
Services.urlFormatter.formatURLPref("app.support.baseURL") + "private-browsing");
// Update state that depends on preferences.
prefObserver.observe();

View File

@@ -10,9 +10,7 @@ var {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInfo.jsm",
var tmp = {};
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://browser/content/sanitize.js", tmp);
Services.scriptloader.loadSubScript("chrome://browser/content/sanitize.js", tmp);
var Sanitizer = tmp.Sanitizer;
@@ -63,21 +61,14 @@ function sanitizeCache() {
s.sanitize();
}
function get_cache_service() {
return Components.classes["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Components.interfaces.nsICacheStorageService);
}
function getStorageEntryCount(device, goon) {
var cs = get_cache_service();
var storage;
switch (device) {
case "private":
storage = cs.diskCacheStorage(LoadContextInfo.private, false);
storage = Services.cache2.diskCacheStorage(LoadContextInfo.private, false);
break;
case "regular":
storage = cs.diskCacheStorage(LoadContextInfo.default, false);
storage = Services.cache2.diskCacheStorage(LoadContextInfo.default, false);
break;
default:
throw "Unknown device " + device + " at getStorageEntryCount";

View File

@@ -187,16 +187,12 @@ async function openTab(aBrowser, aURL) {
// A clean up function to prevent affecting other tests.
registerCleanupFunction(() => {
// Clear all cookies.
let cookieMgr = Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager);
cookieMgr.removeAll();
Services.cookies.removeAll();
// Clear all image caches and network caches.
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
Services.cache2.clear();
});
add_task(async function test_favicon_privateBrowsing() {
@@ -252,9 +248,7 @@ add_task(async function test_favicon_cache_privateBrowsing() {
// Clear all image cahces and network cache before running the test.
clearAllImageCaches();
let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
networkCache.clear();
Services.cache2.clear();
// Clear all favicons in Places.
await clearAllPlacesFavicons();

View File

@@ -23,10 +23,8 @@ registerCleanupFunction(function() {
function test() {
// initialization
waitForExplicitFinish();
let ds = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
let dir1 = ds.get("ProfD", Ci.nsIFile);
let dir2 = ds.get("TmpD", Ci.nsIFile);
let dir1 = Services.dirsvc.get("ProfD", Ci.nsIFile);
let dir2 = Services.dirsvc.get("TmpD", Ci.nsIFile);
let file = dir2.clone();
file.append("pbtest.file");
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);

View File

@@ -89,8 +89,7 @@ add_task(async function setup() {
[["privacy.resistFingerprinting", true]]
});
let appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
let appVersion = parseInt(appInfo.version);
let appVersion = parseInt(Services.appinfo.version);
let spoofedVersion = appVersion - ((appVersion - 3) % 7);
spoofedUserAgent = `Mozilla/5.0 (${SPOOFED_OSCPU}; rv:${spoofedVersion}.0) Gecko/20100101 Firefox/${spoofedVersion}.0`;
});

View File

@@ -4,9 +4,7 @@
// Instead of loading EventUtils.js into the test scope in browser-test.js for all tests,
// we only need EventUtils.js for a few files which is why we are using loadSubScript.
var EventUtils = {};
this._scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
Services.scriptloader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
const searchPopup = document.getElementById("PopupSearchAutoComplete");
const kValues = ["long text", "long text 2", "long text 3"];

View File

@@ -165,13 +165,12 @@ function restoreSession() {
// restore the session into a new window and close the current tab
var newWindow = top.openDialog(top.location, "_blank", "chrome,dialog=no,all");
var obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
obs.addObserver(function observe(win, topic) {
Services.obs.addObserver(function observe(win, topic) {
if (win != newWindow) {
return;
}
obs.removeObserver(observe, topic);
Services.obs.removeObserver(observe, topic);
ss.setWindowState(newWindow, stateString, true);
var tabbrowser = top.gBrowser;
@@ -181,8 +180,7 @@ function restoreSession() {
}
function startNewSession() {
var prefBranch = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
if (prefBranch.getIntPref("browser.startup.page") == 0)
if (Services.prefs.getIntPref("browser.startup.page") == 0)
getBrowserWindow().gBrowser.loadURI("about:blank");
else
getBrowserWindow().BrowserHome();
@@ -280,8 +278,7 @@ function restoreSingleTab(aIx, aShifted) {
ss.setTabState(newTab, JSON.stringify(tabState));
// respect the preference as to whether to select the tab (the Shift key inverses)
var prefBranch = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
if (prefBranch.getBoolPref("browser.tabs.loadInBackground") != !aShifted)
if (Services.prefs.getBoolPref("browser.tabs.loadInBackground") != !aShifted)
tabbrowser.selectedTab = newTab;
}

View File

@@ -10,9 +10,7 @@ function test() {
waitForExplicitFinish();
// read the sessionstore.js mtime (picked from browser_248970_a.js)
let profilePath = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).
get("ProfD", Ci.nsIFile);
let profilePath = Services.dirsvc.get("ProfD", Ci.nsIFile);
function getSessionstoreFile() {
let sessionStoreJS = profilePath.clone();
sessionStoreJS.append("sessionstore.jsonlz4");

View File

@@ -1,11 +1,10 @@
function test() {
var startup_info = Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(Components.interfaces.nsIAppStartup).getStartupInfo();
var startup_info = Services.startup.getStartupInfo();
// No .process info on mac
// Check if we encountered a telemetry error for the the process creation
// timestamp and turn the first test into a known failure.
var telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
var snapshot = telemetry.getHistogramById("STARTUP_MEASUREMENT_ERRORS")
var snapshot = Services.telemetry.getHistogramById("STARTUP_MEASUREMENT_ERRORS")
.snapshot();
if (snapshot.counts[0] == 0)

View File

@@ -3,6 +3,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://gre/modules/AppConstants.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
var Ci = Components.interfaces;
@@ -32,9 +33,7 @@ var gSetBackground = {
if (AppConstants.platform == "win") {
// Hide fill + fit options if < Win7 since they don't work.
var version = Components.classes["@mozilla.org/system-info;1"]
.getService(Ci.nsIPropertyBag2)
.getProperty("version");
var version = Services.sysinfo.getProperty("version");
var isWindows7OrHigher = (parseFloat(version) >= 6.1);
if (!isWindows7OrHigher) {
document.getElementById("fillPosition").hidden = true;
@@ -80,9 +79,7 @@ var gSetBackground = {
document.persist("menuPosition", "value");
this._shell.desktopBackgroundColor = this._hexStringToLong(this._backgroundColor);
} else {
Components.classes["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService)
.addObserver(this, "shell:desktop-background-changed");
Services.obs.addObserver(this, "shell:desktop-background-changed");
var bundle = document.getElementById("backgroundBundle");
var setDesktopBackground = document.getElementById("setDesktopBackground");
@@ -195,9 +192,7 @@ if (AppConstants.platform != "macosx") {
document.getElementById("setDesktopBackground").hidden = true;
document.getElementById("showDesktopPreferences").hidden = false;
Components.classes["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService)
.removeObserver(this, "shell:desktop-background-changed");
Services.obs.removeObserver(this, "shell:desktop-background-changed");
}
};

View File

@@ -6,9 +6,7 @@ const DG_DRAW_BG_KEY = DG_BACKGROUND + "/draw_background";
function onPageLoad() {
gBrowser.selectedBrowser.removeEventListener("load", onPageLoad, true);
var bs = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService);
var brandName = bs.createBundle("chrome://branding/locale/brand.properties").
var brandName = Services.strings.createBundle("chrome://branding/locale/brand.properties").
GetStringFromName("brandShortName");
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].

View File

@@ -7,8 +7,7 @@ Cu.import("resource://gre/modules/Services.jsm");
// Load mocking/stubbing library, sinon
// docs: http://sinonjs.org/docs/
/* global sinon */
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
loader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
registerCleanupFunction(function* () {
// Cleanup window or the test runner will throw an error

View File

@@ -400,9 +400,7 @@ function writeUpdatesToXMLFile(aText) {
const MODE_CREATE = 0x08;
const MODE_TRUNCATE = 0x20;
let file = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).
get("UpdRootD", Ci.nsIFile);
let file = Services.dirsvc.get("UpdRootD", Ci.nsIFile);
file.append("updates.xml");
let fos = Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);

View File

@@ -186,9 +186,7 @@
<body>
<![CDATA[
this.translation = aTranslation;
let bundle = Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Ci.nsIStringBundleService)
.createBundle("chrome://global/locale/languageNames.properties");
let bundle = Services.strings.createBundle("chrome://global/locale/languageNames.properties");
let sortByLocalizedName = function(aList) {
return aList.map(code => [code, bundle.GetStringFromName(code)])
.sort((a, b) => a[1].localeCompare(b[1]));
@@ -362,16 +360,12 @@
}
let langBundle =
Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Ci.nsIStringBundleService)
.createBundle("chrome://global/locale/languageNames.properties");
Services.strings.createBundle("chrome://global/locale/languageNames.properties");
let langName = langBundle.GetStringFromName(lang);
// Set the label and accesskey on the menuitem.
let bundle =
Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Ci.nsIStringBundleService)
.createBundle("chrome://browser/locale/translation.properties");
Services.strings.createBundle("chrome://browser/locale/translation.properties");
let item = this._getAnonElt("neverForLanguage");
const kStrId = "translation.options.neverForLanguage";
item.setAttribute("label",

View File

@@ -5,8 +5,7 @@ var gContentAPI;
var gContentWindow;
var setDefaultBrowserCalled = false;
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
Services.scriptloader
.loadSubScript("chrome://mochikit/content/tests/SimpleTest/MockObjects.js", this);
function MockShellService() {}

View File

@@ -43,10 +43,9 @@ var observer = SpecialPowers.wrapCallbackObject({
function getDialogDoc() {
// Find the <browser> which contains notifyWindow, by looking
// through all the open windows and all the <browsers> in each.
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
// var enumerator = wm.getEnumerator("navigator:browser");
var enumerator = wm.getXULWindowEnumerator(null);
var enumerator = Services.wm.getXULWindowEnumerator(null);
while (enumerator.hasMoreElements()) {
var win = enumerator.getNext();

View File

@@ -11,14 +11,12 @@ add_UITour_task(async function test_resetFirefox() {
let canReset = await getConfigurationPromise("canReset");
ok(!canReset, "Shouldn't be able to reset from mochitest's temporary profile.");
let dialogPromise = new Promise((resolve) => {
let winWatcher = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
winWatcher.registerNotification(function onOpen(subj, topic, data) {
Services.ww.registerNotification(function onOpen(subj, topic, data) {
if (topic == "domwindowopened" && subj instanceof Ci.nsIDOMWindow) {
subj.addEventListener("load", function() {
if (subj.document.documentURI ==
"chrome://global/content/resetProfile.xul") {
winWatcher.unregisterNotification(onOpen);
Services.ww.unregisterNotification(onOpen);
ok(true, "Observed search manager window open");
is(subj.opener, window,
"Reset Firefox event opened a reset profile window.");
@@ -44,4 +42,3 @@ add_UITour_task(async function test_resetFirefox() {
canReset = await getConfigurationPromise("canReset");
ok(!canReset, "Shouldn't be able to reset from mochitest's temporary profile once removed from the profile manager.");
});