Bug 1230373 - Enable mozilla/use-services for browser/components/ r=mossop
MozReview-Commit-ID: 9m9iss3jUJJ
This commit is contained in:
@@ -14,7 +14,6 @@ add_task(async function() {
|
||||
// longer, we skip this for now.
|
||||
];
|
||||
|
||||
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
for (let cid in Cc) {
|
||||
let result = cid.match(/@mozilla.org\/network\/protocol\/about;1\?what\=(.*)$/);
|
||||
if (!result) {
|
||||
@@ -25,7 +24,7 @@ add_task(async function() {
|
||||
let contract = "@mozilla.org/network/protocol/about;1?what=" + aboutType;
|
||||
try {
|
||||
let am = Cc[contract].getService(Ci.nsIAboutModule);
|
||||
let uri = ios.newURI("about:" + aboutType);
|
||||
let uri = Services.io.newURI("about:" + aboutType);
|
||||
let flags = am.getURIFlags(uri);
|
||||
if (!(flags & Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT) &&
|
||||
networkURLs.indexOf(aboutType) == -1) {
|
||||
|
||||
@@ -121,18 +121,13 @@ add_task(async function test_quota_clearStoragesForPrincipal() {
|
||||
}
|
||||
|
||||
// Using quota manager to clear all indexed DB for a given domain.
|
||||
let qms = Cc["@mozilla.org/dom/quota-manager-service;1"].
|
||||
getService(Ci.nsIQuotaManagerService);
|
||||
|
||||
let caUtils = {};
|
||||
let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
|
||||
getService(Ci.mozIJSSubScriptLoader);
|
||||
scriptLoader.loadSubScript("chrome://global/content/contentAreaUtils.js",
|
||||
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.
|
||||
|
||||
@@ -7,10 +7,6 @@ const { classes: Cc, Constructor: CC, interfaces: Ci, utils: Cu } = Components;
|
||||
Cu.import("resource://gre/modules/ForgetAboutSite.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
let {HttpServer} = Cu.import("resource://testing-common/httpd.js", {});
|
||||
let LoadContextInfo = Cc["@mozilla.org/load-context-info-factory;1"]
|
||||
.getService(Ci.nsILoadContextInfoFactory);
|
||||
let css = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
|
||||
.getService(Ci.nsICacheStorageService);
|
||||
|
||||
const USER_CONTEXTS = [
|
||||
"default",
|
||||
@@ -72,18 +68,16 @@ function getCookiesForOA(host, userContextId) {
|
||||
}
|
||||
|
||||
function createURI(uri) {
|
||||
let ioServ = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
return ioServ.newURI(uri);
|
||||
return Services.io.newURI(uri);
|
||||
}
|
||||
|
||||
function getCacheStorage(where, lci, appcache) {
|
||||
if (!lci) lci = LoadContextInfo.default;
|
||||
if (!lci) lci = Services.loadContextInfo.default;
|
||||
switch (where) {
|
||||
case "disk": return css.diskCacheStorage(lci, false);
|
||||
case "memory": return css.memoryCacheStorage(lci);
|
||||
case "appcache": return css.appCacheStorage(lci, appcache);
|
||||
case "pin": return css.pinningCacheStorage(lci);
|
||||
case "disk": return Services.cache2.diskCacheStorage(lci, false);
|
||||
case "memory": return Services.cache2.memoryCacheStorage(lci);
|
||||
case "appcache": return Services.cache2.appCacheStorage(lci, appcache);
|
||||
case "pin": return Services.cache2.pinningCacheStorage(lci);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -166,19 +160,19 @@ async function test_cache_cleared() {
|
||||
await OpenCacheEntry("http://" + TEST_HOST + "/",
|
||||
"disk",
|
||||
Ci.nsICacheStorage.OPEN_NORMALLY,
|
||||
LoadContextInfo.custom(false, {userContextId}));
|
||||
Services.loadContextInfo.custom(false, {userContextId}));
|
||||
|
||||
await OpenCacheEntry("http://" + TEST_HOST + "/",
|
||||
"memory",
|
||||
Ci.nsICacheStorage.OPEN_NORMALLY,
|
||||
LoadContextInfo.custom(false, {userContextId}));
|
||||
Services.loadContextInfo.custom(false, {userContextId}));
|
||||
}
|
||||
|
||||
|
||||
// Check that caches have been set correctly.
|
||||
for (let userContextId of Object.keys(USER_CONTEXTS)) {
|
||||
let mem = getCacheStorage("memory", LoadContextInfo.custom(false, {userContextId}));
|
||||
let disk = getCacheStorage("disk", LoadContextInfo.custom(false, {userContextId}));
|
||||
let mem = getCacheStorage("memory", Services.loadContextInfo.custom(false, {userContextId}));
|
||||
let disk = getCacheStorage("disk", Services.loadContextInfo.custom(false, {userContextId}));
|
||||
|
||||
Assert.ok(mem.exists(createURI("http://" + TEST_HOST + "/"), ""), "The memory cache has been set correctly");
|
||||
Assert.ok(disk.exists(createURI("http://" + TEST_HOST + "/"), ""), "The disk cache has been set correctly");
|
||||
@@ -189,8 +183,8 @@ async function test_cache_cleared() {
|
||||
|
||||
// Check that do caches be removed or not?
|
||||
for (let userContextId of Object.keys(USER_CONTEXTS)) {
|
||||
let mem = getCacheStorage("memory", LoadContextInfo.custom(false, {userContextId}));
|
||||
let disk = getCacheStorage("disk", LoadContextInfo.custom(false, {userContextId}));
|
||||
let mem = getCacheStorage("memory", Services.loadContextInfo.custom(false, {userContextId}));
|
||||
let disk = getCacheStorage("disk", Services.loadContextInfo.custom(false, {userContextId}));
|
||||
|
||||
Assert.ok(!mem.exists(createURI("http://" + TEST_HOST + "/"), ""), "The memory cache is cleared");
|
||||
Assert.ok(!disk.exists(createURI("http://" + TEST_HOST + "/"), ""), "The disk cache is cleared");
|
||||
|
||||
Reference in New Issue
Block a user