--- a/toolkit/components/prompts/src/nsPrompter.js
+++ b/toolkit/components/prompts/src/nsPrompter.js
@@ -306,19 +306,17 @@ var PromptUtilsTemp = {
return promptBox;
},
};
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;
});
XPCOMUtils.defineLazyGetter(PromptUtils, "ellipsis", function() {
let ellipsis = "\u2026";
try {
--- a/toolkit/components/prompts/test/chromeScript.js
+++ b/toolkit/components/prompts/test/chromeScript.js
@@ -105,19 +105,17 @@ function getPromptState(ui) {
function isDefaultButton(b) {
return (b.hasAttribute("default") &&
b.getAttribute("default") == "true");
}
state.defButton0 = isDefaultButton(ui.button0);
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;
} else if (ui.button0.isSameNode(e)) {
state.focused = "button0";
} else if (ui.button1.isSameNode(e)) {
state.focused = "button1";
} else if (ui.button2.isSameNode(e)) {
@@ -197,20 +195,18 @@ function dismissPrompt(ui, action) {
default:
throw "dismissPrompt action listed unknown button.";
}
}
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();
var windowDocShell = win.QueryInterface(Ci.nsIXULWindow).docShell;
var containedDocShells = windowDocShell.getDocShellEnumerator(
Ci.nsIDocShellTreeItem.typeChrome,
Ci.nsIDocShell.ENUMERATE_FORWARDS);
@@ -225,19 +221,17 @@ function getDialogDoc() {
.DOMDocument;
if (childDoc.location.href != "chrome://global/content/commonDialog.xul" &&
childDoc.location.href != "chrome://global/content/selectDialog.xul")
continue;
// 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;
}
}
return null;
}
--- a/toolkit/components/prompts/test/test_modal_prompts.html
+++ b/toolkit/components/prompts/test/test_modal_prompts.html
@@ -15,23 +15,23 @@ Prompter tests: modal prompts
<iframe id="iframe"></iframe>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/* 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).
getPrompt(window, Ci.nsIPrompt);
if (isTabModal) {
let bag = prompter.QueryInterface(Ci.nsIWritablePropertyBag2);
bag.setPropertyAsBool("allowTabModal", true);
}
--- a/toolkit/components/prompts/test/test_modal_select.html
+++ b/toolkit/components/prompts/test/test_modal_select.html
@@ -13,18 +13,17 @@ Prompter tests: modal prompts
<div id="content" style="display: none">
<iframe id="iframe"></iframe>
</div>
<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
// XXX check focused element
// XXX check button labels?
is(promptState.msg, expectedState.msg, "Checking expected message");
@@ -63,17 +62,17 @@ add_task(async function test_select_empt
items: [],
};
let action = {
buttonClick: "ok",
};
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");
await promptDone;
});
// =====
add_task(async function test_select_ok() {
@@ -84,17 +83,17 @@ add_task(async function test_select_ok()
items: ["one", "two", "three"],
};
let action = {
buttonClick: "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");
await promptDone;
});
// =====
add_task(async function test_select_item() {
@@ -106,17 +105,17 @@ add_task(async function test_select_item
};
let action = {
buttonClick: "ok",
selectItem: 1,
};
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");
await promptDone;
});
// =====
add_task(async function test_cancel_prompt() {
@@ -127,17 +126,17 @@ add_task(async function test_cancel_prom
items: ["one", "two", "three"],
};
let action = {
buttonClick: "cancel",
};
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");
await promptDone;
});
</script>
</pre>
--- a/toolkit/components/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
+++ b/toolkit/components/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
@@ -6,30 +6,24 @@ const DUMMY2 = "http://example.org/brows
function waitForLoad(uri) {
return BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, uri);
}
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);
let browser = gBrowser.selectedBrowser;
browser.webNavigation.loadURI(DUMMY1,
Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
- makeURI(DUMMY2), null, null,
+ Services.io.newURI(DUMMY2), null, null,
SYSTEMPRINCIPAL);
await waitForLoad(DUMMY1);
await ContentTask.spawn(browser, [ DUMMY1, DUMMY2 ], function([dummy1, dummy2]) {
is(content.location.href, dummy1, "Should have loaded the right URL");
is(content.document.referrer, dummy2, "Should have the right referrer");
});
--- a/toolkit/components/reputationservice/test/unit/test_app_rep.js
+++ b/toolkit/components/reputationservice/test/unit/test_app_rep.js
@@ -96,44 +96,40 @@ add_task(async function test_setup() {
gHttpServ.stop(resolve);
});
})();
});
});
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],
"Block list counts don't match");
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 };
}
add_test(function test_nullSourceURI() {
let counts = get_telemetry_counts();
gAppRep.queryReputation({
// No source URI
--- a/toolkit/components/satchel/test/unit/head_satchel.js
+++ b/toolkit/components/satchel/test/unit/head_satchel.js
@@ -15,29 +15,24 @@ const CURRENT_SCHEMA = 4;
const PR_HOURS = 60 * 60 * 1000000;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
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"]
.getService(Ci.nsIObserver);
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();
return version;
}
const isGUID = /[A-Za-z0-9\+\/]{16}/;
--- a/toolkit/components/satchel/test/unit/test_autocomplete.js
+++ b/toolkit/components/satchel/test/unit/test_autocomplete.js
@@ -1,61 +1,59 @@
/* 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/. */
"use strict";
var fac;
-var prefs;
var numRecords, timeGroupingSize, now;
const DEFAULT_EXPIRE_DAYS = 180;
function padLeft(number, length) {
let str = number + "";
while (str.length < length) {
str = "0" + str;
}
return str;
}
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;
}
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();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
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
now = 1000 * Date.now();
numRecords = Math.ceil(maxTimeGroupings / bucketSize) * 2;
let changes = [];
for (let i = 0; i < numRecords; i += 2) {
--- a/toolkit/components/satchel/test/unit/test_db_corrupt.js
+++ b/toolkit/components/satchel/test/unit/test_db_corrupt.js
@@ -2,17 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var 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();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
--- a/toolkit/components/satchel/test/unit/test_db_update_v4.js
+++ b/toolkit/components/satchel/test/unit/test_db_update_v4.js
@@ -11,17 +11,17 @@ function run_test() {
iter = next_test();
iter.next();
}
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();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
--- a/toolkit/components/satchel/test/unit/test_db_update_v4b.js
+++ b/toolkit/components/satchel/test/unit/test_db_update_v4b.js
@@ -11,17 +11,17 @@ function run_test() {
iter = next_test();
iter.next();
}
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();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
--- a/toolkit/components/satchel/test/unit/test_db_update_v999a.js
+++ b/toolkit/components/satchel/test/unit/test_db_update_v999a.js
@@ -23,17 +23,17 @@ function next_test() {
}
function* tests() {
let testnum = 0;
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();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
--- a/toolkit/components/satchel/test/unit/test_db_update_v999b.js
+++ b/toolkit/components/satchel/test/unit/test_db_update_v999b.js
@@ -23,17 +23,17 @@ function next_test() {
}
function* tests() {
let testnum = 0;
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();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
--- a/toolkit/components/satchel/test/unit/test_history_api.js
+++ b/toolkit/components/satchel/test/unit/test_history_api.js
@@ -103,17 +103,17 @@ function promiseCountEntries(name, value
add_task(async function() {
let oldSupportsDeletedTable = FormHistory._supportsDeletedTable;
FormHistory._supportsDeletedTable = true;
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();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
--- a/toolkit/components/satchel/test/unit/test_notify.js
+++ b/toolkit/components/satchel/test/unit/test_notify.js
@@ -69,18 +69,17 @@ function* run_test_steps() {
yield updateEntry("remove", null, null, next_test);
yield countEntries(null, null, function(num) {
do_check_false(num, "Checking initial DB is empty");
next_test();
});
// 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++;
testdesc = "addEntry";
expectedNotification = "formhistory-add";
expectedData = entry1;
@@ -187,15 +186,15 @@ function* run_test_steps() {
},
handleErrors(error) {
do_throw("Error occurred updating form history: " + error);
},
});
do_check_eq(expectedNotification, null);
- os.removeObserver(TestObserver, "satchel-storage-changed");
+ Services.obs.removeObserver(TestObserver, "satchel-storage-changed");
do_test_finished();
} catch (e) {
throw new Error(`FAILED in test #${testnum} -- ${testdesc}: ${e}`);
}
}
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -2370,18 +2370,17 @@ Engine.prototype = {
Cr.NS_ERROR_FAILURE);
url.addParam(aName, aValue);
},
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";
} else if (!isTablet && this.supportsResponseType("application/x-moz-phonesearch")) {
// Check for a phone-specific search URL override
type = "application/x-moz-phonesearch";
}
--- a/toolkit/components/search/tests/xpcshell/head_search.js
+++ b/toolkit/components/search/tests/xpcshell/head_search.js
@@ -19,16 +19,17 @@ const NS_APP_SEARCH_DIR = "SrchPlugns";
const MODE_RDONLY = FileUtils.MODE_RDONLY;
const MODE_WRONLY = FileUtils.MODE_WRONLY;
const MODE_CREATE = FileUtils.MODE_CREATE;
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);
var isChild = XULRuntime.processType == XULRuntime.PROCESS_TYPE_CONTENT;
updateAppInfo({
name: "XPCShell",
ID: "xpcshell@test.mozilla.org",
--- a/toolkit/components/search/tests/xpcshell/test_json_cache.js
+++ b/toolkit/components/search/tests/xpcshell/test_json_cache.js
@@ -7,27 +7,22 @@
"use strict";
/**
* Gets a directory from the directory service.
* @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) {
return Services.io.newURI(uri);
}
var cacheTemplate, appPluginsPath, profPlugins;
--- a/toolkit/components/startup/tests/browser/browser_bug511456.js
+++ b/toolkit/components/startup/tests/browser/browser_bug511456.js
@@ -23,19 +23,17 @@ function test() {
// Cancel the prompt the first time.
waitForOnBeforeUnloadDialog(browser, (btnLeave, btnStay) => {
seenDialog = Services.focus.activeWindow == window &&
gBrowser.selectedBrowser == browser;
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();
// Leave the page the second time.
waitForOnBeforeUnloadDialog(browser, (btnLeave, btnStay) => {
btnLeave.click();
});
--- a/toolkit/components/startup/tests/browser/browser_bug537449.js
+++ b/toolkit/components/startup/tests/browser/browser_bug537449.js
@@ -18,19 +18,17 @@ function test() {
let seenDialog = false;
// Cancel the prompt the first time.
waitForOnBeforeUnloadDialog(browser, (btnLeave, btnStay) => {
seenDialog = true;
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");
let win2 = window.openDialog(location, "", "chrome,all,dialog=no", "about:blank");
ok(win2 != null, "Should have been able to open a new window");
win2.addEventListener("load", function() {
win2.close();
--- a/toolkit/components/startup/tests/unit/test_startup_crash.js
+++ b/toolkit/components/startup/tests/unit/test_startup_crash.js
@@ -4,18 +4,17 @@
Components.utils.import("resource://gre/modules/Services.jsm");
var Cc = Components.classes;
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";
const pref_max_resumed_crashes = "toolkit.startup.max_resumed_crashes";
const pref_always_use_safe_mode = "toolkit.startup.always_use_safe_mode";
function run_test() {
prefService.setBoolPref(pref_always_use_safe_mode, true);
--- a/toolkit/components/telemetry/TelemetryLog.jsm
+++ b/toolkit/components/telemetry/TelemetryLog.jsm
@@ -1,32 +1,33 @@
/* 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/. */
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;
var gLogEntries = [];
this.TelemetryLog = Object.freeze({
log(id, data) {
if (gLogEntries.length >= LOG_ENTRY_MAX_COUNT) {
return;
}
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.
return;
}
var entry = [id, ts];
if (data !== undefined) {
--- a/toolkit/components/telemetry/TelemetryStopwatch.jsm
+++ b/toolkit/components/telemetry/TelemetryStopwatch.jsm
@@ -4,22 +4,20 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
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 = {};
const NULL_KEY = {};
/**
* Timers is a variation of a Map used for storing information about running
* Stopwatches. Timers has the following data structure:
@@ -399,19 +397,19 @@ this.TelemetryStopwatchImpl = {
finish(histogram, object, key, aCanceledOkay) {
let delta = this.timeElapsed(histogram, object, key, aCanceledOkay);
if (delta == -1) {
return false;
}
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) {
Cu.reportError("TelemetryStopwatch: failed to update the Histogram " +
`"${histogram}", using key: "${key}", ` +
`exception: ${Log.exceptionStr(e)}`);
}
return false;
--- a/toolkit/components/telemetry/TelemetryUtils.jsm
+++ b/toolkit/components/telemetry/TelemetryUtils.jsm
@@ -14,16 +14,17 @@ Cu.import("resource://gre/modules/Servic
const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
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;
})();
this.TelemetryUtils = {
Preferences: Object.freeze({
// General Preferences
ArchiveEnabled: "toolkit.telemetry.archive.enabled",
--- a/toolkit/components/telemetry/tests/unit/head.js
+++ b/toolkit/components/telemetry/tests/unit/head.js
@@ -21,17 +21,17 @@ XPCOMUtils.defineLazyModuleGetter(this,
XPCOMUtils.defineLazyModuleGetter(this, "Log",
"resource://gre/modules/Log.jsm");
const gIsWindows = AppConstants.platform == "win";
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;
const MILLISECONDS_PER_DAY = 24 * MILLISECONDS_PER_HOUR;
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
var gGlobalScope = this;
--- a/toolkit/components/thumbnails/test/browser_thumbnails_expiration.js
+++ b/toolkit/components/thumbnails/test/browser_thumbnails_expiration.js
@@ -2,19 +2,17 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
const URL = "http://mochi.test:8888/?t=" + Date.now();
const URL1 = URL + "#1";
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;
function* runTests() {
// Create dummy URLs.
let dummyURLs = [];
for (let i = 0; i < EXPIRATION_MIN_CHUNK_SIZE + 10; i++) {
--- a/toolkit/components/thumbnails/test/browser_thumbnails_storage.js
+++ b/toolkit/components/thumbnails/test/browser_thumbnails_storage.js
@@ -1,19 +1,17 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const URL = "http://mochi.test:8888/";
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;
});
/**
* These tests ensure that the thumbnail storage is working as intended.
* Newly captured thumbnails should be saved as files and they should as well
* be removed when the user sanitizes their history.
*/
--- a/toolkit/components/thumbnails/test/browser_thumbnails_storage_migrate3.js
+++ b/toolkit/components/thumbnails/test/browser_thumbnails_storage_migrate3.js
@@ -3,19 +3,17 @@
const URL = "http://mochi.test:8888/migration3";
const URL2 = URL + "#2";
const URL3 = URL + "#3";
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",
"@mozilla.org/file/directory_service;1", "nsIProperties");
/**
* This test makes sure we correctly migrate to thumbnail storage version 3.
* This means copying existing thumbnails from the roaming to the local profile
--- a/toolkit/components/urlformatter/tests/unit/test_urlformatter.js
+++ b/toolkit/components/urlformatter/tests/unit/test_urlformatter.js
@@ -1,38 +1,31 @@
/* 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;
try {
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.
defaults.setCharPref("distribution.id", "bacon");
defaults.setCharPref("distribution.version", "1.0");
var upperUrlRaw = "http://%LOCALE%.%VENDOR%.foo/?name=%NAME%&id=%ID%&version=%VERSION%&platversion=%PLATFORMVERSION%&abid=%APPBUILDID%&pbid=%PLATFORMBUILDID%&app=%APP%&os=%OS%&abi=%XPCOMABI%";
var lowerUrlRaw = "http://%locale%.%vendor%.foo/?name=%name%&id=%id%&version=%version%&platversion=%platformversion%&abid=%appbuildid%&pbid=%platformbuildid%&app=%app%&os=%os%&abi=%xpcomabi%";
@@ -41,17 +34,17 @@ function run_test() {
var multiUrl = "http://%VENDOR%.%VENDOR%.%NAME%.%VENDOR%.%NAME%";
var multiUrlRef = "http://Mozilla.Mozilla.Url Formatter Test.Mozilla.Url Formatter Test";
var encodedUrl = "https://%LOCALE%.%VENDOR%.foo/?q=%E3%82%BF%E3%83%96&app=%NAME%&ver=%PLATFORMVERSION%";
var encodedUrlRef = "https://" + locale + ".Mozilla.foo/?q=%E3%82%BF%E3%83%96&app=Url Formatter Test&ver=2.0";
var advancedUrl = "http://test.mozilla.com/%NAME%/%VERSION%/%APPBUILDID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/";
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);
// Keys must be uppercase
do_check_neq(formatter.formatURL(lowerUrlRaw), ulUrlRef);
do_check_eq(formatter.formatURL(multiUrl), multiUrlRef);
// Encoded strings must be kept as is (Bug 427304)
do_check_eq(formatter.formatURL(encodedUrl), encodedUrlRef);
--- a/toolkit/components/viewsource/content/viewSource.js
+++ b/toolkit/components/viewsource/content/viewSource.js
@@ -526,38 +526,33 @@ ViewSourceChrome.prototype = {
// other listener cancelled the event.
let types = event.dataTransfer.types;
if (types.includes("text/x-moz-text-internal") && !types.includes("text/plain")) {
event.dataTransfer.dropEffect = "none";
event.stopPropagation();
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();
}
},
/**
* Called twhen the user drops something onto the content browser.
*/
onDrop(event) {
if (event.defaultPrevented)
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;
}
if (uri) {
this.loadURL(uri);
}
},
--- a/toolkit/components/viewsource/content/viewSourceUtils.js
+++ b/toolkit/components/viewsource/content/viewSourceUtils.js
@@ -55,19 +55,17 @@ var gViewSourceUtils = {
* Accepted for compatibility reasons, but is otherwise ignored.
* @param aDocument (deprecated, optional)
* The content document we would like to view the source of. This
* function will throw if aDocument is a CPOW.
* @param aLineNumber (deprecated, optional)
* 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);
}
},
/**
* Displays view source in the provided <browser>. This allows for non-window
@@ -168,19 +166,17 @@ var gViewSourceUtils = {
aArgsOrURL, charset, aPageDescriptor, aLineNumber, isForcedCharset);
},
buildEditorArgs(aPath, aLineNumber) {
// Determine the command line arguments to pass to the editor.
// 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)
const argumentRE = /"([^"]+)"|(\S+)/g;
while (argumentRE.test(args))
editorArgs.push(RegExp.$1 || RegExp.$2);
}
editorArgs.push(aPath);
@@ -266,20 +262,18 @@ var gViewSourceUtils = {
try {
var editor = this.getExternalViewSourceEditor();
if (!editor) {
this.handleCallBack(aCallBack, false, data);
return;
}
// 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;
var contentType = data.doc ? data.doc.contentType : null;
if (uri.scheme == "file") {
// it's a local file; we can open it directly
path = uri.QueryInterface(Components.interfaces.nsIFileURL).file.path;
@@ -357,20 +351,18 @@ var gViewSourceUtils = {
aCallBack(result, data);
}
},
// Returns nsIProcess of the external view source editor or null
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);
return editor;
} catch (ex) {
Components.utils.reportError(ex);
}
@@ -488,24 +480,20 @@ var gViewSourceUtils = {
data: null,
file: null
},
// returns an nsIFile for the passed document in the system temp directory
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);
tempFile.append(leafName);
return tempFile;
}
};
--- a/toolkit/components/windowcreator/test/browser_bug1204626.js
+++ b/toolkit/components/windowcreator/test/browser_bug1204626.js
@@ -23,19 +23,17 @@ function one_test(delay, continuation) {
}
});
});
function onDocumentReady(doc) {
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();
tmpDir.append(nameStem + "_files");
registerCleanupFunction(function cleanUp() {
if (tmpFile.exists()) {
tmpFile.remove(/* recursive: */ false);
--- a/toolkit/components/windowcreator/test/test_bug1170334_wbp_xmlstyle.html
+++ b/toolkit/components/windowcreator/test/test_bug1170334_wbp_xmlstyle.html
@@ -24,21 +24,17 @@ let iframe = document.getElementById("if
SimpleTest.waitForExplicitFinish();
iframe.onload = function iframe_onload1() {
let doc = iframe.contentDocument;
ok(doc, "iframe content document exists");
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();
tmpDir.append(nameStem + "_files");
// When the document in the iframe is saved, try to load the result.
wbp.progressListener = {
onProgressChange() {},
@@ -55,17 +51,17 @@ iframe.onload = function iframe_onload1(
is(elem && elem.tagName, "thing", "document element tag");
if (elem && elem.tagName == "parsererror") {
ok(false, "Parser error: " + elem.textContent);
}
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);
function cleanUp() {
if (tmpFile.exists()) {
tmpFile.remove(/* recursive: */ false);
}
--- a/toolkit/components/windowcreator/test/test_bug1192654.html
+++ b/toolkit/components/windowcreator/test/test_bug1192654.html
@@ -31,19 +31,17 @@ let iframe = document.getElementById("if
SimpleTest.waitForExplicitFinish();
iframe.onload = function iframe_onload1() {
let doc = iframe.contentDocument;
ok(doc, "iframe content document exists");
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();
tmpDir.append(nameStem + "_files");
wbp.progressListener = {
onProgressChange() {},
onLocationChange() {},
--- a/toolkit/components/windowcreator/test/test_bug293834.html
+++ b/toolkit/components/windowcreator/test/test_bug293834.html
@@ -56,19 +56,17 @@ function checkform(doc) {
ok(doc.getElementById("aselect").selectedIndex == 0,
"Modified select selected index not preserved");
}
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) {
const PR_RDONLY = 0x01;
var fileStream = Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(Ci.nsIFileInputStream);
fileStream.init(aFile, PR_RDONLY, 0o400,
Ci.nsIFileInputStream.DELETE_ON_CLOSE
@@ -89,31 +87,27 @@ function persistDocument(aDoc) {
const nsIWBP = Ci.nsIWebBrowserPersist;
const persistFlags =
nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES
| nsIWBP.PERSIST_FLAGS_FROM_CACHE
| nsIWBP.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
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");
var persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
.createInstance(Ci.nsIWebBrowserPersist);
persist.progressListener = null;
persist.persistFlags = persistFlags;
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);
return getFileContents(file);
}
SimpleTest.waitForExplicitFinish();
--- a/toolkit/components/windowcreator/test/test_bug449141.html
+++ b/toolkit/components/windowcreator/test/test_bug449141.html
@@ -20,19 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cg
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 449141 **/
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
const STATE_STOP = 0x00000010;
var progressListener = {
onProgressChange() {
/* Ignore progress callback */
@@ -59,36 +57,33 @@ var progressListener = {
function persistDocument(aDoc) {
const nsIWBP = Ci.nsIWebBrowserPersist;
const persistFlags =
nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES
| nsIWBP.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
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;
var file = getTempDir();
file.append("bug449141-serialized" + id + ".html");
var persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
.createInstance(Ci.nsIWebBrowserPersist);
persist.progressListener = progressListener;
persist.persistFlags = persistFlags;
const kWrapColumn = 80;
var folder = getTempDir();
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);
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {