Bug 1424862 - Enable mozilla/use-services from chrome/. r=mossop

MozReview-Commit-ID: ILZTMzuBAZ1

--HG--
extra : rebase_source : 3fe4420fa4fec5509c8174d4f6b7d636dfcc42ef
This commit is contained in:
Mark Banner 2017-12-11 20:29:28 +00:00
Родитель 69c59d84e2
Коммит 7242ebf417
14 изменённых файлов: 30 добавлений и 61 удалений

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

@ -32,7 +32,6 @@ module.exports = {
// Browser: Bug 1421379
"browser/extensions/shield-recipe-client/test/browser/head.js",
"browser/modules/offlineAppCache.jsm",
"chrome/**",
"devtools/**",
"dom/indexedDB/**",
"dom/media/**",

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

@ -1,10 +1,9 @@
const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
const XULAPPINFO_CID = Components.ID("{4ba645d3-be6f-40d6-a42a-01b2f40091b8}");
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
let {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");
function registerManifests(manifests) {
var reg = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);

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

@ -9,18 +9,15 @@ const MANIFESTS = [
registerManifests(MANIFESTS);
var gIOS;
var gCR;
function check_accessibility(spec, desired) {
var uri = gIOS.newURI(spec);
var uri = Services.io.newURI(spec);
var actual = gCR.allowContentToAccess(uri);
do_check_eq(desired, actual);
}
function run_test() {
gIOS = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
gCR = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIXULChromeRegistry);
gCR.checkForNewChrome();

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

@ -18,17 +18,15 @@ updateAppInfo({
platformVersion: "1.9",
});
var gIOS = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIChromeRegistry);
chromeReg.checkForNewChrome();
var target = gIOS.newFileURI(do_get_file("data"));
var target = Services.io.newFileURI(do_get_file("data"));
target = target.spec + "test/test.xul";
function test_succeeded_mapping(namespace) {
var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul");
var uri = Services.io.newURI("chrome://" + namespace + "/content/test.xul");
try {
var result = chromeReg.convertChromeURL(uri);
do_check_eq(result.spec, target);
@ -38,7 +36,7 @@ function test_succeeded_mapping(namespace) {
}
function test_failed_mapping(namespace) {
var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul");
var uri = Services.io.newURI("chrome://" + namespace + "/content/test.xul");
try {
chromeReg.convertChromeURL(uri);
do_throw(namespace);

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

@ -18,17 +18,15 @@ updateAppInfo({
platformVersion: "1.9",
});
var gIOS = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIChromeRegistry);
chromeReg.checkForNewChrome();
var target = gIOS.newFileURI(do_get_file("data"));
var target = Services.io.newFileURI(do_get_file("data"));
target = target.spec + "test/test.xul";
function test_succeeded_mapping(namespace) {
var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul");
var uri = Services.io.newURI("chrome://" + namespace + "/content/test.xul");
try {
var result = chromeReg.convertChromeURL(uri);
do_check_eq(result.spec, target);
@ -38,7 +36,7 @@ function test_succeeded_mapping(namespace) {
}
function test_failed_mapping(namespace) {
var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul");
var uri = Services.io.newURI("chrome://" + namespace + "/content/test.xul");
try {
chromeReg.convertChromeURL(uri);
do_throw(namespace);

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

@ -17,17 +17,15 @@ updateAppInfo({
platformVersion: "1.9",
});
var gIOS = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIChromeRegistry);
chromeReg.checkForNewChrome();
var target = gIOS.newFileURI(do_get_file("data"));
var target = Services.io.newFileURI(do_get_file("data"));
target = target.spec + "test/test.xul";
function test_succeeded_mapping(namespace) {
var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul");
var uri = Services.io.newURI("chrome://" + namespace + "/content/test.xul");
try {
var result = chromeReg.convertChromeURL(uri);
do_check_eq(result.spec, target);
@ -37,7 +35,7 @@ function test_succeeded_mapping(namespace) {
}
function test_failed_mapping(namespace) {
var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul");
var uri = Services.io.newURI("chrome://" + namespace + "/content/test.xul");
try {
chromeReg.convertChromeURL(uri);
do_throw(namespace);

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

@ -17,19 +17,17 @@ updateAppInfo({
platformVersion: "1.9",
});
var gIOS = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIChromeRegistry);
chromeReg.checkForNewChrome();
var rph = gIOS.getProtocolHandler("resource")
var rph = Services.io.getProtocolHandler("resource")
.QueryInterface(Ci.nsIResProtocolHandler);
function test_succeeded_mapping(namespace, target) {
try {
do_check_true(rph.hasSubstitution(namespace));
var uri = gIOS.newURI("resource://" + namespace);
var uri = Services.io.newURI("resource://" + namespace);
dump("### checking for " + target + ", getting " + rph.resolveURI(uri) + "\n");
do_check_eq(rph.resolveURI(uri), target);
} catch (ex) {
@ -43,7 +41,7 @@ function test_failed_mapping(namespace) {
}
function run_test() {
var data = gIOS.newFileURI(do_get_file("data")).spec;
var data = Services.io.newFileURI(do_get_file("data")).spec;
test_succeeded_mapping("test1", data + "test1/");
test_succeeded_mapping("test3", "jar:" + data + "test3.jar!/resources/");
test_failed_mapping("test4");

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

@ -3,15 +3,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var gIOS = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
function test_uri(obj) {
var uri = null;
var failed = false;
var message = "";
try {
uri = gIOS.newURI(obj.uri);
uri = Services.io.newURI(obj.uri);
if (!obj.result) {
failed = true;
message = obj.uri + " should not be accepted as a valid URI";

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

@ -6,9 +6,6 @@
const UNPACKAGED_ADDON = do_get_file("data/test_bug564667");
const PACKAGED_ADDON = do_get_file("data/test_bug564667.xpi");
var gIOS = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var gCR = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIChromeRegistry).
QueryInterface(Ci.nsIXULOverlayProvider);
@ -17,7 +14,7 @@ var gCR = Cc["@mozilla.org/chrome/chrome-registry;1"].
* Checks that a mapping was added
*/
function test_mapping(chromeURL, target) {
var uri = gIOS.newURI(chromeURL);
var uri = Services.io.newURI(chromeURL);
try {
var result = gCR.convertChromeURL(uri);
@ -31,7 +28,7 @@ function test_mapping(chromeURL, target) {
* Checks that a mapping was removed
*/
function test_removed_mapping(chromeURL, target) {
var uri = gIOS.newURI(chromeURL);
var uri = Services.io.newURI(chromeURL);
try {
gCR.convertChromeURL(uri);
do_throw(chromeURL + " not removed");
@ -47,7 +44,7 @@ function test_removed_mapping(chromeURL, target) {
* @param type The type of overlay: overlay|style
*/
function test_no_overlays(chromeURL, target, type = "overlay") {
var uri = gIOS.newURI(chromeURL);
var uri = Services.io.newURI(chromeURL);
var overlays = (type == "overlay") ?
gCR.getXULOverlays(uri) : gCR.getStyleOverlays(uri);
@ -109,8 +106,8 @@ function testManifest(manifestPath, baseURI) {
function run_test() {
// Test an unpackaged addon
testManifest(UNPACKAGED_ADDON, gIOS.newFileURI(UNPACKAGED_ADDON).spec);
testManifest(UNPACKAGED_ADDON, Services.io.newFileURI(UNPACKAGED_ADDON).spec);
// Test a packaged addon
testManifest(PACKAGED_ADDON, "jar:" + gIOS.newFileURI(PACKAGED_ADDON).spec + "!/");
testManifest(PACKAGED_ADDON, "jar:" + Services.io.newFileURI(PACKAGED_ADDON).spec + "!/");
}

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

@ -18,10 +18,6 @@ var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
.QueryInterface(Ci.nsIToolkitChromeRegistry);
chromeReg.checkForNewChrome();
var prefService = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService)
.QueryInterface(Ci.nsIPrefBranch);
function enum_to_array(strings) {
let rv = [];
while (strings.hasMore()) {
@ -41,7 +37,7 @@ function run_test() {
["en-US", "fr"]);
// with override
prefService.setCharPref("chrome.override_package.basepack", "overpack");
Services.prefs.setCharPref("chrome.override_package.basepack", "overpack");
do_check_eq(chromeReg.getSelectedLocale("basepack"), "de");
do_check_matches(enum_to_array(chromeReg.getLocalesForPackage("basepack")),
["de", "en-US"]);

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

@ -4,9 +4,7 @@ function run_test() {
let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIChromeRegistry);
let ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
let sourceURI = ios.newURI("chrome://test_crlf/content/");
let sourceURI = Services.io.newURI("chrome://test_crlf/content/");
// this throws for packages that are not registered
let file = cr.convertChromeURL(sourceURI).QueryInterface(Ci.nsIFileURL).file;

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

@ -78,9 +78,7 @@ function run_test() {
let expectedURI = "data:application/vnd.mozilla.xul+xml,";
let sourceURI = "chrome://good-package/content/test.xul";
try {
let ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
sourceURI = ios.newURI(sourceURI);
sourceURI = Services.io.newURI(sourceURI);
// this throws for packages that are not registered
let uri = cr.convertChromeURL(sourceURI).spec;

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

@ -178,13 +178,11 @@ function run_test() {
break;
}
try {
let ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
sourceURI = ios.newURI(sourceURI);
sourceURI = Services.io.newURI(sourceURI);
let uri;
if (type == "resource") {
// resources go about a slightly different way than everything else
let rph = ios.getProtocolHandler("resource").
let rph = Services.io.getProtocolHandler("resource").
QueryInterface(Ci.nsIResProtocolHandler);
// this throws for packages that are not registered
uri = rph.resolveURI(sourceURI);

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

@ -13,9 +13,6 @@ var manifestFile = do_get_file("../unit/data/test_resolve_uris.manifest");
var manifests = [ manifestFile ];
registerManifests(manifests);
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
function do_run_test() {
let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIChromeRegistry);
@ -24,6 +21,7 @@ function do_run_test() {
// we don't need to worry about checking for new chrome.
var appInfo = Cc["@mozilla.org/xre/app-info;1"];
if (!appInfo ||
// eslint-disable-next-line mozilla/use-services
(appInfo.getService(Ci.nsIXULRuntime).processType ==
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT)) {
cr.checkForNewChrome();
@ -58,16 +56,16 @@ function do_run_test() {
expectedURI += "override-me.xul";
break;
case "resource":
expectedURI = ios.newFileURI(manifestFile.parent).spec;
expectedURI = Services.io.newFileURI(manifestFile.parent).spec;
sourceURI = "resource://foo/";
break;
}
try {
sourceURI = ios.newURI(sourceURI);
sourceURI = Services.io.newURI(sourceURI);
let uri;
if (type == "resource") {
// resources go about a slightly different way than everything else
let rph = ios.getProtocolHandler("resource").
let rph = Services.io.getProtocolHandler("resource").
QueryInterface(Ci.nsIResProtocolHandler);
uri = rph.resolveURI(sourceURI);
} else {