Bug 1412893 - Change instances of using getService to Services.jsm where possible in toolkit/components - Part 2. r=florian

MozReview-Commit-ID: 44oBXPP88Lc

--HG--
extra : rebase_source : 6625ac73eca1fa63d474eda3d1146baf910eac8c
This commit is contained in:
Mark Banner 2017-10-30 17:22:17 +00:00
Родитель cf372ccd32
Коммит 99e91ded27
36 изменённых файлов: 85 добавлений и 171 удалений

Просмотреть файл

@ -311,9 +311,7 @@ var PromptUtilsTemp = {
PromptUtils = PromptUtilsTemp;
XPCOMUtils.defineLazyGetter(PromptUtils, "strBundle", function() {
let bunService = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService);
let bundle = bunService.createBundle("chrome://global/locale/commonDialogs.properties");
let bundle = Services.strings.createBundle("chrome://global/locale/commonDialogs.properties");
if (!bundle)
throw "String bundle for Prompter not present!";
return bundle;

Просмотреть файл

@ -110,9 +110,7 @@ function getPromptState(ui) {
state.defButton1 = isDefaultButton(ui.button1);
state.defButton2 = isDefaultButton(ui.button2);
let fm = Cc["@mozilla.org/focus-manager;1"].
getService(Ci.nsIFocusManager);
let e = fm.focusedElement;
let e = Services.focus.focusedElement;
if (e == null) {
state.focused = null;
@ -202,10 +200,8 @@ function dismissPrompt(ui, action) {
function getDialogDoc() {
// Trudge through all the open windows, until we find the one
// that has either commonDialog.xul or selectDialog.xul loaded.
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.getEnumerator("navigator:browser");
var enumerator = Services.wm.getXULWindowEnumerator(null);
while (enumerator.hasMoreElements()) {
var win = enumerator.getNext();
@ -230,9 +226,7 @@ function getDialogDoc() {
// We're expecting the dialog to be focused. If it's not yet, try later.
// (In particular, this is needed on Linux to reliably check focused elements.)
let fm = Cc["@mozilla.org/focus-manager;1"].
getService(Ci.nsIFocusManager);
if (fm.focusedWindow != childDoc.defaultView)
if (Services.focus.focusedWindow != childDoc.defaultView)
continue;
return childDoc;

Просмотреть файл

@ -20,13 +20,13 @@ Prompter tests: modal prompts
/* import-globals-from prompt_common.js */
async function runTests() {
const { NetUtil } = SpecialPowers.Cu.import("resource://gre/modules/NetUtil.jsm");
const { Services } = SpecialPowers.Cu.import("resource://gre/modules/Services.jsm");
let state, action, promptDone;
ok(true, "Running tests (isTabModal=" + isTabModal + ", usePromptService=" + usePromptService + ")");
let prompter, promptArgs;
if (usePromptService) {
prompter = Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService);
prompter = Services.prompt;
} else {
prompter = Cc["@mozilla.org/prompter;1"].
getService(Ci.nsIPromptFactory).

Просмотреть файл

@ -18,8 +18,7 @@ Prompter tests: modal prompts
<pre id="test">
<script class="testbody" type="text/javascript">
/* import-globals-from prompt_common.js */
let prompter = Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService);
const { Services } = SpecialPowers.Cu.import("resource://gre/modules/Services.jsm");
function checkPromptState(promptState, expectedState) {
// XXX check title? OS X has title in content
@ -68,7 +67,7 @@ add_task(async function test_select_empty_list() {
let promptDone = handlePrompt(state, action);
let items = [];
selectVal.value = null; // outparam, just making sure.
isOK = prompter.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
isOK = Services.prompt.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
is(isOK, true, "checked expected retval");
is(selectVal.value, -1, "checking selected index");
@ -89,7 +88,7 @@ add_task(async function test_select_ok() {
let promptDone = handlePrompt(state, action);
let items = ["one", "two", "three"];
selectVal.value = null; // outparam, just making sure.
isOK = prompter.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
isOK = Services.prompt.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
is(isOK, true, "checked expected retval");
is(selectVal.value, 0, "checking selected index");
@ -111,7 +110,7 @@ add_task(async function test_select_item() {
let promptDone = handlePrompt(state, action);
let items = ["one", "two", "three"];
selectVal.value = null; // outparam, just making sure.
isOK = prompter.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
isOK = Services.prompt.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
is(isOK, true, "checked expected retval");
is(selectVal.value, 1, "checking selected index");
@ -132,7 +131,7 @@ add_task(async function test_cancel_prompt() {
let promptDone = handlePrompt(state, action);
let items = ["one", "two", "three"];
selectVal.value = null; // outparam, just making sure.
isOK = prompter.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
isOK = Services.prompt.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal);
is(isOK, false, "checked expected retval");
is(selectVal.value, 0, "checking selected index");

Просмотреть файл

@ -11,12 +11,6 @@ function waitForPageShow(browser = gBrowser.selectedBrowser) {
return BrowserTestUtils.waitForContentEvent(browser, "pageshow", true);
}
function makeURI(url) {
return Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService).
newURI(url);
}
// Tests that loadURI accepts a referrer and it is included in the load.
add_task(async function test_referrer() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
@ -24,7 +18,7 @@ add_task(async function test_referrer() {
browser.webNavigation.loadURI(DUMMY1,
Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
makeURI(DUMMY2), null, null,
Services.io.newURI(DUMMY2), null, null,
SYSTEMPRINCIPAL);
await waitForLoad(DUMMY1);

Просмотреть файл

@ -101,10 +101,9 @@ add_task(async function test_setup() {
function check_telemetry(aShouldBlockCount,
aListCounts) {
let local = Cc["@mozilla.org/base/telemetry;1"]
.getService(Ci.nsITelemetry)
.getHistogramById("APPLICATION_REPUTATION_LOCAL")
.snapshot();
let local = Services.telemetry
.getHistogramById("APPLICATION_REPUTATION_LOCAL")
.snapshot();
do_check_eq(local.counts[ALLOW_LIST], aListCounts[ALLOW_LIST],
"Allow list counts don't match");
do_check_eq(local.counts[BLOCK_LIST], aListCounts[BLOCK_LIST],
@ -112,23 +111,20 @@ function check_telemetry(aShouldBlockCount,
do_check_eq(local.counts[NO_LIST], aListCounts[NO_LIST],
"No list counts don't match");
let shouldBlock = Cc["@mozilla.org/base/telemetry;1"]
.getService(Ci.nsITelemetry)
.getHistogramById("APPLICATION_REPUTATION_SHOULD_BLOCK")
.snapshot();
let shouldBlock = Services.telemetry
.getHistogramById("APPLICATION_REPUTATION_SHOULD_BLOCK")
.snapshot();
// SHOULD_BLOCK = true
do_check_eq(shouldBlock.counts[1], aShouldBlockCount);
}
function get_telemetry_counts() {
let local = Cc["@mozilla.org/base/telemetry;1"]
.getService(Ci.nsITelemetry)
.getHistogramById("APPLICATION_REPUTATION_LOCAL")
.snapshot();
let shouldBlock = Cc["@mozilla.org/base/telemetry;1"]
.getService(Ci.nsITelemetry)
.getHistogramById("APPLICATION_REPUTATION_SHOULD_BLOCK")
.snapshot();
let local = Services.telemetry
.getHistogramById("APPLICATION_REPUTATION_LOCAL")
.snapshot();
let shouldBlock = Services.telemetry
.getHistogramById("APPLICATION_REPUTATION_SHOULD_BLOCK")
.snapshot();
return { shouldBlock: shouldBlock.counts[1],
listCounts: local.counts };
}

Просмотреть файл

@ -20,9 +20,6 @@ Cu.import("resource://gre/modules/FormHistory.jsm");
do_get_profile();
var dirSvc = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties);
// Send the profile-after-change notification to the form history component to ensure
// that it has been initialized.
var formHistoryStartup = Cc["@mozilla.org/satchel/form-history-startup;1"]
@ -30,9 +27,7 @@ var formHistoryStartup = Cc["@mozilla.org/satchel/form-history-startup;1"]
formHistoryStartup.observe(null, "profile-after-change", null);
function getDBVersion(dbfile) {
let ss = Cc["@mozilla.org/storage/service;1"]
.getService(Ci.mozIStorageService);
let dbConnection = ss.openDatabase(dbfile);
let dbConnection = Services.storage.openDatabase(dbfile);
let version = dbConnection.schemaVersion;
dbConnection.close();

Просмотреть файл

@ -5,7 +5,6 @@
"use strict";
var fac;
var prefs;
var numRecords, timeGroupingSize, now;
@ -20,8 +19,8 @@ function padLeft(number, length) {
}
function getFormExpiryDays() {
if (prefs.prefHasUserValue("browser.formfill.expire_days")) {
return prefs.getIntPref("browser.formfill.expire_days");
if (Services.prefs.prefHasUserValue("browser.formfill.expire_days")) {
return Services.prefs.getIntPref("browser.formfill.expire_days");
}
return DEFAULT_EXPIRE_DAYS;
}
@ -29,7 +28,7 @@ function getFormExpiryDays() {
function run_test() {
// ===== test init =====
let testfile = do_get_file("formhistory_autocomplete.sqlite");
let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
let profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
let destFile = profileDir.clone();
@ -41,16 +40,15 @@ function run_test() {
testfile.copyTo(profileDir, "formhistory.sqlite");
fac = Cc["@mozilla.org/satchel/form-autocomplete;1"].getService(Ci.nsIFormAutoComplete);
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
timeGroupingSize = prefs.getIntPref("browser.formfill.timeGroupingSize") * 1000 * 1000;
timeGroupingSize = Services.prefs.getIntPref("browser.formfill.timeGroupingSize") * 1000 * 1000;
run_next_test();
}
add_test(function test0() {
let maxTimeGroupings = prefs.getIntPref("browser.formfill.maxTimeGroupings");
let bucketSize = prefs.getIntPref("browser.formfill.bucketSize");
let maxTimeGroupings = Services.prefs.getIntPref("browser.formfill.maxTimeGroupings");
let bucketSize = Services.prefs.getIntPref("browser.formfill.bucketSize");
// ===== Tests with constant timesUsed and varying lastUsed date =====
// insert 2 records per bucket to check alphabetical sort within

Просмотреть файл

@ -7,7 +7,7 @@ var bakFile;
function run_test() {
// ===== test init =====
let testfile = do_get_file("formhistory_CORRUPT.sqlite");
let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
let profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
let destFile = profileDir.clone();

Просмотреть файл

@ -16,7 +16,7 @@ function* next_test() {
try {
// ===== test init =====
let testfile = do_get_file("formhistory_v3.sqlite");
let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
let profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
let destFile = profileDir.clone();

Просмотреть файл

@ -16,7 +16,7 @@ function* next_test() {
try {
// ===== test init =====
let testfile = do_get_file("formhistory_v3v4.sqlite");
let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
let profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
let destFile = profileDir.clone();

Просмотреть файл

@ -28,7 +28,7 @@ function* tests() {
try {
// ===== test init =====
let testfile = do_get_file("formhistory_v999a.sqlite");
let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
let profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
let destFile = profileDir.clone();

Просмотреть файл

@ -28,7 +28,7 @@ function* tests() {
try {
// ===== test init =====
let testfile = do_get_file("formhistory_v999b.sqlite");
let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
let profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
let destFile = profileDir.clone();

Просмотреть файл

@ -108,7 +108,7 @@ add_task(async function() {
try {
// ===== test init =====
let testfile = do_get_file("formhistory_apitest.sqlite");
let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
let profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
let destFile = profileDir.clone();

Просмотреть файл

@ -74,8 +74,7 @@ function* run_test_steps() {
});
// Add the observer
let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
os.addObserver(TestObserver, "satchel-storage-changed");
Services.obs.addObserver(TestObserver, "satchel-storage-changed");
/* ========== 2 ========== */
testnum++;
@ -192,7 +191,7 @@ function* run_test_steps() {
do_check_eq(expectedNotification, null);
os.removeObserver(TestObserver, "satchel-storage-changed");
Services.obs.removeObserver(TestObserver, "satchel-storage-changed");
do_test_finished();
} catch (e) {

Просмотреть файл

@ -2375,8 +2375,7 @@ Engine.prototype = {
get _defaultMobileResponseType() {
let type = URLTYPE_SEARCH_HTML;
let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
let isTablet = sysInfo.get("tablet");
let isTablet = Services.sysinfo.get("tablet");
if (isTablet && this.supportsResponseType("application/x-moz-tabletsearch")) {
// Check for a tablet-specific search URL override
type = "application/x-moz-tabletsearch";

Просмотреть файл

@ -24,6 +24,7 @@ const MODE_TRUNCATE = FileUtils.MODE_TRUNCATE;
const CACHE_FILENAME = "search.json.mozlz4";
// nsSearchService.js uses Services.appinfo.name to build a salt for a hash.
// eslint-disable-next-line mozilla/use-services
var XULRuntime = Components.classesByID["{95d89e3e-a169-41a3-8e56-719978e15b12}"]
.getService(Ci.nsIXULRuntime);

Просмотреть файл

@ -12,17 +12,12 @@
* @param aKey
* The directory service key indicating the directory to get.
*/
var _dirSvc = null;
function getDir(aKey, aIFace) {
if (!aKey) {
do_throw("getDir requires a directory key!");
}
if (!_dirSvc) {
_dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
}
return _dirSvc.get(aKey, aIFace || Ci.nsIFile);
return Services.dirsvc.get(aKey, aIFace || Ci.nsIFile);
}
function makeURI(uri) {

Просмотреть файл

@ -28,9 +28,7 @@ function test() {
btnStay.click();
});
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].
getService(Ci.nsIAppStartup);
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit);
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit);
ok(seenDialog, "Should have seen a prompt dialog");
ok(!win2.closed, "Shouldn't have closed the additional window");
win2.close();

Просмотреть файл

@ -23,9 +23,7 @@ function test() {
btnStay.click();
});
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].
getService(Ci.nsIAppStartup);
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit);
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit);
ok(seenDialog, "Should have seen a prompt dialog");
ok(!window.closed, "Shouldn't have closed the window");

Просмотреть файл

@ -9,8 +9,7 @@ var Ci = Components.interfaces;
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "10.0");
var prefService = Services.prefs;
var appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].
getService(Ci.nsIAppStartup);
var appStartup = Services.startup;
const pref_last_success = "toolkit.startup.last_success";
const pref_recent_crashes = "toolkit.startup.recent_crashes";

Просмотреть файл

@ -6,8 +6,9 @@ this.EXPORTED_SYMBOLS = ["TelemetryLog"];
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
Cu.import("resource://gre/modules/Services.jsm");
const LOG_ENTRY_MAX_COUNT = 1000;
@ -21,7 +22,7 @@ this.TelemetryLog = Object.freeze({
id = String(id);
var ts;
try {
ts = Math.floor(Telemetry.msSinceProcessStart());
ts = Math.floor(Services.telemetry.msSinceProcessStart());
} catch (e) {
// If timestamp is screwed up, we just give up instead of making up
// data.

Просмотреть файл

@ -9,12 +9,10 @@ const Cu = Components.utils;
this.EXPORTED_SYMBOLS = ["TelemetryStopwatch"];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Log",
"resource://gre/modules/Log.jsm");
var Telemetry = Cc["@mozilla.org/base/telemetry;1"]
.getService(Ci.nsITelemetry);
// Weak map does not allow using null objects as keys. These objects are used
// as 'null' placeholders.
const NULL_OBJECT = {};
@ -404,9 +402,9 @@ this.TelemetryStopwatchImpl = {
try {
if (key) {
Telemetry.getKeyedHistogramById(histogram).add(key, delta);
Services.telemetry.getKeyedHistogramById(histogram).add(key, delta);
} else {
Telemetry.getHistogramById(histogram).add(delta);
Services.telemetry.getHistogramById(histogram).add(delta);
}
} catch (e) {
if (!this._suppressErrors) {

Просмотреть файл

@ -19,6 +19,7 @@ const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
const IS_CONTENT_PROCESS = (function() {
// We cannot use Services.appinfo here because in telemetry xpcshell tests,
// appinfo is initially unavailable, and becomes available only later on.
// eslint-disable-next-line mozilla/use-services
let runtime = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
return runtime.processType == Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT;
})();

Просмотреть файл

@ -26,7 +26,7 @@ const gIsMac = AppConstants.platform == "macosx";
const gIsAndroid = AppConstants.platform == "android";
const gIsLinux = AppConstants.platform == "linux";
const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
const Telemetry = Services.telemetry;
const MILLISECONDS_PER_MINUTE = 60 * 1000;
const MILLISECONDS_PER_HOUR = 60 * MILLISECONDS_PER_MINUTE;

Просмотреть файл

@ -7,9 +7,7 @@ const URL2 = URL + "#2";
const URL3 = URL + "#3";
var tmp = {};
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("resource://gre/modules/PageThumbs.jsm", tmp);
Services.scriptloader.loadSubScript("resource://gre/modules/PageThumbs.jsm", tmp);
const EXPIRATION_MIN_CHUNK_SIZE = 50;
const {PageThumbsExpiration} = tmp;

Просмотреть файл

@ -6,9 +6,7 @@ const URL_COPY = URL + "#copy";
XPCOMUtils.defineLazyGetter(this, "Sanitizer", function() {
let 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);
return tmp.Sanitizer;
});

Просмотреть файл

@ -8,9 +8,7 @@ const THUMBNAIL_DIRECTORY = "thumbnails";
const PREF_STORAGE_VERSION = "browser.pagethumbnails.storage_version";
var tmp = {};
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("resource://gre/modules/PageThumbs.jsm", tmp);
Services.scriptloader.loadSubScript("resource://gre/modules/PageThumbs.jsm", tmp);
var {PageThumbsStorageMigrator} = tmp;
XPCOMUtils.defineLazyServiceGetter(this, "gDirSvc",

Просмотреть файл

@ -1,20 +1,16 @@
/* 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/. */
Cu.import("resource://gre/modules/Services.jsm");
function run_test() {
var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
getService(Ci.nsIURLFormatter);
var locale = Cc["@mozilla.org/intl/localeservice;1"].
getService(Ci.mozILocaleService).
getAppLocaleAsLangTag();
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
var sysInfo = Cc["@mozilla.org/system-info;1"].
getService(Ci.nsIPropertyBag2);
var OSVersion = sysInfo.getProperty("name") + " " +
sysInfo.getProperty("version");
var formatter = Services.urlFormatter;
var locale = Services.locale.getAppLocaleAsLangTag();
var OSVersion = Services.sysinfo.getProperty("name") + " " +
Services.sysinfo.getProperty("version");
try {
OSVersion += " (" + sysInfo.getProperty("secondaryLibrary") + ")";
OSVersion += " (" + Services.sysinfo.getProperty("secondaryLibrary") + ")";
} catch (e) {}
OSVersion = encodeURIComponent(OSVersion);
var macutils = null;
@ -22,12 +18,9 @@ function run_test() {
macutils = Cc["@mozilla.org/xpcom/mac-utils;1"].
getService(Ci.nsIMacUtils);
} catch (e) {}
var appInfo = Cc["@mozilla.org/xre/app-info;1"].
getService(Ci.nsIXULAppInfo).
QueryInterface(Ci.nsIXULRuntime);
var abi = macutils && macutils.isUniversalBinary ? "Universal-gcc3" : appInfo.XPCOMABI;
var abi = macutils && macutils.isUniversalBinary ? "Universal-gcc3" : Services.appinfo.XPCOMABI;
let defaults = prefs.QueryInterface(Ci.nsIPrefService).getDefaultBranch(null);
let defaults = Services.prefs.getDefaultBranch(null);
let channel = defaults.getCharPref("app.update.channel", "default");
// Set distribution values.
@ -46,7 +39,7 @@ function run_test() {
var advancedUrlRef = "http://test.mozilla.com/Url Formatter Test/1/" + gAppInfo.appBuildID + "/XPCShell_" + abi + "/" + locale + "/" + channel + "/" + OSVersion + "/bacon/1.0/";
var pref = "xpcshell.urlformatter.test";
prefs.setStringPref(pref, upperUrlRaw);
Services.prefs.setStringPref(pref, upperUrlRaw);
do_check_eq(formatter.formatURL(upperUrlRaw), ulUrlRef);
do_check_eq(formatter.formatURLPref(pref), ulUrlRef);

Просмотреть файл

@ -531,10 +531,7 @@ ViewSourceChrome.prototype = {
event.preventDefault();
}
let linkHandler = Cc["@mozilla.org/content/dropped-link-handler;1"]
.getService(Ci.nsIDroppedLinkHandler);
if (linkHandler.canDropLink(event, false)) {
if (Services.droppedLinkHandler.canDropLink(event, false)) {
event.preventDefault();
}
},
@ -547,12 +544,10 @@ ViewSourceChrome.prototype = {
return;
let name = { };
let linkHandler = Cc["@mozilla.org/content/dropped-link-handler;1"]
.getService(Ci.nsIDroppedLinkHandler);
let uri;
try {
// Pass true to prevent the dropping of javascript:/data: URIs
uri = linkHandler.dropLink(event, name, true);
uri = Services.droppedLinkHandler.dropLink(event, name, true);
} catch (e) {
return;
}

Просмотреть файл

@ -60,9 +60,7 @@ var gViewSourceUtils = {
* The line number to focus on once the source is loaded.
*/
viewSource(aArgsOrURL, aPageDescriptor, aDocument, aLineNumber) {
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
if (prefs.getBoolPref("view_source.editor.external")) {
if (Services.prefs.getBoolPref("view_source.editor.external")) {
this.openInExternalEditor(aArgsOrURL, aPageDescriptor, aDocument, aLineNumber);
} else {
this._openInInternalViewer(aArgsOrURL, aPageDescriptor, aDocument, aLineNumber);
@ -173,9 +171,7 @@ var gViewSourceUtils = {
// We currently support a %LINE% placeholder which is set to the passed
// line number (or to 0 if there's none)
var editorArgs = [];
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var args = prefs.getCharPref("view_source.editor.args");
var args = Services.prefs.getCharPref("view_source.editor.args");
if (args) {
args = args.replace("%LINE%", aLineNumber || "0");
// add the arguments to the array (keeping quoted strings intact)
@ -271,10 +267,8 @@ var gViewSourceUtils = {
}
// make a uri
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var charset = data.doc ? data.doc.characterSet : null;
var uri = ios.newURI(data.url, charset);
var uri = Services.io.newURI(data.url, charset);
data.uri = uri;
var path;
@ -362,10 +356,8 @@ var gViewSourceUtils = {
getExternalViewSourceEditor() {
try {
let viewSourceAppPath =
Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch)
.getComplexValue("view_source.editor.path",
Components.interfaces.nsIFile);
Services.prefs.getComplexValue("view_source.editor.path",
Components.interfaces.nsIFile);
let editor = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
editor.init(viewSourceAppPath);
@ -493,15 +485,11 @@ var gViewSourceUtils = {
getTemporaryFile(aURI, aDocument, aContentType) {
// include contentAreaUtils.js in our own context when we first need it
if (!this._caUtils) {
var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
this._caUtils = {};
scriptLoader.loadSubScript("chrome://global/content/contentAreaUtils.js", this._caUtils);
Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js", this._caUtils);
}
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
var tempFile = fileLocator.get("TmpD", Components.interfaces.nsIFile);
var tempFile = Services.dirsvc.get("TmpD", Components.interfaces.nsIFile);
var fileName = this._caUtils.getDefaultFileName(null, aURI, aDocument, aContentType);
var extension = this._caUtils.getDefaultExtension(fileName, aURI, aContentType);
var leafName = this._caUtils.getNormalizedLeafName(fileName, extension);

Просмотреть файл

@ -28,9 +28,7 @@ function one_test(delay, continuation) {
const nameStem = "test_bug1204626_" + Date.now();
let wbp = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
.createInstance(Ci.nsIWebBrowserPersist);
let tmp = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("TmpD", Ci.nsIFile);
let tmp = Services.dirsvc.get("TmpD", Ci.nsIFile);
let tmpFile = tmp.clone();
tmpFile.append(nameStem + "_saved.html");
let tmpDir = tmp.clone();

Просмотреть файл

@ -29,11 +29,7 @@ iframe.onload = function iframe_onload1() {
let wbp = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
.createInstance(Ci.nsIWebBrowserPersist);
let ios = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
let tmp = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("TmpD", Ci.nsIFile);
let tmp = SpecialPowers.Services.dirsvc.get("TmpD", Ci.nsIFile);
let tmpFile = tmp.clone();
tmpFile.append(nameStem + "_iframe.xml");
let tmpDir = tmp.clone();
@ -60,7 +56,7 @@ iframe.onload = function iframe_onload1() {
cleanUp();
SimpleTest.finish();
};
iframe.src = ios.newFileURI(tmpFile).spec;
iframe.src = SpecialPowers.Services.io.newFileURI(tmpFile).spec;
}
};
wbp.saveDocument(doc, tmpFile, tmpDir, null, 0, 0);

Просмотреть файл

@ -36,9 +36,7 @@ iframe.onload = function iframe_onload1() {
let wbp = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
.createInstance(Ci.nsIWebBrowserPersist);
let tmp = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("TmpD", Ci.nsIFile);
let tmp = SpecialPowers.Services.dirsvc.get("TmpD", Ci.nsIFile);
let tmpFile = tmp.clone();
tmpFile.append(nameStem + "_iframe.xml");
let tmpDir = tmp.clone();

Просмотреть файл

@ -61,9 +61,7 @@ const Cc = SpecialPowers.Cc;
const Ci = SpecialPowers.Ci;
function getTempDir() {
return Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("TmpD", Ci.nsIFile);
return SpecialPowers.Services.dirsvc.get("TmpD", Ci.nsIFile);
}
function getFileContents(aFile) {
@ -94,10 +92,6 @@ function persistDocument(aDoc) {
const encodingFlags =
nsIWBP.ENCODE_FLAGS_ENCODE_BASIC_ENTITIES;
var ioService = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var file = getTempDir();
file.append("bug293834-serialized.html");
@ -108,7 +102,7 @@ function persistDocument(aDoc) {
const kWrapColumn = 80;
var folder = getTempDir();
folder.append("bug293834-serialized");
persist.saveDocument(aDoc, ioService.newFileURI(file),
persist.saveDocument(aDoc, SpecialPowers.Services.io.newFileURI(file),
folder,
aDoc.contentType,
encodingFlags, kWrapColumn);

Просмотреть файл

@ -25,9 +25,7 @@ const Cc = SpecialPowers.Cc;
const Ci = SpecialPowers.Ci;
function getTempDir() {
return Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("TmpD", Ci.nsIFile);
return SpecialPowers.Services.dirsvc.get("TmpD", Ci.nsIFile);
}
// STATE_STOP from nsIWebProgressListener.idl
@ -64,9 +62,6 @@ function persistDocument(aDoc) {
const encodingFlags =
nsIWBP.ENCODE_FLAGS_ENCODE_BASIC_ENTITIES;
var ioService = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var id = Math.round(Math.random() * 10000);
var dirName = "bug449141_serialized" + id;
progressListener.dirName = dirName;
@ -83,7 +78,7 @@ function persistDocument(aDoc) {
folder.append(dirName);
progressListener.folder = folder;
progressListener.file = file;
persist.saveDocument(aDoc, ioService.newFileURI(file),
persist.saveDocument(aDoc, SpecialPowers.Services.io.newFileURI(file),
folder,
aDoc.contentType,
encodingFlags, kWrapColumn);