--- a/browser/components/.eslintrc.js
+++ b/browser/components/.eslintrc.js
@@ -1,9 +1,11 @@
"use strict";
module.exports = {
rules: {
// 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",
}
};
--- a/browser/components/contextualidentity/test/browser/browser_aboutURLs.js
+++ b/browser/components/contextualidentity/test/browser/browser_aboutURLs.js
@@ -9,28 +9,27 @@ add_task(async function() {
// List of about: URLs that will initiate network requests.
let networkURLs = [
"credits",
"telemetry" // about:telemetry will fetch Telemetry asynchrounously and takes
// 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) {
continue;
}
let aboutType = result[1];
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) {
aboutURLs.push(aboutType);
}
} catch (e) {
// getService might have thrown if the component doesn't actually
// implement nsIAboutModule
--- a/browser/components/contextualidentity/test/browser/browser_forgetAPI_quota_clearStoragesForPrincipal.js
+++ b/browser/components/contextualidentity/test/browser/browser_forgetAPI_quota_clearStoragesForPrincipal.js
@@ -116,28 +116,23 @@ add_task(async function test_quota_clear
// Setup an entry for the indexedDB.
await setupIndexedDB(tabs[userContextId].browser);
// Close this tab.
await BrowserTestUtils.removeTab(tabs[userContextId].tab);
}
// 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",
- caUtils);
+ 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.
tabs[userContextId] = await openTabInUserContext(TEST_URL + "empty_file.html", userContextId);
// Check whether indexed DB has been cleared.
await checkIndexedDB(tabs[userContextId].browser);
--- a/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js
+++ b/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js
@@ -2,20 +2,16 @@
* Bug 1238183 - Test cases for forgetAboutSite with userContextId.
*/
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",
"personal",
];
const TEST_HOST = "example.com";
const TEST_URL = "http://" + TEST_HOST + "/browser/browser/components/contextualidentity/test/browser/";
const COOKIE_NAME = "userContextId";
@@ -67,28 +63,26 @@ async function openTabInUserContext(uri,
return {tab, browser};
}
function getCookiesForOA(host, userContextId) {
return Services.cookies.getCookiesFromHost(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;
}
function OpenCacheEntry(key, where, flags, lci) {
return new Promise(resolve => {
key = createURI(key);
function CacheListener() { }
@@ -161,41 +155,41 @@ async function test_cookie_cleared() {
// Cache
async function test_cache_cleared() {
// First, add some caches.
for (let userContextId of Object.keys(USER_CONTEXTS)) {
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");
}
// Forget the site.
await ForgetAboutSite.removeDataFromDomain(TEST_HOST);
// 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");
}
}
// Image Cache
async function test_image_cache_cleared() {
--- a/browser/components/distribution.js
+++ b/browser/components/distribution.js
@@ -26,23 +26,21 @@ XPCOMUtils.defineLazyModuleGetter(this,
this.DistributionCustomizer = function DistributionCustomizer() {
};
DistributionCustomizer.prototype = {
get _iniFile() {
// 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";
}
iniFile.append("distribution.ini");
} catch (ex) {}
this.__defineGetter__("_iniFile", () => iniFile);
return iniFile;
@@ -95,40 +93,16 @@ DistributionCustomizer.prototype = {
},
get _language() {
let language = this._locale.split("-")[0];
this.__defineGetter__("_language", () => language);
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*)/;
let items = {};
let defaultIndex = -1;
let maxIndex = -1;
for (let key of keys) {
@@ -206,18 +180,18 @@ DistributionCustomizer.prototype = {
case "livemark":
if (itemIndex < defaultIndex)
index = prependIndex++;
// 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;
case "bookmark":
default:
if (itemIndex < defaultIndex)
index = prependIndex++;
@@ -231,23 +205,23 @@ DistributionCustomizer.prototype = {
PlacesUtils.annotations.setItemAnnotation(bmId,
"bookmarkProperties/description",
item.description, 0,
PlacesUtils.annotations.EXPIRE_NEVER);
}
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) {
Cu.reportError(e);
}
}
if (item.keyword) {
@@ -273,18 +247,18 @@ DistributionCustomizer.prototype = {
this._newProfile = true;
if (!this._ini)
return this._checkCustomizationComplete();
// 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,
async applyBookmarks() {
await this._doApplyBookmarks();
this._bookmarksApplied = true;
this._checkCustomizationComplete();
},
@@ -308,26 +282,26 @@ DistributionCustomizer.prototype = {
try {
bmProcessedPref = this._ini.getString("Global",
"bookmarks.initialized.pref");
} catch (e) {
bmProcessedPref = "distribution." +
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)
await this._parseBookmarksSection(PlacesUtils.bookmarks.menuGuid,
"BookmarksMenu");
if (sections.BookmarksToolbar)
await this._parseBookmarksSection(PlacesUtils.bookmarks.toolbarGuid,
"BookmarksToolbar");
- this._prefs.setBoolPref(bmProcessedPref, true);
+ Services.prefs.setBoolPref(bmProcessedPref, true);
}
},
_prefDefaultsApplied: false,
applyPrefDefaults: function DIST_applyPrefDefaults() {
this._prefDefaultsApplied = true;
if (!this._ini)
return this._checkCustomizationComplete();
@@ -484,19 +458,17 @@ DistributionCustomizer.prototype = {
xulStore.setValue(BROWSER_DOCURL, "toolbar-menubar", "autohide", "false");
}
} catch (e) {}
}
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);
}
}
};
function parseValue(value) {
try {
value = JSON.parse(value);
} catch (e) {
--- a/browser/components/downloads/DownloadsCommon.jsm
+++ b/browser/components/downloads/DownloadsCommon.jsm
@@ -620,22 +620,21 @@ XPCOMUtils.defineLazyGetter(this.Downloa
XPCOMUtils.defineLazyGetter(this.DownloadsCommon, "error", () => {
return DownloadsLogger.error.bind(DownloadsLogger);
});
/**
* 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
/**
* Retrieves the list of past and completed downloads from the underlying
* Downloads API data, and provides asynchronous notifications allowing to
* build a consistent view of the available data.
--- a/browser/components/downloads/test/browser/browser_indicatorDrop.js
+++ b/browser/components/downloads/test/browser/browser_indicatorDrop.js
@@ -12,20 +12,18 @@ registerCleanupFunction(async function()
});
add_task(async function test_indicatorDrop() {
await SpecialPowers.pushPrefEnv({set: [["browser.download.autohideButton", false]]});
let downloadButton = document.getElementById("downloads-button");
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")}]];
let list = await Downloads.getList(Downloads.ALL);
let added = new Set();
let succeeded = new Set();
--- a/browser/components/downloads/test/browser/browser_libraryDrop.js
+++ b/browser/components/downloads/test/browser/browser_libraryDrop.js
@@ -7,20 +7,18 @@ XPCOMUtils.defineLazyModuleGetter(this,
"resource://testing-common/httpd.js");
registerCleanupFunction(async function() {
await task_resetState();
await PlacesUtils.history.clear();
});
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")}]];
let listBox = win.document.getElementById("downloadsRichListBox");
ok(listBox, "download list box present");
let list = await Downloads.getList(Downloads.ALL);
--- a/browser/components/extensions/ext-devtools.js
+++ b/browser/components/extensions/ext-devtools.js
@@ -306,18 +306,17 @@ initDevTools = function() {
if (!toolbox.target.isLocalTab) {
// Only local tabs are currently supported (See Bug 1304378 for additional details
// related to remote targets support).
let msg = `Ignoring DevTools Toolbox for target "${toolbox.target.toString()}": ` +
`"${toolbox.target.name}" ("${toolbox.target.url}"). ` +
"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;
}
for (let devtoolsPage of devtoolsPageDefinitionMap.values()) {
devtoolsPage.buildForToolbox(toolbox);
}
});
--- a/browser/components/extensions/ext-tabs.js
+++ b/browser/components/extensions/ext-tabs.js
@@ -1,27 +1,26 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
// 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",
"resource://gre/modules/PromiseUtils.jsm");
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;
let tabListener = {
tabReadyInitialized: false,
tabReadyPromises: new WeakMap(),
initializingTabs: new WeakSet(),
--- a/browser/components/extensions/test/browser/browser_ext_browsingData_indexedDB.js
+++ b/browser/components/extensions/test/browser/browser_ext_browsingData_indexedDB.js
@@ -43,23 +43,20 @@ add_task(async function testIndexedDB()
let win = await BrowserTestUtils.openNewBrowserWindow();
await focusWindow(win);
await extension.startup();
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")) {
origins.push(request.result[i].origin);
}
}
resolve(origins);
});
--- a/browser/components/extensions/test/browser/head.js
+++ b/browser/components/extensions/test/browser/head.js
@@ -61,18 +61,17 @@ function forceGC() {
}
function makeWidgetId(id) {
id = id.toLowerCase();
return id.replace(/[^a-z0-9_-]/g, "_");
}
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;
}
let promise = new Promise(resolve => {
win.addEventListener("focus", function() {
resolve();
}, {capture: true, once: true});
});
--- a/browser/components/feeds/FeedConverter.js
+++ b/browser/components/feeds/FeedConverter.js
@@ -86,27 +86,16 @@ function getPrefReaderForType(t) {
case Ci.nsIFeed.TYPE_AUDIO:
return PREF_AUDIO_SELECTED_READER;
default:
return PREF_SELECTED_READER;
}
}
-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 = {
classID: Components.ID("{229fa115-9412-4d32-baf3-2fc407f76fb1}"),
/**
* This is the downloaded text data for the feed.
*/
@@ -188,21 +177,21 @@ FeedConverter.prototype = {
// If this is just a feed, not some kind of specialized application, then
// auto-handlers can be set and we should obey them.
try {
let feedService =
Cc["@mozilla.org/browser/feeds/result-service;1"].
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 =
Cc["@mozilla.org/embeddor.implemented/web-content-handler-registrar;1"].
getService(Ci.nsIWebContentConverterService);
if ((feed.type == Ci.nsIFeed.TYPE_FEED &&
wccr.getAutoHandler(TYPE_MAYBE_FEED)) ||
(feed.type == Ci.nsIFeed.TYPE_VIDEO &&
@@ -225,19 +214,16 @@ FeedConverter.prototype = {
let desc = feed.subtitle ? feed.subtitle.plainText() : "";
feedService.addToClientReader(result.uri.spec, title, desc, feed.type, handler);
return;
} catch (ex) { /* fallback to preview mode */ }
}
}
}
- 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
// to the newchannel.
let oldChannel = this._request.QueryInterface(Ci.nsIChannel);
let loadInfo = oldChannel.loadInfo;
// If there was no automatic handler, or this was a podcast,
@@ -245,26 +231,26 @@ FeedConverter.prototype = {
// if the parser returned a document.
if (result.doc) {
// Store the result in the result service so that the display
// page can access it.
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.
chromeChannel.owner =
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;
chromeChannel.asyncOpen2(this._listener);
} finally {
this._releaseHandles();
}
},
@@ -369,17 +355,17 @@ FeedResultService.prototype = {
/**
* See nsIFeedResultService.idl
*/
addToClientReader(spec, title, subtitle, feedType, feedReader) {
if (!feedReader) {
feedReader = "default";
}
- let handler = safeGetCharPref(getPrefActionForType(feedType), "bookmarks");
+ let handler = Services.prefs.getCharPref(getPrefActionForType(feedType), "bookmarks");
if (handler == "ask" || handler == "reader")
handler = feedReader;
switch (handler) {
case "client":
Services.cpmm.sendAsyncMessage("FeedConverter:ExecuteClientApp",
{ spec,
title,
@@ -472,20 +458,17 @@ FeedResultService.prototype = {
/**
* A protocol handler that attempts to deal with the variant forms of feed:
* URIs that are actually either http or https.
*/
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;
},
get scheme() {
return this._scheme;
},
get protocolFlags() {
@@ -548,19 +531,17 @@ GenericProtocolHandler.prototype = {
let uri = Services.io.QueryInterface(Ci.nsINetUtil).newSimpleNestedURI(inner);
uri.spec = inner.spec.replace(prefix, scheme);
return uri;
},
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);
if (channel instanceof Components.interfaces.nsIHttpChannel)
// Set this so we know this is supposed to be a feed
channel.setRequestHeader("X-Moz-Is-Feed", "1", false);
channel.originalURI = aUri;
--- a/browser/components/feeds/FeedWriter.js
+++ b/browser/components/feeds/FeedWriter.js
@@ -12,36 +12,31 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
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");
}
/**
* Wrapper function for nsIIOService::newURI.
* @param aURLSpec
* The URL string from which to create an nsIURI.
* @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;
}
const XML_NS = "http://www.w3.org/XML/1998/namespace";
const HTML_NS = "http://www.w3.org/1999/xhtml";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
@@ -119,39 +114,35 @@ FeedWriter.prototype = {
* @param element
* The element to set a URI attribute on
* @param attribute
* The attribute of the element to set the URI to, e.g. href or src
* @param uri
* 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...
} catch (e) {
// Not allowed to load this link because secman.checkLoadURIStr threw
return;
}
element.setAttribute(attribute, uri);
},
__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;
},
_getFormattedString(key, params) {
return this._bundle.formatStringFromName(key, params, params.length);
},
@@ -487,19 +478,17 @@ FeedWriter.prototype = {
/**
* Get moz-icon url for a file
* @param file
* A nsIFile object for which the moz-icon:// is returned
* @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";
},
/**
* Displays a prompt from which the user may choose a (client) feed reader.
* @param aCallback the callback method, passes in true if a feed reader was
@@ -796,19 +785,17 @@ FeedWriter.prototype = {
this._feedURI = this._getOriginalURI(window);
if (!this._feedURI)
return;
this._window = window;
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);
this._mm.addMessageListener("FeedWriter:PreferenceUpdated", this);
this._mm.addMessageListener("FeedWriter:SetApplicationLauncherMenuItem", this);
this._mm.addMessageListener("FeedWriter:GetSubscriptionUIResponse", this);
this._mm.addMessageListener("FeedWriter:SetFeedPrefsAndSubscribeResponse", this);
--- a/browser/components/feeds/test/unit/head_feeds.js
+++ b/browser/components/feeds/test/unit/head_feeds.js
@@ -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");
--- a/browser/components/feeds/test/unit/test_355473.js
+++ b/browser/components/feeds/test/unit/test_355473.js
@@ -1,19 +1,19 @@
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,
loadUsingSystemPrincipal: true
});
var httpChannel = NetUtil.newChannel({
uri: httpFeedURI,
@@ -31,13 +31,13 @@ function run_test() {
do_check_true(httpsFeedURI.equals(httpsChannel.originalURI));
// actually using the horrible mess that's a feed: URI is suicidal
do_check_true(httpURI.equals(feedChannel.URI));
do_check_true(httpURI.equals(httpChannel.URI));
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");
}
--- a/browser/components/feeds/test/unit/test_758990.js
+++ b/browser/components/feeds/test/unit/test_758990.js
@@ -1,38 +1,38 @@
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;
}
if (!success)
do_throw("We didn't throw NS_ERROR_MALFORMED_URI creating a feed:javascript: URI");
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;
}
if (!success)
do_throw("We didn't throw NS_ERROR_MALFORMED_URI creating a feed:data: URI");
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;
}
if (!success)
do_throw("We didn't throw NS_ERROR_MALFORMED_URI creating a pcast:javascript: URI");
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;
}
if (!success)
do_throw("We didn't throw NS_ERROR_MALFORMED_URI creating a pcast:data: URI");
}
--- a/browser/components/migration/content/migration.js
+++ b/browser/components/migration/content/migration.js
@@ -53,18 +53,17 @@ var MigrationWizard = { /* exported Migr
document.getElementById("nothing").hidden = false;
}
}
this.onImportSourcePageShow();
},
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");
os.removeObserver(this, "Migration:ItemError");
os.removeObserver(this, "Migration:Ended");
MigrationUtils.finishMigration();
},
@@ -414,32 +413,26 @@ var MigrationWizard = { /* exported Migr
}
if (this._autoMigrate) {
let hasImportedHomepage = !!(this._newHomePage && this._newHomePage != "DEFAULT");
Services.telemetry.getKeyedHistogramById("FX_MIGRATION_IMPORTED_HOMEPAGE")
.add(this._source, hasImportedHomepage);
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",
- this._newHomePage);
+ 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);
}
}
// We're done now.
this._wiz.canAdvance = true;
this._wiz.advance();
@@ -472,19 +465,17 @@ var MigrationWizard = { /* exported Migr
break;
case Ci.nsIBrowserProfileMigrator.BOOKMARKS:
type = "bookmarks";
break;
case Ci.nsIBrowserProfileMigrator.OTHERDATA:
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;
}
},
onDonePageShow() {
this._wiz.getButton("cancel").disabled = true;
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -976,19 +976,17 @@ BrowserGlue.prototype = {
_onQuitApplicationGranted() {
// This pref must be set here because SessionStore will use its value
// on quit-application.
this._setPrefToSaveSession();
// 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);
}
if (this._bookmarksBackupIdleTime) {
this._idleService.removeIdleObserver(this, this._bookmarksBackupIdleTime);
delete this._bookmarksBackupIdleTime;
}
@@ -1376,25 +1374,23 @@ BrowserGlue.prototype = {
Cu.reportError("Unable to find update: " + e);
return;
}
var actions = update.getProperty("actions");
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,
aPropData.stringParams.length);
else
propValue = gBrowserBundle.GetStringFromName(aPropData.stringName);
}
return propValue;
@@ -1691,19 +1687,17 @@ BrowserGlue.prototype = {
var applicationName = gBrandBundle.GetStringFromName("brandShortName");
var placesBundle = Services.strings.createBundle("chrome://browser/locale/places/places.properties");
var title = placesBundle.GetStringFromName("lockPrompt.title");
var text = placesBundle.formatStringFromName("lockPrompt.text", [applicationName], 1);
var buttonText = placesBundle.GetStringFromName("lockPromptInfoButton.label");
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();
var buttons = [
{
label: buttonText,
accessKey,
--- a/browser/components/originattributes/test/browser/browser_cache.js
+++ b/browser/components/originattributes/test/browser/browser_cache.js
@@ -122,19 +122,17 @@ let stopObservingChannels;
// The init function, which clears image and network caches, and generates
// the random value for isolating video and audio elements across different
// test runs.
async function doInit(aMode) {
await SpecialPowers.pushPrefEnv({"set": [["network.predictor.enabled", false],
["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);
}
// In the test function, we dynamically generate the video and audio element,
// and assign a random suffix to their URL to isolate them across different
// test runs.
--- a/browser/components/originattributes/test/browser/browser_favicon_firstParty.js
+++ b/browser/components/originattributes/test/browser/browser_favicon_firstParty.js
@@ -249,36 +249,30 @@ add_task(async function setup() {
await SpecialPowers.pushPrefEnv({"set": [
["privacy.firstparty.isolate", true]
]});
});
// 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() {
for (let testThirdParty of [false, true]) {
// 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();
let cookies = await generateCookies(testThirdParty);
if (testThirdParty) {
await doTest(TEST_THIRD_PARTY_PAGE, cookies, THIRD_PARTY_SITE + FAVICON_URI);
@@ -287,19 +281,17 @@ add_task(async function test_favicon_fir
}
}
});
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);
// Start to observer for the favicon response of the first tab.
let responsePromise = waitOnFaviconResponse(THIRD_PARTY_SITE + TEST_FAVICON_CACHE_URI);
// Open the tab for the first site.
--- a/browser/components/originattributes/test/browser/browser_favicon_userContextId.js
+++ b/browser/components/originattributes/test/browser/browser_favicon_userContextId.js
@@ -206,52 +206,44 @@ add_task(async function setup() {
await SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true]
]});
});
// 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();
});
add_task(async function test_favicon_userContextId() {
// Clear all image caches before running the test.
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();
await doTest(TEST_PAGE, TEST_SITE, FAVICON_URI);
});
add_task(async function test_thirdPartyFavicon_userContextId() {
// Clear all image caches before running the test.
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();
await doTest(TEST_THIRD_PARTY_PAGE, TEST_THIRD_PARTY_SITE, THIRD_PARTY_FAVICON_URI);
});
--- a/browser/components/originattributes/test/browser/browser_firstPartyIsolation_aboutPages.js
+++ b/browser/components/originattributes/test/browser/browser_firstPartyIsolation_aboutPages.js
@@ -136,28 +136,27 @@ add_task(async function test_remote_wind
add_task(async function test_aboutURL() {
let aboutURLs = [];
// List of about: URLs that will initiate network requests.
let networkURLs = [
"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) {
continue;
}
let aboutType = result[1];
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
// are not loaded with System Principal but with codebase principal.
// Also we skip pages with HIDE_FROM_ABOUTABOUT, some of them may have
// errors while loading.
if ((flags & Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT) &&
!(flags & Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT) &&
--- a/browser/components/originattributes/test/browser/browser_imageCacheIsolation.js
+++ b/browser/components/originattributes/test/browser/browser_imageCacheIsolation.js
@@ -56,19 +56,17 @@ function doBefore() {
gHits = 0;
info("XXX clearing image cache");
let imageCache = Cc["@mozilla.org/image/tools;1"]
.getService(Ci.imgITools)
.getImgCacheForDocument(null);
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.
function doTest(aBrowser) {
return 0;
}
// the check function
--- a/browser/components/originattributes/test/browser/browser_sanitize.js
+++ b/browser/components/originattributes/test/browser/browser_sanitize.js
@@ -65,19 +65,17 @@ function checkCacheExists(aShouldExist)
let cacheURIs = await cacheDataForContext(loadContextInfo);
is(cacheURIs.includes(TEST_DOMAIN), aShouldExist, TEST_DOMAIN + " should "
+ (aShouldExist ? "not " : "") + "be cached for all origin attributes." + i++);
}
};
}
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.
IsolationTestTools.runTests(TEST_DOMAIN, setCookies, () => true);
add_task(checkCacheExists(true));
add_task(async function sanitize() {
--- a/browser/components/places/PlacesUIUtils.jsm
+++ b/browser/components/places/PlacesUIUtils.jsm
@@ -759,18 +759,17 @@ this.PlacesUIUtils = {
*/
checkURLSecurity: function PUIU_checkURLSecurity(aURINode, aWindow) {
if (PlacesUtils.nodeIsBookmark(aURINode))
return true;
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");
var errorStr = this.getString("load-js-data-url-error");
Services.prompt.alert(aWindow, brandShortName, errorStr);
return false;
}
return true;
@@ -905,18 +904,17 @@ this.PlacesUIUtils = {
if (Services.prefs.getBoolPref(WARN_ON_OPEN_PREF)) {
if (numTabsToOpen >= Services.prefs.getIntPref("browser.tabs.maxOpenBeforeWarn")) {
// default to true: if it were false, we wouldn't get this far
var warnOnOpen = { value: true };
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");
var buttonPressed = Services.prompt.confirmEx(
aWindow,
this.getString("tabs.openWarningTitle"),
this.getFormattedString(messageKey, [numTabsToOpen, brandShortName]),
(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0) +
--- a/browser/components/places/content/editBookmarkOverlay.js
+++ b/browser/components/places/content/editBookmarkOverlay.js
@@ -609,19 +609,17 @@ var gEditItemOverlay = {
// * if this._firstEditedField is already set, this is not the first field,
// so there's nothing to do
if (this._paneInfo.bulkTagging || this._firstEditedField)
return;
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() {
if (this.readOnly || !(this._paneInfo.isItem || this._paneInfo.isTag))
return;
// Here we update either the item title or its cached static title
let newTitle = this._namePicker.value;
--- a/browser/components/places/content/places.js
+++ b/browser/components/places/content/places.js
@@ -471,19 +471,17 @@ var PlacesOrganizer = {
}
},
/**
* Called when 'Choose File...' is selected from the restore menu.
* 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) {
this.restoreBookmarksFromFile(fp.file.path);
}
};
fp.init(window, PlacesUIUtils.getString("bookmarksRestoreTitle"),
@@ -502,50 +500,44 @@ var PlacesOrganizer = {
// check file extension
if (!aFilePath.toLowerCase().endsWith("json") &&
!aFilePath.toLowerCase().endsWith("jsonlz4")) {
this._showErrorAlert(PlacesUIUtils.getString("bookmarksRestoreFormatError"));
return;
}
// confirm ok to delete existing bookmarks
- var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].
- getService(Ci.nsIPromptService);
- if (!prompts.confirm(null,
- PlacesUIUtils.getString("bookmarksRestoreAlertTitle"),
- PlacesUIUtils.getString("bookmarksRestoreAlert")))
+ if (!Services.prompt.confirm(null,
+ PlacesUIUtils.getString("bookmarksRestoreAlertTitle"),
+ PlacesUIUtils.getString("bookmarksRestoreAlert")))
return;
(async function() {
try {
await BookmarkJSONUtils.importFromFile(aFilePath, true);
} catch (ex) {
PlacesOrganizer._showErrorAlert(PlacesUIUtils.getString("bookmarksRestoreParseError"));
}
})();
},
_showErrorAlert: function PO__showErrorAlert(aMsg) {
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);
},
/**
* Backup bookmarks to desktop, auto-generate a filename with a date.
* The file is a JSON serialization of bookmarks, tags and any annotations
* 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) {
// There is no OS.File version of the filepicker yet (Bug 937812).
PlacesBackups.saveBookmarksToJSONFile(fp.file.path);
}
};
--- a/browser/components/places/tests/browser/browser_bookmarksProperties.js
+++ b/browser/components/places/tests/browser/browser_bookmarksProperties.js
@@ -31,18 +31,16 @@ const TYPE_BOOKMARK = 1;
const TEST_URL = "http://www.example.com/";
const DIALOG_URL = "chrome://browser/content/places/bookmarkProperties.xul";
const DIALOG_URL_MINIMAL_UI = "chrome://browser/content/places/bookmarkProperties2.xul";
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({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url,
title: `bookmark/${url}`
});
}
@@ -416,31 +414,31 @@ function open_properties_dialog(test) {
test.selectNode(tree);
Assert.ok(tree.selectedNode,
"We have a places node selected: " + tree.selectedNode.title);
// Wait for the Properties dialog.
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
await BrowserTestUtils.waitForCondition(
() => observerWindow.gEditItemOverlay.initialized, "EditItemOverlay is initialized");
test.window = observerWindow;
try {
executeSoon(resolve);
} catch (ex) {
Assert.ok(false, "An error occured during test run: " + ex.message);
}
}, observerWindow);
}
- ww.registerNotification(windowObserver);
+ Services.ww.registerNotification(windowObserver);
var command = null;
switch (test.action) {
case ACTION_EDIT:
command = "placesCmd_show:info";
break;
case ACTION_ADD:
if (test.sidebar == SIDEBAR_BOOKMARKS_ID) {
--- a/browser/components/places/tests/browser/browser_toolbar_drop_text.js
+++ b/browser/components/places/tests/browser/browser_toolbar_drop_text.js
@@ -1,16 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// 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.
let toolbar = document.getElementById("PersonalToolbar");
ok(toolbar, "PersonalToolbar should not be null");
if (toolbar.collapsed) {
await promiseSetToolbarVisibility(toolbar, true);
--- a/browser/components/preferences/connection.js
+++ b/browser/components/preferences/connection.js
@@ -1,13 +1,15 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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");
if (proxyTypePref.value == 2) {
this.doAutoconfigURLFixup();
return true;
}
@@ -94,21 +96,18 @@ var gConnectionsDialog = {
// Disable the "Reload PAC" button if the selected proxy type is not PAC or
// if the current value of the PAC textbox does not match the value stored
// in prefs. Likewise, disable the reload button if PAC is not configured
// in prefs.
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");
disableReloadPref.disabled =
(proxyTypeCur != 2 || proxyType != 2 || typedURL != pacURL);
},
readProxyType() {
@@ -163,20 +162,19 @@ var gConnectionsDialog = {
reloadPAC() {
Components.classes["@mozilla.org/network/protocol-proxy-service;1"].
getService().reloadPAC();
},
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) {}
},
sanitizeNoProxiesPref() {
var noProxiesPref = document.getElementById("network.proxy.no_proxies_on");
// replace substrings of ; and \n with commas if they're neither immediately
// preceded nor followed by a valid separator character
noProxiesPref.value = noProxiesPref.value.replace(/([^, \n;])[;\n]+(?![,\n;])/g, "$1,");
--- a/browser/components/preferences/cookies.js
+++ b/browser/components/preferences/cookies.js
@@ -11,28 +11,24 @@ Components.utils.import("resource://gre/
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SiteDataManager",
"resource:///modules/SiteDataManager.jsm");
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");
let removeAllCookies = document.getElementById("removeAllCookies");
removeAllCookies.setAttribute("accesskey", this._bundle.getString("removeAllCookies.accesskey"));
let removeSelectedCookies = document.getElementById("removeSelectedCookies");
removeSelectedCookies.setAttribute("accesskey", this._bundle.getString("removeSelectedCookies.accesskey"));
@@ -42,20 +38,18 @@ var gCookiesWindow = {
document.getElementById("filter").focus();
if (!Services.prefs.getBoolPref("privacy.userContext.enabled")) {
document.getElementById("userContextRow").hidden = true;
}
},
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) {
this._loadCookies();
this._tree.view = this._view;
if (aInitialLoad)
this.sort("rawHost");
if (this._view.rowCount > 0)
@@ -470,17 +464,17 @@ var gCookiesWindow = {
expires: aCookie.expires,
level: 1,
container: false,
originAttributes: aCookie.originAttributes };
return c;
},
_loadCookies() {
- var e = this._cm.enumerator;
+ var e = Services.cookies.enumerator;
var hostCount = { value: 0 };
this._hosts = {};
this._hostOrder = [];
while (e.hasMoreElements()) {
var cookie = e.getNext();
if (cookie && cookie instanceof Components.interfaces.nsICookie) {
if (SiteDataManager.isPrivateCookie(cookie)) {
continue;
@@ -571,23 +565,21 @@ var gCookiesWindow = {
let removeSelectedCookies = document.getElementById("removeSelectedCookies");
removeSelectedCookies.label = PluralForm.get(selectedCookieCount, buttonLabel)
.replace("#1", selectedCookieCount);
removeSelectedCookies.disabled = !(seln.count > 0);
},
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);
}
},
deleteCookie() {
// Selection Notes
// - Selection always moves to *NEXT* adjacent item unless item
// is last child at a given level in which case it moves to *PREVIOUS*
@@ -717,17 +709,17 @@ var gCookiesWindow = {
for (let index = 0; index < rowCount; index++) {
deleteItems.push(this._view._getItemAtIndex(index));
}
this._view._removeItemAtIndex(0, rowCount);
this._view._rowCount = 0;
this._tree.treeBoxObject.rowCountChanged(0, -rowCount);
this.performDeletion(deleteItems);
} else {
- this._cm.removeAll();
+ Services.cookies.removeAll();
}
this._updateRemoveAllButton();
this.focusFilterBox();
},
onCookieKeyPress(aEvent) {
if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE ||
(AppConstants.platform == "macosx" &&
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -11,17 +11,16 @@ XPCOMUtils.defineLazyModuleGetter(this,
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
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");
XPCOMUtils.defineLazyModuleGetter(this, "CloudStorage",
"resource://gre/modules/CloudStorage.jsm");
// Constants & Enumeration Values
const TYPE_MAYBE_FEED = "application/vnd.mozilla.maybe.feed";
@@ -149,31 +148,25 @@ var gMainPane = {
return this._list = document.getElementById("handlersView");
},
get _filter() {
delete this._filter;
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),
_helperAppSvc: Cc["@mozilla.org/uriloader/external-helper-app-service;1"].
getService(Ci.nsIExternalHelperAppService),
_handlerSvc: Cc["@mozilla.org/uriloader/handler-service;1"].
getService(Ci.nsIHandlerService),
- _ioSvc: Cc["@mozilla.org/network/io-service;1"].
- getService(Ci.nsIIOService),
-
_backoffIndex: 0,
/**
* Initialization of this.
*/
init() {
function setEventListener(aId, aEventType, aCallback) {
document.getElementById(aId)
@@ -239,19 +232,17 @@ var gMainPane = {
Services.obs.addObserver(newTabObserver, "newtab-url-changed");
window.addEventListener("unload", () => {
Services.obs.removeObserver(newTabObserver, "newtab-url-changed");
});
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) { }
}
// The "closing multiple tabs" and "opening multiple tabs might slow down
// &brandShortName;" warnings provide options for not showing these
// warnings again. When the user disabled them, we provide checkboxes to
@@ -419,32 +410,32 @@ var gMainPane = {
setEventListener("showUpdateHistory", "command",
gMainPane.showUpdates);
}
// Initilize Application section.
// 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);
-
- 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);
-
- 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_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);
+
+ 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);
+
+ 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",
gMainPane.onSelectionChanged);
setEventListener("typeColumn", "click", gMainPane.sort);
setEventListener("actionColumn", "click", gMainPane.sort);
setEventListener("chooseFolder", "command", gMainPane.chooseFolder);
setEventListener("browser.download.dir", "change", gMainPane.displayDownloadDirPref);
@@ -471,19 +462,17 @@ var gMainPane = {
appendSearchKeywords("browserContainersSettings", [
browserBundle.getString("userContextPersonal.label"),
browserBundle.getString("userContextWork.label"),
browserBundle.getString("userContextBanking.label"),
browserBundle.getString("userContextShopping.label"),
]);
// 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() {
promiseLoadHandlersList = new Promise((resolve, reject) => {
// Load the data and build the list of handlers for applications pane.
// By doing this after pageshow, we ensure it doesn't delay painting
// of the preferences page.
window.addEventListener("pageshow", async () => {
@@ -532,17 +521,17 @@ var gMainPane = {
initBrowserContainers() {
if (!Services.prefs.getBoolPref("privacy.userContext.ui.enabled")) {
// The browserContainersGroup element has its own internal padding that
// is visible even if the browserContainersbox is visible, so hide the whole
// groupbox if the feature is disabled to prevent a gap in the preferences.
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";
document.getElementById("browserContainersbox").hidden = false;
this.readBrowserContainersCheckbox();
},
@@ -641,19 +630,17 @@ var gMainPane = {
createOrRemoveSpecialDevEditionFile();
}
}
},
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) {
if (data) {
// We have a user, open Sync preferences in the same tab
win.openUILinkIn("about:preferences#sync", "current");
return;
}
@@ -819,19 +806,17 @@ var gMainPane = {
useCurrent.disabled = !tabs.length;
},
_getTabsForHomePage() {
var win;
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") {
// We should only include visible & non-pinned tabs
tabs = win.gBrowser.visibleTabs.slice(win.gBrowser._numPinnedTabs);
tabs = tabs.filter(this.isNotAboutPreferences);
}
@@ -1404,34 +1389,34 @@ var gMainPane = {
* Displays the history of installed updates.
*/
showUpdates() {
gSubDialog.open("chrome://mozapps/content/update/history.xul");
},
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);
-
- 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);
-
- 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);
-
- this._prefSvc.removeObserver(PREF_CONTAINERS_EXTENSION, 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);
+
+ 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);
+
+ 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);
+
+ Services.prefs.removeObserver(PREF_CONTAINERS_EXTENSION, this);
},
// nsISupports
QueryInterface(aIID) {
if (aIID.equals(Ci.nsIObserver) ||
aIID.equals(Ci.nsIDOMEventListener ||
@@ -1578,19 +1563,19 @@ var gMainPane = {
// View Construction
async _rebuildVisibleTypes() {
// Reset the list of visible types and the visible type description counts.
this._visibleTypes = [];
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
// the main thread, as the objects are retrieved lazily, and retrieval
// can be expensive on Windows.
await new Promise(resolve => Services.tm.dispatchToMainThread(resolve));
let handlerInfo = this._handledTypes[type];
@@ -2319,34 +2304,34 @@ var gMainPane = {
if (aHandlerApp instanceof Ci.nsIWebContentHandlerInfo)
return this._getIconURLForWebApp(aHandlerApp.uri);
// We know nothing about other kinds of handler apps.
return "";
},
_getIconURLForFile(aFile) {
- var fph = this._ioSvc.getProtocolHandler("file").
+ var fph = Services.io.getProtocolHandler("file").
QueryInterface(Ci.nsIFileProtocolHandler);
var urlSpec = fph.getURLSpecFromFile(aFile);
return "moz-icon://" + urlSpec + "?size=16";
},
_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
// the exact URL we give it, and users won't have such records for URLs
// they don't visit, and users won't visit the web app's URL template,
// 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 "";
},
_getIconURLForSystemDefault(aHandlerInfo) {
// Handler info objects for MIME types on some OSes implement a property bag
// interface from which we can get an icon for the default app, so if we're
@@ -2556,19 +2541,17 @@ var gMainPane = {
async displayDownloadDirPrefTask() {
var folderListPref = document.getElementById("browser.download.folderList");
var bundlePreferences = document.getElementById("bundlePreferences");
var downloadFolder = document.getElementById("downloadFolder");
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;
let folderIndex = folderListPref.value;
if (folderIndex == 3) {
// When user has selected cloud storage, use value in currentDirPref to
// compute index to display download folder label and icon to avoid
// displaying blank downloadFolder label and icon on load of preferences UI
@@ -2609,19 +2592,17 @@ var gMainPane = {
* the XPCOM directory service via the download manager's attribute
* defaultDownloadsDirectory.
*
* @throws if aFolder is not "Desktop" or "Downloads"
*/
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);
}
throw "ASSERTION FAILED: folder type should be 'Desktop' or 'Downloads'";
},
/**
@@ -2812,19 +2793,16 @@ HandlerInfoWrapper.prototype = {
wrappedHandlerInfo: null,
// Convenience Utils
_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),
element(aID) {
return document.getElementById(aID);
},
@@ -3011,49 +2989,49 @@ HandlerInfoWrapper.prototype = {
get isDisabledPluginType() {
return this._getDisabledPluginTypes().indexOf(this.type) != -1;
},
_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.
if (types != "")
return types.split(",");
return [];
},
disablePluginType() {
var disabledPluginTypes = this._getDisabledPluginTypes();
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.
this._categoryMgr.deleteCategoryEntry("Gecko-Content-Viewers",
this.type,
false);
},
enablePluginType() {
var disabledPluginTypes = this._getDisabledPluginTypes();
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.
this._categoryMgr.
addCategoryEntry("Gecko-Content-Viewers",
this.type,
"@mozilla.org/content/plugin/document-loader-factory;1",
false,
--- a/browser/components/preferences/in-content/preferences.js
+++ b/browser/components/preferences/in-content/preferences.js
@@ -249,17 +249,16 @@ function confirmRestartPrompt(aRestartTo
aWantRestartLaterButton) {
let brandName = document.getElementById("bundleBrand").getString("brandShortName");
let bundle = document.getElementById("bundlePreferences");
let msg = bundle.getFormattedString(aRestartToEnable ?
"featureEnableRequiresRestart" :
"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]);
let buttonFlags = (Services.prompt.BUTTON_POS_0 *
Services.prompt.BUTTON_TITLE_IS_STRING);
// Set up the second (index 1) button:
@@ -290,19 +289,19 @@ function confirmRestartPrompt(aRestartTo
break;
case 2:
buttonFlags += Services.prompt.BUTTON_POS_2_DEFAULT;
break;
default:
break;
}
- let buttonIndex = prompts.confirmEx(window, title, msg, buttonFlags,
- button0Text, button1Text, button2Text,
- null, {});
+ let buttonIndex = Services.prompt.confirmEx(window, title, msg, buttonFlags,
+ button0Text, button1Text, button2Text,
+ null, {});
// If we have the second confirmation dialog for restart, see if the user
// cancels out at that point.
if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) {
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
.createInstance(Ci.nsISupportsPRBool);
Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
"restart");
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -310,19 +310,17 @@ var gPrivacyPane = {
]);
appendSearchKeywords("siteDataSettings", [
bundlePrefs.getString("siteDataSettings2.description"),
bundlePrefs.getString("removeAllCookies.label"),
bundlePrefs.getString("removeSelectedCookies.label"),
]);
// 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
/**
* Selects the right item of the Tracking Protection radiogroup.
*/
trackingProtectionReadPrefs() {
@@ -570,19 +568,17 @@ var gPrivacyPane = {
// We're performing a revert. Just let it happen.
return;
}
let buttonIndex = confirmRestartPrompt(autoStart.checked, 1,
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;
}
this._shouldPromptForRestart = false;
if (this._lastCheckState) {
autoStart.checked = "checked";
} else {
@@ -990,20 +986,18 @@ var gPrivacyPane = {
* Displays the "remove master password" dialog to allow the user to remove
* the current master password. When the dialog is dismissed, master password
* UI is automatically updated.
*/
_removeMasterPassword() {
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();
} else {
gSubDialog.open("chrome://mozapps/content/preferences/removemp.xul",
null, null, this._initMasterPasswordUI.bind(this));
}
},
@@ -1238,19 +1232,17 @@ var gPrivacyPane = {
gSubDialog.open("chrome://pippki/content/device_manager.xul");
},
/**
* Clears the cache.
*/
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();
},
showOfflineExceptions() {
var bundlePreferences = document.getElementById("bundlePreferences");
var params = {
blockVisible: false,
@@ -1320,20 +1312,17 @@ var gPrivacyPane = {
Components.interfaces.nsICacheStorageConsumptionObserver,
Components.interfaces.nsISupportsWeakReference
])
};
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) { }
},
updateCacheSizeUI(smartSizeEnabled) {
document.getElementById("useCacheBefore").disabled = smartSizeEnabled;
document.getElementById("cacheSize").disabled = smartSizeEnabled;
document.getElementById("useCacheAfter").disabled = smartSizeEnabled;
},
@@ -1474,21 +1463,17 @@ var gPrivacyPane = {
return;
}
var sizeStr = prefStrBundle.getFormattedString("actualAppCacheSize", sizeStrings);
actualSizeLabel.value = sizeStr;
}
};
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) { }
},
readOfflineNotify() {
var pref = document.getElementById("browser.offline-apps.notify");
var button = document.getElementById("offlineNotifyExceptions");
button.disabled = !pref.value;
return pref.value;
@@ -1517,36 +1502,33 @@ var gPrivacyPane = {
return usage;
},
/**
* 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();
}
var groups;
try {
var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
getService(Components.interfaces.nsIApplicationCacheService);
groups = cacheService.getGroups();
} catch (e) {
return;
}
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" &&
perm.capability != Components.interfaces.nsIPermissionManager.DEFAULT_ACTION &&
perm.capability != Components.interfaces.nsIPermissionManager.DENY_ACTION) {
var row = document.createElement("listitem");
row.id = "";
row.className = "offlineapp";
@@ -1562,50 +1544,46 @@ var gPrivacyPane = {
},
removeOfflineApp() {
var list = document.getElementById("offlineAppsList");
var item = list.selectedItem;
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 {
var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
getService(Components.interfaces.nsIApplicationCacheService);
var groups = cacheService.getGroups();
for (var i = 0; i < groups.length; i++) {
var uri = Services.io.newURI(groups[i]);
if (perm.matchesURI(uri, true)) {
var cache = cacheService.getActiveCache(groups[i]);
cache.discard();
}
}
} catch (e) { }
- pm.removePermission(perm);
+ Services.perms.removePermission(perm);
}
list.removeChild(item);
gPrivacyPane.offlineAppSelected();
this.updateActualAppCacheSize();
},
// Methods for Offline Apps (AppCache) end
observe(aSubject, aTopic, aData) {
--- a/browser/components/preferences/in-content/sync.js
+++ b/browser/components/preferences/in-content/sync.js
@@ -151,19 +151,17 @@ var gSyncPane = {
fxAccounts.promiseAccountsManageURI(this._getEntryPoint()).then(accountsManageURI => {
document.getElementById("verifiedManage").setAttribute("href", accountsManageURI);
});
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) {
let textbox = document.getElementById("fxaSyncComputerName");
textbox.disabled = !editMode;
document.getElementById("fxaChangeDeviceName").hidden = editMode;
document.getElementById("fxaCancelChangeDeviceName").hidden = !editMode;
document.getElementById("fxaSaveChangeDeviceName").hidden = !editMode;
--- a/browser/components/preferences/in-content/tests/browser_bug705422.js
+++ b/browser/components/preferences/in-content/tests/browser_bug705422.js
@@ -6,43 +6,38 @@ function test() {
// Allow all cookies, then actually set up the test
SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 0]]}, initTest);
}
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
[searchTerm + ".org", dummyTerm, dummyTerm], // match
[dummyTerm + ".com", searchTerm, dummyTerm], // match
[dummyTerm + ".edu", searchTerm + dummyTerm, dummyTerm], // match
[dummyTerm + ".net", dummyTerm, searchTerm], // match
[dummyTerm + ".org", dummyTerm, searchTerm + dummyTerm], // match
[dummyTerm + ".int", dummyTerm, dummyTerm]]; // no match
// 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);
}
// open cookie manager
var cmd = window.openDialog("chrome://browser/content/preferences/cookies.xul",
"Browser:Cookies", "", {});
// when it has loaded, run actual tests
@@ -50,23 +45,19 @@ function initTest() {
}
function isDisabled(win, expectation) {
var disabled = win.document.getElementById("removeAllCookies").disabled;
is(disabled, expectation, "Remove all cookies button has correct state: " + (expectation ? "disabled" : "enabled"));
}
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();
}
is(injectedCookies, cookies, "Number of cookies match injected cookies");
// "delete all cookies" should be enabled
isDisabled(win, false);
@@ -122,23 +113,22 @@ function runTest(win, searchTerm, cookie
isDisabled(win, false);
// delete all cookies and count should be 0
EventUtils.synthesizeMouseAtCenter(deleteAllButton, {}, win);
is(win.gCookiesWindow._view.rowCount, 0, "Deleted all cookies");
// check that datastore is also at 0
var remainingCookies = 0,
- remainingEnumerator = cm.enumerator;
+ remainingEnumerator = Services.cookies.enumerator;
while (remainingEnumerator.hasMoreElements()) {
remainingCookies++;
remainingEnumerator.getNext();
}
is(remainingCookies, 0, "Zero cookies remain");
// "delete all cookies" should be disabled
isDisabled(win, true);
// clean up
win.close();
finish();
}
-
--- a/browser/components/preferences/in-content/tests/browser_cookies_exceptions.js
+++ b/browser/components/preferences/in-content/tests/browser_cookies_exceptions.js
@@ -60,26 +60,26 @@ var testRunner = {
is(params.tree.view.rowCount, 0, "exception should be removed");
params.btnApplyChanges.doCommand();
},
observances: [{ type: "cookie", origin: "http://test.com", data: "deleted" }],
},
{
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");
},
},
{
test(params) {
params.url.value = "https://test.com:12345";
params.btnAllow.doCommand();
is(params.tree.view.rowCount, 1, "added exception shows up in treeview");
is(params.tree.view.getCellText(0, params.nameCol), "https://test.com:12345",
@@ -174,18 +174,18 @@ var testRunner = {
params.btnApplyChanges.doCommand();
},
observances: [{ type: "cookie", origin: "http://localhost:12345", data: "deleted" }],
},
{
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");
is(params.tree.view.getCellText(0, params.nameCol), "http://a",
"site should be sorted. 'a' should be first");
is(params.tree.view.getCellText(1, params.nameCol), "http://b",
"site should be sorted. 'b' should be second");
is(params.tree.view.getCellText(2, params.nameCol), "http://z",
@@ -206,18 +206,18 @@ var testRunner = {
is(params.tree.view.getCellText(0, params.nameCol), "http://z",
"site should be sorted. 'z' should be first");
is(params.tree.view.getCellText(1, params.nameCol), "http://b",
"site should be sorted. 'b' should be second");
is(params.tree.view.getCellText(2, params.nameCol), "http://a",
"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");
}
},
},
],
_currentTest: -1,
runTests() {
@@ -246,20 +246,16 @@ var testRunner = {
tree: doc.getElementById("permissionsTree"),
nameCol: doc.getElementById("permissionsTree").treeBoxObject.columns.getColumnAt(0),
statusCol: doc.getElementById("permissionsTree").treeBoxObject.columns.getColumnAt(1),
url: doc.getElementById("url"),
btnAllow: doc.getElementById("btnAllow"),
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(
Ci.nsIPermissionManager.DENY_ACTION),
allow: Ci.nsIPermissionManager.ALLOW_ACTION,
deny: Ci.nsIPermissionManager.DENY_ACTION,
};
@@ -284,34 +280,31 @@ var testRunner = {
"property: \"" + prop + "\" should be equal");
}
if (expected.origin) {
is(permission.principal.origin, expected.origin,
"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) {
if (testCase.cleanUp) {
testCase.cleanUp(params);
}
gBrowser.removeCurrentTab();
resolve();
}
},
};
- 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");
}
try {
let testCase = testRunner.tests[testRunner._currentTest];
testCase.test(params);
--- a/browser/components/preferences/in-content/tests/browser_password_management.js
+++ b/browser/components/preferences/in-content/tests/browser_password_management.js
@@ -1,27 +1,25 @@
"use strict";
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();
});
});
add_task(async function test_openPasswordSubDialog() {
// Undo the save password change.
registerCleanupFunction(async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
let doc = content.document;
--- a/browser/components/preferences/in-content/tests/browser_privacypane_1.js
+++ b/browser/components/preferences/in-content/tests/browser_privacypane_1.js
@@ -1,19 +1,16 @@
-let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
- getService(Ci.mozIJSSubScriptLoader);
-
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(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,
test_dependent_elements,
test_dependent_cookie_elements,
test_dependent_clearonclose_elements,
test_dependent_prefs,
]);
--- a/browser/components/preferences/in-content/tests/browser_privacypane_3.js
+++ b/browser/components/preferences/in-content/tests/browser_privacypane_3.js
@@ -1,18 +1,16 @@
-let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
- getService(Ci.mozIJSSubScriptLoader);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(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"),
test_custom_retention("rememberHistory", "custom"),
test_custom_retention("rememberForms", "custom"),
test_custom_retention("rememberForms", "custom"),
test_historymode_retention("remember", "custom"),
]);
--- a/browser/components/preferences/in-content/tests/browser_privacypane_4.js
+++ b/browser/components/preferences/in-content/tests/browser_privacypane_4.js
@@ -1,21 +1,19 @@
requestLongerTimeout(2);
-let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
- getService(Ci.mozIJSSubScriptLoader);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(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"),
test_custom_retention("acceptCookies", "custom"),
test_custom_retention("acceptThirdPartyMenu", "custom", "visited"),
test_custom_retention("acceptThirdPartyMenu", "custom", "always"),
test_custom_retention("keepCookiesUntil", "custom", 1),
test_custom_retention("keepCookiesUntil", "custom", 2),
--- a/browser/components/preferences/in-content/tests/browser_privacypane_5.js
+++ b/browser/components/preferences/in-content/tests/browser_privacypane_5.js
@@ -1,18 +1,16 @@
-let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
- getService(Ci.mozIJSSubScriptLoader);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(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),
test_locbar_suggestion_retention("bookmark", true),
test_locbar_suggestion_retention("openpage", false),
test_locbar_suggestion_retention("history", true),
test_locbar_suggestion_retention("history", false),
]);
--- a/browser/components/preferences/in-content/tests/browser_privacypane_8.js
+++ b/browser/components/preferences/in-content/tests/browser_privacypane_8.js
@@ -1,18 +1,16 @@
-let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
- getService(Ci.mozIJSSubScriptLoader);
let rootDir = getRootDirectory(gTestPath);
let jar = getJar(rootDir);
if (jar) {
let tmpdir = extractJarToTmp(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
test_historymode_retention("remember", undefined),
// history mode should remain remember; toggle acceptCookies checkbox
test_custom_retention("acceptCookies", "remember"),
--- a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js
+++ b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js
@@ -61,22 +61,20 @@ document.addEventListener("DOMContentLoa
document.title = stringBundle.GetStringFromName("title.head");
document.getElementById("favicon")
.setAttribute("href", FAVICON_PRIVACY);
tpToggle.addEventListener("change", toggleTrackingProtection);
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();
});
function openPrivateWindow() {
// Ask chrome to open a private window
document.dispatchEvent(
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_cache.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_cache.js
@@ -5,19 +5,17 @@
// Check about:cache after private browsing
// This test covers MozTrap test 6047
// bug 880621
var {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInfo.jsm", null);
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;
function test() {
waitForExplicitFinish();
sanitizeCache();
@@ -58,31 +56,24 @@ function sanitizeCache() {
prefs.setBoolPref("offlineApps", false);
prefs.setBoolPref("passwords", false);
prefs.setBoolPref("sessions", false);
prefs.setBoolPref("siteSettings", false);
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";
}
var visitor = {
entryCount: 0,
onCacheStorageInfo(aEntryCount, aConsumption) {
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js
@@ -182,26 +182,22 @@ async function openTab(aBrowser, aURL) {
let browser = aBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return {tab, browser};
}
// 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() {
// Clear all image caches before running the test.
clearAllImageCaches();
// Clear all favicons in Places.
await clearAllPlacesFavicons();
@@ -247,19 +243,17 @@ add_task(async function test_favicon_pri
await BrowserTestUtils.removeTab(tabInfo.tab);
await BrowserTestUtils.closeWindow(privateWindow);
});
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();
// Add an observer for making sure the favicon has been loaded and cached.
let promiseFaviconLoaded = waitOnFaviconLoaded(FAVICON_CACHE_URI);
// Open a tab for the non-private window.
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_opendir.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_opendir.js
@@ -18,20 +18,18 @@ registerCleanupFunction(function() {
windowsToClose.forEach(function(win) {
win.close();
});
});
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);
const kPrefName = "browser.open.lastDir";
function setupCleanSlate(win) {
win.gLastOpenDirectory.reset();
--- a/browser/components/resistfingerprinting/test/browser/browser_navigator.js
+++ b/browser/components/resistfingerprinting/test/browser/browser_navigator.js
@@ -84,18 +84,17 @@ async function testWorkerNavigator() {
await BrowserTestUtils.removeTab(tab);
}
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({"set":
[["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`;
});
add_task(async function runNavigatorTest() {
await testNavigator();
});
--- a/browser/components/search/test/browser_searchbar_openpopup.js
+++ b/browser/components/search/test/browser_searchbar_openpopup.js
@@ -1,17 +1,15 @@
// Tests that the suggestion popup appears at the right times in response to
// focus and user events (mouse, keyboard, drop).
// 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"];
const isWindows = Services.appinfo.OS == "WINNT";
const mouseDown = isWindows ? 2 : 1;
const mouseUp = isWindows ? 4 : 2;
const utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
--- a/browser/components/sessionstore/content/aboutSessionRestore.js
+++ b/browser/components/sessionstore/content/aboutSessionRestore.js
@@ -160,34 +160,32 @@ function restoreSession() {
if (top.gBrowser.tabs.length == 1) {
ss.setWindowState(top, stateString, true);
return;
}
// 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;
var tabIndex = tabbrowser.getBrowserIndexForDocument(document);
tabbrowser.removeTab(tabbrowser.tabs[tabIndex]);
}, "browser-delayed-startup-finished");
}
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();
}
function onListClick(aEvent) {
// don't react to right-clicks
if (aEvent.button == 2)
@@ -275,18 +273,17 @@ function restoreSingleTab(aIx, aShifted)
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
var tabState = gStateObject.windows[item.parent.ix]
.tabs[aIx - gTreeData.indexOf(item.parent) - 1];
// ensure tab would be visible on the tabstrip.
tabState.hidden = false;
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;
}
// Tree controller
var treeView = {
treeBox: null,
selection: null,
--- a/browser/components/sessionstore/test/browser_506482.js
+++ b/browser/components/sessionstore/test/browser_506482.js
@@ -5,19 +5,17 @@
function test() {
/** Test for Bug 506482 **/
// test setup
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");
return sessionStoreJS;
}
function getSessionstorejsModificationTime() {
let file = getSessionstoreFile();
if (file.exists()) {
--- a/browser/components/sessionstore/test/browser_522375.js
+++ b/browser/components/sessionstore/test/browser_522375.js
@@ -1,17 +1,16 @@
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")
- .snapshot();
+ var snapshot = Services.telemetry.getHistogramById("STARTUP_MEASUREMENT_ERRORS")
+ .snapshot();
if (snapshot.counts[0] == 0)
ok(startup_info.process <= startup_info.main, "process created before main is run " + uneval(startup_info));
else
todo(false, "An error occurred while recording the process creation timestamp, skipping this test");
// on linux firstPaint can happen after everything is loaded (especially with remote X)
if (startup_info.firstPaint)
--- a/browser/components/shell/content/setDesktopBackground.js
+++ b/browser/components/shell/content/setDesktopBackground.js
@@ -1,13 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
Components.utils.import("resource://gre/modules/AppConstants.jsm");
+Components.utils.import("resource://gre/modules/Services.jsm");
var Ci = Components.interfaces;
var gSetBackground = {
_position: AppConstants.platform == "macosx" ? "STRETCH" : "",
_backgroundColor: AppConstants.platform != "macosx" ? 0 : undefined,
_screenWidth: 0,
_screenHeight: 0,
@@ -27,19 +28,17 @@ var gSetBackground = {
if (AppConstants.platform == "macosx") {
document.documentElement.getButton("accept").hidden = true;
}
if (this._screenWidth / this._screenHeight >= 1.6)
document.getElementById("monitor").setAttribute("aspectratio", "16:10");
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;
document.getElementById("fitPosition").hidden = true;
}
}
// make sure that the correct dimensions will be used
@@ -75,19 +74,17 @@ var gSetBackground = {
this.updatePosition();
},
setDesktopBackground() {
if (AppConstants.platform != "macosx") {
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");
setDesktopBackground.disabled = true;
setDesktopBackground.label = bundle.getString("DesktopBackgroundDownloading");
}
this._shell.setDesktopBackground(
this._image,
@@ -190,18 +187,16 @@ if (AppConstants.platform != "macosx") {
.join("").toUpperCase();
};
} else {
gSetBackground.observe = function(aSubject, aTopic, aData) {
if (aTopic == "shell:desktop-background-changed") {
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");
}
};
gSetBackground.showDesktopPrefs = function() {
this._shell.openApplication(Ci.nsIMacShellService.APPLICATION_DESKTOP);
};
}
--- a/browser/components/shell/test/browser_420786.js
+++ b/browser/components/shell/test/browser_420786.js
@@ -1,19 +1,17 @@
const DG_BACKGROUND = "/desktop/gnome/background";
const DG_IMAGE_KEY = DG_BACKGROUND + "/picture_filename";
const DG_OPTION_KEY = DG_BACKGROUND + "/picture_options";
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"].
getService(Ci.nsIDirectoryServiceProvider);
var homeDir = dirSvc.getFile("Home", {});
var wpFile = homeDir.clone();
wpFile.append(brandName + "_wallpaper.png");
--- a/browser/components/syncedtabs/test/browser/head.js
+++ b/browser/components/syncedtabs/test/browser/head.js
@@ -2,15 +2,14 @@ const {classes: Cc, interfaces: Ci, util
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
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
delete window.sinon;
});
--- a/browser/components/tests/browser/browser_bug538331.js
+++ b/browser/components/tests/browser/browser_bug538331.js
@@ -395,19 +395,17 @@ function reloadUpdateManagerData() {
function writeUpdatesToXMLFile(aText) {
const PERMS_FILE = 0o644;
const MODE_WRONLY = 0x02;
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);
if (!file.exists()) {
file.create(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
}
fos.init(file, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, 0);
fos.write(aText, aText.length);
--- a/browser/components/translation/translation-infobar.xml
+++ b/browser/components/translation/translation-infobar.xml
@@ -181,19 +181,17 @@
</setter>
</property>
<method name="init">
<parameter name="aTranslation"/>
<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]));
};
// Fill the lists of supported source languages.
let detectedLanguage = this._getAnonElt("detectedLanguage");
let fromLanguage = this._getAnonElt("fromLanguage");
@@ -357,26 +355,22 @@
// If we have never attempted to translate the page before the
// service became unavailable, "fromLanguage" isn't set.
if (!lang && this.state == Translation.STATE_UNAVAILABLE)
lang = this.translation.detectedLanguage;
}
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",
bundle.formatStringFromName(kStrId + ".label",
[langName], 1));
item.setAttribute("accesskey",
bundle.GetStringFromName(kStrId + ".accesskey"));
item.langCode = lang;
--- a/browser/components/uitour/test/browser_UITour_defaultBrowser.js
+++ b/browser/components/uitour/test/browser_UITour_defaultBrowser.js
@@ -1,17 +1,16 @@
"use strict";
var gTestTab;
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() {}
MockShellService.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIShellService]),
isDefaultBrowser(aStartupCheck, aForAllTypes) { return false; },
setDefaultBrowser(aClaimAllTypes, aForAllUsers) {
setDefaultBrowserCalled = true;
--- a/browser/components/uitour/test/browser_UITour_modalDialog.js
+++ b/browser/components/uitour/test/browser_UITour_modalDialog.js
@@ -38,20 +38,19 @@ var observer = SpecialPowers.wrapCallbac
else
startCallbackTimer(); // try again in a bit
}
});
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();
var windowDocShell = win.QueryInterface(Ci.nsIXULWindow).docShell;
var containedDocShells = windowDocShell.getDocShellEnumerator(
Ci.nsIDocShellTreeItem.typeChrome,
Ci.nsIDocShell.ENUMERATE_FORWARDS);
--- a/browser/components/uitour/test/browser_UITour_resetProfile.js
+++ b/browser/components/uitour/test/browser_UITour_resetProfile.js
@@ -6,24 +6,22 @@ var gContentWindow;
add_task(setup_UITourTest);
// Test that a reset profile dialog appears when "resetFirefox" event is triggered
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.");
subj.close();
resolve();
}
}, {once: true});
}
@@ -39,9 +37,8 @@ add_UITour_task(async function test_rese
canReset = await getConfigurationPromise("canReset");
ok(canReset, "Should be able to reset from mochitest's temporary profile once it's in the profile manager.");
await gContentAPI.resetFirefox();
await dialogPromise;
tempProfile.remove(false);
canReset = await getConfigurationPromise("canReset");
ok(!canReset, "Shouldn't be able to reset from mochitest's temporary profile once removed from the profile manager.");
});
-