mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1741167 - Enable ESLint rule mozilla/use-services for rest of netwerk. r=necko-reviewers,dragana
Differential Revision: https://phabricator.services.mozilla.com/D131131
This commit is contained in:
parent
9985ff4a0f
commit
b5e3aa0e47
@ -249,7 +249,6 @@ module.exports = {
|
||||
rules: {
|
||||
"mozilla/no-arbitrary-setTimeout": "off",
|
||||
"mozilla/no-define-cc-etc": "off",
|
||||
"mozilla/use-services": "off",
|
||||
"consistent-return": "off",
|
||||
"no-eval": "off",
|
||||
"no-global-assign": "off",
|
||||
|
@ -9,8 +9,6 @@ const COOKIE_NAMES = ["cookie0", "cookie1", "cookie2"];
|
||||
const TEST_URL =
|
||||
"http://example.com/browser/netwerk/cookie/test/browser/file_empty.html";
|
||||
|
||||
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
|
||||
// opens `uri' in a new tab with the provided userContextId and focuses it.
|
||||
// returns the newly opened tab
|
||||
async function openTabInUserContext(uri, userContextId) {
|
||||
@ -63,7 +61,9 @@ add_task(async function test() {
|
||||
await checkCookies(expectedValues, "before removal");
|
||||
|
||||
// remove cookies that belongs to user context id #1
|
||||
cm.removeCookiesWithOriginAttributes(JSON.stringify({ userContextId: 1 }));
|
||||
Services.cookies.removeCookiesWithOriginAttributes(
|
||||
JSON.stringify({ userContextId: 1 })
|
||||
);
|
||||
|
||||
expectedValues[1] = undefined;
|
||||
await checkCookies(expectedValues, "after removal");
|
||||
@ -92,7 +92,7 @@ async function checkCookies(expectedValues, time) {
|
||||
|
||||
function getCookiesFromManager(userContextId) {
|
||||
let cookies = {};
|
||||
let allCookies = cm.getCookiesWithOriginAttributes(
|
||||
let allCookies = Services.cookies.getCookiesWithOriginAttributes(
|
||||
JSON.stringify({ userContextId })
|
||||
);
|
||||
for (let cookie of allCookies) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
let cs = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
|
||||
addMessageListener("getCookieCountAndClear", () => {
|
||||
|
@ -3,6 +3,7 @@
|
||||
"use strict";
|
||||
|
||||
function getCookieService() {
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
return Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* eslint-env mozilla/frame-script */
|
||||
/* eslint-disable mozilla/use-services */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -27,10 +27,7 @@ function evict_cache_entries(where) {
|
||||
}
|
||||
|
||||
function createURI(urispec) {
|
||||
var ioServ = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
return ioServ.newURI(urispec);
|
||||
return Services.io.newURI(urispec);
|
||||
}
|
||||
|
||||
function getCacheStorage(where, lci) {
|
||||
|
@ -22,6 +22,7 @@ XPCOMUtils.defineLazyServiceGetter(
|
||||
"@mozilla.org/cookieService;1",
|
||||
"nsICookieService"
|
||||
);
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
Services,
|
||||
"cookiemgr",
|
||||
@ -29,13 +30,6 @@ XPCOMUtils.defineLazyServiceGetter(
|
||||
"nsICookieManager"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
Services,
|
||||
"etld",
|
||||
"@mozilla.org/network/effective-tld-service;1",
|
||||
"nsIEffectiveTLDService"
|
||||
);
|
||||
|
||||
function do_check_throws(f, result, stack) {
|
||||
if (!stack) {
|
||||
stack = Components.stack.caller;
|
||||
@ -243,7 +237,7 @@ function Cookie(
|
||||
let strippedHost = host.charAt(0) == "." ? host.slice(1) : host;
|
||||
|
||||
try {
|
||||
this.baseDomain = Services.etld.getBaseDomainFromHost(strippedHost);
|
||||
this.baseDomain = Services.eTLD.getBaseDomainFromHost(strippedHost);
|
||||
} catch (e) {
|
||||
if (
|
||||
e.result == Cr.NS_ERROR_HOST_IS_IP_ADDRESS ||
|
||||
|
@ -123,6 +123,8 @@ class TRRDNSListener {
|
||||
this.type = this.options.type ?? Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT;
|
||||
let trrServer = this.options.trrServer || "";
|
||||
|
||||
// This may be called in a child process that doesn't have Services available.
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
const threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
|
@ -18,11 +18,6 @@ XPCOMUtils.defineLazyGetter(this, "baseURI", function() {
|
||||
const unexpected304 = "unexpected304";
|
||||
const existingCached304 = "existingCached304";
|
||||
|
||||
function make_uri(url) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
return ios.newURI(url);
|
||||
}
|
||||
|
||||
function make_channel(url) {
|
||||
return NetUtil.newChannel({
|
||||
uri: url,
|
||||
@ -30,13 +25,6 @@ function make_channel(url) {
|
||||
}).QueryInterface(Ci.nsIHttpChannel);
|
||||
}
|
||||
|
||||
function clearCache() {
|
||||
var service = Cc["@mozilla.org/netwerk/cache-storage-service;1"].getService(
|
||||
Ci.nsICacheStorageService
|
||||
);
|
||||
service.clear();
|
||||
}
|
||||
|
||||
function alwaysReturn304Handler(metadata, response) {
|
||||
response.setStatusLine(metadata.httpVersion, 304, "Not Modified");
|
||||
response.setHeader("Returned-From-Handler", "1");
|
||||
|
@ -78,10 +78,7 @@ function run_test() {
|
||||
httpserver.registerPathHandler("/content", contentHandler);
|
||||
httpserver.start(-1);
|
||||
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
prefs.setBoolPref("network.http.prompt-temp-redirect", false);
|
||||
Services.prefs.setBoolPref("network.http.prompt-temp-redirect", false);
|
||||
|
||||
var chan = make_channel(noRedirectURI);
|
||||
var uploadStream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
|
||||
|
@ -61,9 +61,7 @@ function async_write_file(aContractId, aDeferOpen) {
|
||||
do_test_pending();
|
||||
|
||||
// First, we need an output file to write to.
|
||||
let file = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("ProfD", Ci.nsIFile);
|
||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
file.append("NetUtil-async-test-file.tmp");
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
|
||||
|
||||
@ -122,9 +120,7 @@ function test_async_copy() {
|
||||
}
|
||||
|
||||
// File input streams are not buffered, so let's create a file
|
||||
let file = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("ProfD", Ci.nsIFile);
|
||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
file.append("NetUtil-asyncFetch-test-file.tmp");
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
|
||||
|
||||
@ -145,9 +141,7 @@ function test_async_copy() {
|
||||
|
||||
// Create an output buffer holding some data
|
||||
function make_output(isBuffered) {
|
||||
let file = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("ProfD", Ci.nsIFile);
|
||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
file.append("NetUtil-asyncFetch-test-file.tmp");
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
|
||||
|
||||
@ -226,12 +220,10 @@ function test_newURI_no_spec_throws() {
|
||||
}
|
||||
|
||||
function test_newURI() {
|
||||
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
// Check that we get the same URI back from the IO service and the utility
|
||||
// method.
|
||||
const TEST_URI = "http://mozilla.org";
|
||||
let iosURI = ios.newURI(TEST_URI);
|
||||
let iosURI = Services.io.newURI(TEST_URI);
|
||||
let NetUtilURI = NetUtil.newURI(TEST_URI);
|
||||
Assert.ok(iosURI.equals(NetUtilURI));
|
||||
|
||||
@ -239,17 +231,13 @@ function test_newURI() {
|
||||
}
|
||||
|
||||
function test_newURI_takes_nsIFile() {
|
||||
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
// Create a test file that we can pass into NetUtil.newURI
|
||||
let file = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("ProfD", Ci.nsIFile);
|
||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
file.append("NetUtil-test-file.tmp");
|
||||
|
||||
// Check that we get the same URI back from the IO service and the utility
|
||||
// method.
|
||||
let iosURI = ios.newFileURI(file);
|
||||
let iosURI = Services.io.newFileURI(file);
|
||||
let NetUtilURI = NetUtil.newURI(file);
|
||||
Assert.ok(iosURI.equals(NetUtilURI));
|
||||
|
||||
@ -405,9 +393,7 @@ function test_asyncFetch_with_nsIFile() {
|
||||
const TEST_DATA = "this is a test string";
|
||||
|
||||
// First we need a file to read from.
|
||||
let file = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("ProfD", Ci.nsIFile);
|
||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
file.append("NetUtil-asyncFetch-test-file.tmp");
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
|
||||
|
||||
@ -527,8 +513,7 @@ function test_newChannel_with_string() {
|
||||
|
||||
// Check that we get the same URI back from channel the IO service creates and
|
||||
// the channel the utility method creates.
|
||||
let ios = Services.io;
|
||||
let iosChannel = ios.newChannel(
|
||||
let iosChannel = Services.io.newChannel(
|
||||
TEST_SPEC,
|
||||
null,
|
||||
null,
|
||||
|
@ -5,10 +5,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
var gIoService = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
|
||||
// Run by: cd objdir; make -C netwerk/test/ xpcshell-tests
|
||||
// or: cd objdir; make SOLO_FILE="test_URIs.js" -C netwerk/test/ check-one
|
||||
|
||||
@ -434,7 +430,7 @@ function do_test_uri_basic(aTest) {
|
||||
var relURI;
|
||||
|
||||
try {
|
||||
relURI = gIoService.newURI(aTest.relativeURI, null, URI);
|
||||
relURI = Services.io.newURI(aTest.relativeURI, null, URI);
|
||||
} catch (e) {
|
||||
do_info(
|
||||
"Caught error on Relative parse of " +
|
||||
@ -518,7 +514,7 @@ function do_test_uri_with_hash_suffix(aTest, aSuffix) {
|
||||
|
||||
if (aTest.relativeURI) {
|
||||
try {
|
||||
origURI = gIoService.newURI(aTest.relativeURI, null, origURI);
|
||||
origURI = Services.io.newURI(aTest.relativeURI, null, origURI);
|
||||
} catch (e) {
|
||||
do_info(
|
||||
"Caught error on Relative parse of " +
|
||||
@ -531,7 +527,7 @@ function do_test_uri_with_hash_suffix(aTest, aSuffix) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
testURI = gIoService.newURI(aSuffix, null, origURI);
|
||||
testURI = Services.io.newURI(aSuffix, null, origURI);
|
||||
} catch (e) {
|
||||
do_info(
|
||||
"Caught error adding suffix to " +
|
||||
@ -751,8 +747,8 @@ function do_test_mutate_ref(aTest, aSuffix) {
|
||||
// Check that changing nested/about URIs works correctly.
|
||||
add_task(function check_nested_mutations() {
|
||||
// nsNestedAboutURI
|
||||
let uri1 = gIoService.newURI("about:blank#");
|
||||
let uri2 = gIoService.newURI("about:blank");
|
||||
let uri1 = Services.io.newURI("about:blank#");
|
||||
let uri2 = Services.io.newURI("about:blank");
|
||||
let uri3 = uri1
|
||||
.mutate()
|
||||
.setRef("")
|
||||
@ -764,8 +760,8 @@ add_task(function check_nested_mutations() {
|
||||
.finalize();
|
||||
do_check_uri_eq(uri3, uri1);
|
||||
|
||||
uri1 = gIoService.newURI("about:blank?something");
|
||||
uri2 = gIoService.newURI("about:blank");
|
||||
uri1 = Services.io.newURI("about:blank?something");
|
||||
uri2 = Services.io.newURI("about:blank");
|
||||
uri3 = uri1
|
||||
.mutate()
|
||||
.setQuery("")
|
||||
@ -777,8 +773,8 @@ add_task(function check_nested_mutations() {
|
||||
.finalize();
|
||||
do_check_uri_eq(uri3, uri1);
|
||||
|
||||
uri1 = gIoService.newURI("about:blank?query#ref");
|
||||
uri2 = gIoService.newURI("about:blank");
|
||||
uri1 = Services.io.newURI("about:blank?query#ref");
|
||||
uri2 = Services.io.newURI("about:blank");
|
||||
uri3 = uri1
|
||||
.mutate()
|
||||
.setPathQueryRef("blank")
|
||||
@ -791,8 +787,8 @@ add_task(function check_nested_mutations() {
|
||||
do_check_uri_eq(uri3, uri1);
|
||||
|
||||
// nsSimpleNestedURI
|
||||
uri1 = gIoService.newURI("view-source:http://example.com/path#");
|
||||
uri2 = gIoService.newURI("view-source:http://example.com/path");
|
||||
uri1 = Services.io.newURI("view-source:http://example.com/path#");
|
||||
uri2 = Services.io.newURI("view-source:http://example.com/path");
|
||||
uri3 = uri1
|
||||
.mutate()
|
||||
.setRef("")
|
||||
@ -804,8 +800,8 @@ add_task(function check_nested_mutations() {
|
||||
.finalize();
|
||||
do_check_uri_eq(uri3, uri1);
|
||||
|
||||
uri1 = gIoService.newURI("view-source:http://example.com/path?something");
|
||||
uri2 = gIoService.newURI("view-source:http://example.com/path");
|
||||
uri1 = Services.io.newURI("view-source:http://example.com/path?something");
|
||||
uri2 = Services.io.newURI("view-source:http://example.com/path");
|
||||
uri3 = uri1
|
||||
.mutate()
|
||||
.setQuery("")
|
||||
@ -817,8 +813,8 @@ add_task(function check_nested_mutations() {
|
||||
.finalize();
|
||||
do_check_uri_eq(uri3, uri1);
|
||||
|
||||
uri1 = gIoService.newURI("view-source:http://example.com/path?query#ref");
|
||||
uri2 = gIoService.newURI("view-source:http://example.com/path");
|
||||
uri1 = Services.io.newURI("view-source:http://example.com/path?query#ref");
|
||||
uri2 = Services.io.newURI("view-source:http://example.com/path");
|
||||
uri3 = uri1
|
||||
.mutate()
|
||||
.setPathQueryRef("path")
|
||||
@ -830,8 +826,8 @@ add_task(function check_nested_mutations() {
|
||||
.finalize();
|
||||
do_check_uri_eq(uri3, uri1);
|
||||
|
||||
uri1 = gIoService.newURI("view-source:about:blank#");
|
||||
uri2 = gIoService.newURI("view-source:about:blank");
|
||||
uri1 = Services.io.newURI("view-source:about:blank#");
|
||||
uri2 = Services.io.newURI("view-source:about:blank");
|
||||
uri3 = uri1
|
||||
.mutate()
|
||||
.setRef("")
|
||||
@ -843,8 +839,8 @@ add_task(function check_nested_mutations() {
|
||||
.finalize();
|
||||
do_check_uri_eq(uri3, uri1);
|
||||
|
||||
uri1 = gIoService.newURI("view-source:about:blank?something");
|
||||
uri2 = gIoService.newURI("view-source:about:blank");
|
||||
uri1 = Services.io.newURI("view-source:about:blank?something");
|
||||
uri2 = Services.io.newURI("view-source:about:blank");
|
||||
uri3 = uri1
|
||||
.mutate()
|
||||
.setQuery("")
|
||||
@ -856,8 +852,8 @@ add_task(function check_nested_mutations() {
|
||||
.finalize();
|
||||
do_check_uri_eq(uri3, uri1);
|
||||
|
||||
uri1 = gIoService.newURI("view-source:about:blank?query#ref");
|
||||
uri2 = gIoService.newURI("view-source:about:blank");
|
||||
uri1 = Services.io.newURI("view-source:about:blank?query#ref");
|
||||
uri2 = Services.io.newURI("view-source:about:blank");
|
||||
uri3 = uri1
|
||||
.mutate()
|
||||
.setPathQueryRef("blank")
|
||||
@ -871,34 +867,34 @@ add_task(function check_nested_mutations() {
|
||||
});
|
||||
|
||||
add_task(function check_space_escaping() {
|
||||
let uri = gIoService.newURI("data:text/plain,hello%20world#space hash");
|
||||
let uri = Services.io.newURI("data:text/plain,hello%20world#space hash");
|
||||
Assert.equal(uri.spec, "data:text/plain,hello%20world#space%20hash");
|
||||
uri = gIoService.newURI("data:text/plain,hello%20world#space%20hash");
|
||||
uri = Services.io.newURI("data:text/plain,hello%20world#space%20hash");
|
||||
Assert.equal(uri.spec, "data:text/plain,hello%20world#space%20hash");
|
||||
uri = gIoService.newURI("data:text/plain,hello world#space%20hash");
|
||||
uri = Services.io.newURI("data:text/plain,hello world#space%20hash");
|
||||
Assert.equal(uri.spec, "data:text/plain,hello world#space%20hash");
|
||||
uri = gIoService.newURI("data:text/plain,hello world#space hash");
|
||||
uri = Services.io.newURI("data:text/plain,hello world#space hash");
|
||||
Assert.equal(uri.spec, "data:text/plain,hello world#space%20hash");
|
||||
uri = gIoService.newURI("http://example.com/test path#test path");
|
||||
uri = gIoService.newURI("http://example.com/test%20path#test%20path");
|
||||
uri = Services.io.newURI("http://example.com/test path#test path");
|
||||
uri = Services.io.newURI("http://example.com/test%20path#test%20path");
|
||||
});
|
||||
|
||||
add_task(function check_schemeIsNull() {
|
||||
let uri = gIoService.newURI("data:text/plain,aaa");
|
||||
let uri = Services.io.newURI("data:text/plain,aaa");
|
||||
Assert.ok(!uri.schemeIs(null));
|
||||
uri = gIoService.newURI("http://example.com");
|
||||
uri = Services.io.newURI("http://example.com");
|
||||
Assert.ok(!uri.schemeIs(null));
|
||||
uri = gIoService.newURI("dummyscheme://example.com");
|
||||
uri = Services.io.newURI("dummyscheme://example.com");
|
||||
Assert.ok(!uri.schemeIs(null));
|
||||
uri = gIoService.newURI("jar:resource://gre/chrome.toolkit.jar!/");
|
||||
uri = Services.io.newURI("jar:resource://gre/chrome.toolkit.jar!/");
|
||||
Assert.ok(!uri.schemeIs(null));
|
||||
uri = gIoService.newURI("moz-icon://.unknown?size=32");
|
||||
uri = Services.io.newURI("moz-icon://.unknown?size=32");
|
||||
Assert.ok(!uri.schemeIs(null));
|
||||
});
|
||||
|
||||
// Check that characters in the query of moz-extension aren't improperly unescaped (Bug 1547882)
|
||||
add_task(function check_mozextension_query() {
|
||||
let uri = gIoService.newURI(
|
||||
let uri = Services.io.newURI(
|
||||
"moz-extension://a7d1572e-3beb-4d93-a920-c408fa09e8ea/_source/holding.html"
|
||||
);
|
||||
uri = uri
|
||||
@ -906,7 +902,7 @@ add_task(function check_mozextension_query() {
|
||||
.setQuery("u=https%3A%2F%2Fnews.ycombinator.com%2F")
|
||||
.finalize();
|
||||
Assert.equal(uri.query, "u=https%3A%2F%2Fnews.ycombinator.com%2F");
|
||||
uri = gIoService.newURI(
|
||||
uri = Services.io.newURI(
|
||||
"moz-extension://a7d1572e-3beb-4d93-a920-c408fa09e8ea/_source/holding.html?u=https%3A%2F%2Fnews.ycombinator.com%2F"
|
||||
);
|
||||
Assert.equal(
|
||||
@ -917,29 +913,29 @@ add_task(function check_mozextension_query() {
|
||||
});
|
||||
|
||||
add_task(function check_resolve() {
|
||||
let base = gIoService.newURI("http://example.com");
|
||||
let uri = gIoService.newURI("tel::+371 27028456", "utf-8", base);
|
||||
let base = Services.io.newURI("http://example.com");
|
||||
let uri = Services.io.newURI("tel::+371 27028456", "utf-8", base);
|
||||
Assert.equal(uri.spec, "tel::+371 27028456");
|
||||
});
|
||||
|
||||
add_task(function test_extra_protocols() {
|
||||
// dweb://
|
||||
let url = gIoService.newURI("dweb://example.com/test");
|
||||
let url = Services.io.newURI("dweb://example.com/test");
|
||||
Assert.equal(url.host, "example.com");
|
||||
|
||||
// dat://
|
||||
url = gIoService.newURI(
|
||||
url = Services.io.newURI(
|
||||
"dat://41f8a987cfeba80a037e51cc8357d513b62514de36f2f9b3d3eeec7a8fb3b5a5/"
|
||||
);
|
||||
Assert.equal(
|
||||
url.host,
|
||||
"41f8a987cfeba80a037e51cc8357d513b62514de36f2f9b3d3eeec7a8fb3b5a5"
|
||||
);
|
||||
url = gIoService.newURI("dat://example.com/test");
|
||||
url = Services.io.newURI("dat://example.com/test");
|
||||
Assert.equal(url.host, "example.com");
|
||||
|
||||
// ipfs://
|
||||
url = gIoService.newURI(
|
||||
url = Services.io.newURI(
|
||||
"ipfs://bafybeiccfclkdtucu6y4yc5cpr6y3yuinr67svmii46v5cfcrkp47ihehy/frontend/license.txt"
|
||||
);
|
||||
Assert.equal(url.scheme, "ipfs");
|
||||
@ -950,19 +946,19 @@ add_task(function test_extra_protocols() {
|
||||
Assert.equal(url.filePath, "/frontend/license.txt");
|
||||
|
||||
// ipns://
|
||||
url = gIoService.newURI("ipns://peerdium.gozala.io/index.html");
|
||||
url = Services.io.newURI("ipns://peerdium.gozala.io/index.html");
|
||||
Assert.equal(url.scheme, "ipns");
|
||||
Assert.equal(url.host, "peerdium.gozala.io");
|
||||
Assert.equal(url.filePath, "/index.html");
|
||||
|
||||
// ssb://
|
||||
url = gIoService.newURI("ssb://scuttlebutt.nz/index.html");
|
||||
url = Services.io.newURI("ssb://scuttlebutt.nz/index.html");
|
||||
Assert.equal(url.scheme, "ssb");
|
||||
Assert.equal(url.host, "scuttlebutt.nz");
|
||||
Assert.equal(url.filePath, "/index.html");
|
||||
|
||||
// wtp://
|
||||
url = gIoService.newURI(
|
||||
url = Services.io.newURI(
|
||||
"wtp://951ead31d09e4049fc1f21f137e233dd0589fcbd/blog/vim-tips/"
|
||||
);
|
||||
Assert.equal(url.scheme, "wtp");
|
||||
@ -975,9 +971,9 @@ add_task(function test_extra_protocols() {
|
||||
add_task(function mainTest() {
|
||||
// UTF-8 check - From bug 622981
|
||||
// ASCII
|
||||
let base = gIoService.newURI("http://example.org/xenia?");
|
||||
let resolved = gIoService.newURI("?x", null, base);
|
||||
let expected = gIoService.newURI("http://example.org/xenia?x");
|
||||
let base = Services.io.newURI("http://example.org/xenia?");
|
||||
let resolved = Services.io.newURI("?x", null, base);
|
||||
let expected = Services.io.newURI("http://example.org/xenia?x");
|
||||
do_info(
|
||||
"Bug 662981: ACSII - comparing " + resolved.spec + " and " + expected.spec
|
||||
);
|
||||
@ -985,9 +981,9 @@ add_task(function mainTest() {
|
||||
|
||||
// UTF-8 character "è"
|
||||
// Bug 622981 was triggered by an empty query string
|
||||
base = gIoService.newURI("http://example.org/xènia?");
|
||||
resolved = gIoService.newURI("?x", null, base);
|
||||
expected = gIoService.newURI("http://example.org/xènia?x");
|
||||
base = Services.io.newURI("http://example.org/xènia?");
|
||||
resolved = Services.io.newURI("?x", null, base);
|
||||
expected = Services.io.newURI("http://example.org/xènia?x");
|
||||
do_info(
|
||||
"Bug 662981: UTF8 - comparing " + resolved.spec + " and " + expected.spec
|
||||
);
|
||||
@ -1017,7 +1013,7 @@ add_task(function mainTest() {
|
||||
|
||||
function check_round_trip_serialization(spec) {
|
||||
dump(`checking ${spec}\n`);
|
||||
let uri = gIoService.newURI(spec);
|
||||
let uri = Services.io.newURI(spec);
|
||||
let str = serialize_to_escaped_string(uri);
|
||||
let other = deserialize_from_escaped_string(str).QueryInterface(Ci.nsIURI);
|
||||
equal(other.spec, uri.spec);
|
||||
|
@ -1,10 +1,6 @@
|
||||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
"use strict";
|
||||
|
||||
var gIoService = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
|
||||
// Run by: cd objdir; make -C netwerk/test/ xpcshell-tests
|
||||
// or: cd objdir; make SOLO_FILE="test_URIs2.js" -C netwerk/test/ check-one
|
||||
|
||||
@ -574,7 +570,7 @@ function do_test_uri_basic(aTest) {
|
||||
var relURI;
|
||||
|
||||
try {
|
||||
relURI = gIoService.newURI(aTest.relativeURI, null, URI);
|
||||
relURI = Services.io.newURI(aTest.relativeURI, null, URI);
|
||||
} catch (e) {
|
||||
do_info(
|
||||
"Caught error on Relative parse of " +
|
||||
@ -658,7 +654,7 @@ function do_test_uri_with_hash_suffix(aTest, aSuffix) {
|
||||
|
||||
if (aTest.relativeURI) {
|
||||
try {
|
||||
origURI = gIoService.newURI(aTest.relativeURI, null, origURI);
|
||||
origURI = Services.io.newURI(aTest.relativeURI, null, origURI);
|
||||
} catch (e) {
|
||||
do_info(
|
||||
"Caught error on Relative parse of " +
|
||||
@ -671,7 +667,7 @@ function do_test_uri_with_hash_suffix(aTest, aSuffix) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
testURI = gIoService.newURI(aSuffix, null, origURI);
|
||||
testURI = Services.io.newURI(aSuffix, null, origURI);
|
||||
} catch (e) {
|
||||
do_info(
|
||||
"Caught error adding suffix to " +
|
||||
@ -865,9 +861,9 @@ function do_test_mutate_ref(aTest, aSuffix) {
|
||||
function run_test() {
|
||||
// UTF-8 check - From bug 622981
|
||||
// ASCII
|
||||
let base = gIoService.newURI("http://example.org/xenia?");
|
||||
let resolved = gIoService.newURI("?x", null, base);
|
||||
let expected = gIoService.newURI("http://example.org/xenia?x");
|
||||
let base = Services.io.newURI("http://example.org/xenia?");
|
||||
let resolved = Services.io.newURI("?x", null, base);
|
||||
let expected = Services.io.newURI("http://example.org/xenia?x");
|
||||
do_info(
|
||||
"Bug 662981: ACSII - comparing " + resolved.spec + " and " + expected.spec
|
||||
);
|
||||
@ -875,9 +871,9 @@ function run_test() {
|
||||
|
||||
// UTF-8 character "è"
|
||||
// Bug 622981 was triggered by an empty query string
|
||||
base = gIoService.newURI("http://example.org/xènia?");
|
||||
resolved = gIoService.newURI("?x", null, base);
|
||||
expected = gIoService.newURI("http://example.org/xènia?x");
|
||||
base = Services.io.newURI("http://example.org/xènia?");
|
||||
resolved = Services.io.newURI("?x", null, base);
|
||||
expected = Services.io.newURI("http://example.org/xènia?x");
|
||||
do_info(
|
||||
"Bug 662981: UTF8 - comparing " + resolved.spec + " and " + expected.spec
|
||||
);
|
||||
|
@ -102,13 +102,9 @@ function run_test() {
|
||||
// We always resolve localhost as it's hardcoded without the following pref:
|
||||
Services.prefs.setBoolPref("network.proxy.allow_hijacking_localhost", true);
|
||||
|
||||
let ioService = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
|
||||
gHttpServer.start(-1);
|
||||
|
||||
let uri = ioService.newURI(
|
||||
let uri = Services.io.newURI(
|
||||
"http://localhost:" + gHttpServer.identity.primaryPort
|
||||
);
|
||||
let channel = NetUtil.newChannel({ uri, loadUsingSystemPrincipal: true });
|
||||
|
@ -32,9 +32,7 @@ var factory = {
|
||||
|
||||
function run_test() {
|
||||
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
let classID = Cc["@mozilla.org/uuid-generator;1"]
|
||||
.getService(Ci.nsIUUIDGenerator)
|
||||
.generateUUID();
|
||||
let classID = Services.uuid.generateUUID();
|
||||
registrar.registerFactory(
|
||||
classID,
|
||||
"",
|
||||
|
@ -35,10 +35,7 @@ function make_channel(url, callback, ctx) {
|
||||
}
|
||||
|
||||
function inChildProcess() {
|
||||
return (
|
||||
Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
|
||||
);
|
||||
return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
const responseContent = "response body";
|
||||
|
@ -24,10 +24,7 @@ function make_channel(url, callback, ctx) {
|
||||
}
|
||||
|
||||
function inChildProcess() {
|
||||
return (
|
||||
Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
|
||||
);
|
||||
return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
const responseContent = "response body";
|
||||
|
@ -24,10 +24,7 @@ function make_channel(url, callback, ctx) {
|
||||
}
|
||||
|
||||
function inChildProcess() {
|
||||
return (
|
||||
Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
|
||||
);
|
||||
return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
const responseContent = "response body";
|
||||
|
@ -34,7 +34,7 @@ function run_test() {
|
||||
|
||||
// Set to allow the cert presented by our H2 server
|
||||
do_get_profile();
|
||||
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
prefs = Services.prefs;
|
||||
|
||||
spdypref = prefs.getBoolPref("network.http.spdy.enabled");
|
||||
http2pref = prefs.getBoolPref("network.http.spdy.enabled.http2");
|
||||
|
@ -37,7 +37,7 @@ function run_test() {
|
||||
|
||||
h3Route = "foo.example.com:" + h3Port;
|
||||
do_get_profile();
|
||||
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
prefs = Services.prefs;
|
||||
|
||||
prefs.setBoolPref("network.http.http3.enabled", true);
|
||||
prefs.setCharPref("network.dns.localDomains", "foo.example.com");
|
||||
|
@ -23,7 +23,7 @@ function run_test() {
|
||||
|
||||
// Set to allow the cert presented by our H2 server
|
||||
do_get_profile();
|
||||
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
prefs = Services.prefs;
|
||||
|
||||
spdypref = prefs.getBoolPref("network.http.spdy.enabled");
|
||||
http2pref = prefs.getBoolPref("network.http.spdy.enabled.http2");
|
||||
|
@ -10,9 +10,7 @@
|
||||
|
||||
const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
|
||||
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
var prefs = Services.prefs;
|
||||
|
||||
// Since this test creates a TYPE_DOCUMENT channel via javascript, it will
|
||||
// end up using the wrong LoadInfo constructor. Setting this pref will disable
|
||||
@ -102,16 +100,15 @@ Requestor.prototype = {
|
||||
};
|
||||
|
||||
function make_uri(url) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
return ios.newURI(url);
|
||||
return Services.io.newURI(url);
|
||||
}
|
||||
|
||||
function makeChan(loadingUrl, url, contentPolicy) {
|
||||
var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(
|
||||
Ci.nsIScriptSecurityManager
|
||||
);
|
||||
var uri = make_uri(loadingUrl);
|
||||
var principal = ssm.createContentPrincipal(uri, {});
|
||||
var principal = Services.scriptSecurityManager.createContentPrincipal(
|
||||
uri,
|
||||
{}
|
||||
);
|
||||
|
||||
return NetUtil.newChannel({
|
||||
uri: url,
|
||||
|
@ -1,19 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
function createURI(s) {
|
||||
let service = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
return service.newURI(s);
|
||||
return Services.io.newURI(s);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
// Set up a profile.
|
||||
do_get_profile();
|
||||
|
||||
var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(
|
||||
Ci.nsIScriptSecurityManager
|
||||
);
|
||||
var secMan = Services.scriptSecurityManager;
|
||||
const kURI1 = "http://example.com";
|
||||
var app = secMan.createContentPrincipal(createURI(kURI1), {});
|
||||
var appbrowser = secMan.createContentPrincipal(createURI(kURI1), {
|
||||
|
@ -6,9 +6,7 @@
|
||||
const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
|
||||
|
||||
// Turn off the authentication dialog blocking for this test.
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
var prefs = Services.prefs;
|
||||
prefs.setIntPref("network.auth.subresource-http-auth-allow", 2);
|
||||
|
||||
function URL(domain, path = "") {
|
||||
|
@ -6,10 +6,7 @@
|
||||
const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
|
||||
|
||||
// Turn off the authentication dialog blocking for this test.
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
prefs.setIntPref("network.auth.subresource-http-auth-allow", 2);
|
||||
Services.prefs.setIntPref("network.auth.subresource-http-auth-allow", 2);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpserv.identity.primaryPort;
|
||||
@ -283,11 +280,10 @@ var listener = {
|
||||
};
|
||||
|
||||
function makeChan(url, loadingUrl) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(
|
||||
Ci.nsIScriptSecurityManager
|
||||
var principal = Services.scriptSecurityManager.createContentPrincipal(
|
||||
Services.io.newURI(loadingUrl),
|
||||
{}
|
||||
);
|
||||
var principal = ssm.createContentPrincipal(ios.newURI(loadingUrl), {});
|
||||
return NetUtil.newChannel({
|
||||
uri: url,
|
||||
loadingPrincipal: principal,
|
||||
|
@ -50,10 +50,7 @@ function makeChannel(uri) {
|
||||
}
|
||||
|
||||
async function TestProxyType(chan, flags) {
|
||||
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
prefs.setIntPref(
|
||||
Services.prefs.setIntPref(
|
||||
"network.proxy.type",
|
||||
Ci.nsIProtocolProxyService.PROXYCONFIG_SYSTEM
|
||||
);
|
||||
@ -103,10 +100,7 @@ add_task(async function testDirectProxy() {
|
||||
.setScheme("https")
|
||||
.finalize();
|
||||
|
||||
let ioService = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
let chan = ioService.newChannelFromURIWithProxyFlags(
|
||||
let chan = Services.io.newChannelFromURIWithProxyFlags(
|
||||
uri,
|
||||
proxyURI,
|
||||
0,
|
||||
@ -137,10 +131,7 @@ add_task(async function testWebSocketProxy() {
|
||||
Ci.nsIProtocolProxyService.RESOLVE_PREFER_HTTPS_PROXY |
|
||||
Ci.nsIProtocolProxyService.RESOLVE_ALWAYS_TUNNEL;
|
||||
|
||||
let ioService = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
let chan = ioService.newChannelFromURIWithProxyFlags(
|
||||
let chan = Services.io.newChannelFromURIWithProxyFlags(
|
||||
uri,
|
||||
proxyURI,
|
||||
proxyFlags,
|
||||
@ -164,10 +155,7 @@ add_task(async function testPreferHttpsProxy() {
|
||||
.finalize();
|
||||
let proxyFlags = Ci.nsIProtocolProxyService.RESOLVE_PREFER_HTTPS_PROXY;
|
||||
|
||||
let ioService = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
let chan = ioService.newChannelFromURIWithProxyFlags(
|
||||
let chan = Services.io.newChannelFromURIWithProxyFlags(
|
||||
uri,
|
||||
null,
|
||||
proxyFlags,
|
||||
|
@ -3,10 +3,8 @@
|
||||
"use strict";
|
||||
|
||||
function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(
|
||||
Ci.nsIScriptSecurityManager
|
||||
);
|
||||
var ios = Services.io;
|
||||
var ssm = Services.scriptSecurityManager;
|
||||
|
||||
// NON-UNICODE
|
||||
var uri = ios.newURI("http://foo.com/file.txt");
|
||||
|
@ -63,7 +63,7 @@ var cePref;
|
||||
function run_test() {
|
||||
do_get_profile();
|
||||
|
||||
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
prefs = Services.prefs;
|
||||
cePref = prefs.getCharPref("network.http.accept-encoding");
|
||||
prefs.setCharPref("network.http.accept-encoding", "gzip, deflate, br");
|
||||
|
||||
|
@ -103,10 +103,7 @@ HttpResponseListener.prototype = {
|
||||
var responseQueue = [];
|
||||
function setup_http_server() {
|
||||
log("setup_http_server");
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
maxConnections = prefs.getIntPref(
|
||||
maxConnections = Services.prefs.getIntPref(
|
||||
"network.http.max-persistent-connections-per-server"
|
||||
);
|
||||
urgentRequests = 2;
|
||||
|
@ -118,10 +118,7 @@ function check_response_id(responses, maxWindowId) {
|
||||
var responseQueue = [];
|
||||
function setup_http_server() {
|
||||
log("setup_http_server");
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
maxConnections = prefs.getIntPref(
|
||||
maxConnections = Services.prefs.getIntPref(
|
||||
"network.http.max-persistent-connections-per-server"
|
||||
);
|
||||
FOCUSED_WINDOW_REQUEST_COUNT = Math.floor(maxConnections * 0.8);
|
||||
@ -184,10 +181,7 @@ function processResponses() {
|
||||
function run_test() {
|
||||
// Make sure "network.http.active_tab_priority" is true, so we can expect to
|
||||
// receive http requests with focused window id before others.
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
prefs.setBoolPref("network.http.active_tab_priority", true);
|
||||
Services.prefs.setBoolPref("network.http.active_tab_priority", true);
|
||||
|
||||
setup_http_server();
|
||||
setup_dummyHttpRequests();
|
||||
@ -196,8 +190,6 @@ function run_test() {
|
||||
Ci.nsISupportsPRUint64
|
||||
);
|
||||
windowIdWrapper.data = FOCUSED_WINDOW_ID;
|
||||
var obsvc = Cc["@mozilla.org/observer-service;1"].getService(
|
||||
Ci.nsIObserverService
|
||||
);
|
||||
var obsvc = Services.obs;
|
||||
obsvc.notifyObservers(windowIdWrapper, "net:current-top-browsing-context-id");
|
||||
}
|
||||
|
@ -147,10 +147,7 @@ HttpResponseListener.prototype = {
|
||||
|
||||
function setup_http_server() {
|
||||
log("setup_http_server");
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
maxConnections = prefs.getIntPref(
|
||||
maxConnections = Services.prefs.getIntPref(
|
||||
"network.http.max-persistent-connections-per-server"
|
||||
);
|
||||
|
||||
|
@ -132,10 +132,7 @@ function check_response_id(responses, windowId) {
|
||||
var responseQueue = [];
|
||||
function setup_http_server() {
|
||||
log("setup_http_server");
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
maxConnections = prefs.getIntPref(
|
||||
maxConnections = Services.prefs.getIntPref(
|
||||
"network.http.max-persistent-connections-per-server"
|
||||
);
|
||||
FOCUSED_WINDOW_REQUEST_COUNT = Math.floor(maxConnections * 0.5);
|
||||
@ -192,10 +189,7 @@ function processResponses() {
|
||||
function run_test() {
|
||||
// Set "network.http.active_tab_priority" to false, so we can expect to
|
||||
// receive http requests with higher priority first.
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
prefs.setBoolPref("network.http.active_tab_priority", false);
|
||||
Services.prefs.setBoolPref("network.http.active_tab_priority", false);
|
||||
|
||||
setup_http_server();
|
||||
setup_dummyHttpRequests();
|
||||
|
@ -84,10 +84,7 @@ HttpResponseListener.prototype = {
|
||||
var responseQueue = [];
|
||||
function setup_http_server() {
|
||||
log("setup_http_server");
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
maxConnections = prefs.getIntPref(
|
||||
maxConnections = Services.prefs.getIntPref(
|
||||
"network.http.max-persistent-connections-per-server"
|
||||
);
|
||||
|
||||
|
@ -23,11 +23,10 @@ XPCOMUtils.defineLazyGetter(this, "PORT", function() {
|
||||
});
|
||||
|
||||
function makeChan(url, loadingUrl) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(
|
||||
Ci.nsIScriptSecurityManager
|
||||
var principal = Services.scriptSecurityManager.createContentPrincipal(
|
||||
Services.io.newURI(loadingUrl),
|
||||
{}
|
||||
);
|
||||
var principal = ssm.createContentPrincipal(ios.newURI(loadingUrl), {});
|
||||
return NetUtil.newChannel({
|
||||
uri: url,
|
||||
loadingPrincipal: principal,
|
||||
@ -49,7 +48,7 @@ function authHandler(metadata, response) {
|
||||
}
|
||||
|
||||
function setup() {
|
||||
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
prefs = Services.prefs;
|
||||
|
||||
prefs.setIntPref("network.auth.subresource-http-auth-allow", 2);
|
||||
prefs.setStringPref("network.negotiate-auth.trusted-uris", "localhost");
|
||||
|
@ -142,10 +142,7 @@ function run_test2() {
|
||||
|
||||
function run_test3() {
|
||||
// Simulate all private browsing instances being closed
|
||||
var obsvc = Cc["@mozilla.org/observer-service;1"].getService(
|
||||
Ci.nsIObserverService
|
||||
);
|
||||
obsvc.notifyObservers(null, "last-pb-context-exited");
|
||||
Services.obs.notifyObservers(null, "last-pb-context-exited");
|
||||
|
||||
// Make sure the memory device is not empty
|
||||
get_device_entry_count(kMemoryDevice, null, function(count) {
|
||||
|
@ -9,10 +9,7 @@ const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
|
||||
var httpserver;
|
||||
|
||||
function inChildProcess() {
|
||||
return (
|
||||
Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
|
||||
);
|
||||
return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
}
|
||||
function makeChan(path) {
|
||||
return NetUtil.newChannel({
|
||||
@ -133,10 +130,7 @@ function run_test() {
|
||||
if (!inChildProcess()) {
|
||||
tests.push(function() {
|
||||
// Simulate all private browsing instances being closed
|
||||
var obsvc = Cc["@mozilla.org/observer-service;1"].getService(
|
||||
Ci.nsIObserverService
|
||||
);
|
||||
obsvc.notifyObservers(null, "last-pb-context-exited");
|
||||
Services.obs.notifyObservers(null, "last-pb-context-exited");
|
||||
// Check that all private cookies are now unavailable in new private requests
|
||||
check_cookie_presence("C2=V2", true, false, runNextTest);
|
||||
});
|
||||
|
@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
var newURI = ios.newURI("http://foo.com");
|
||||
var newURI = Services.io.newURI("http://foo.com");
|
||||
|
||||
var success = false;
|
||||
try {
|
||||
|
@ -38,9 +38,7 @@ function run_test() {
|
||||
uri: "http://localhost:" + server.identity.primaryPort + "/",
|
||||
loadUsingSystemPrincipal: true,
|
||||
});
|
||||
var targetFile = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("TmpD", Ci.nsIFile);
|
||||
var targetFile = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
targetFile.append("bug" + BUGID + ".test");
|
||||
if (targetFile.exists()) {
|
||||
targetFile.remove(false);
|
||||
|
@ -25,13 +25,12 @@ function run_test() {
|
||||
};
|
||||
|
||||
let listener = new StreamListener();
|
||||
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
// This file does not exist.
|
||||
let file = do_get_file("_NOT_EXIST_.txt", true);
|
||||
Assert.ok(!file.exists());
|
||||
let channel = NetUtil.newChannel({
|
||||
uri: ios.newFileURI(file),
|
||||
uri: Services.io.newFileURI(file),
|
||||
loadUsingSystemPrincipal: true,
|
||||
});
|
||||
channel.asyncOpen(listener);
|
||||
|
@ -3,9 +3,7 @@
|
||||
const url = "http://foo.com/folder/file?/.";
|
||||
|
||||
function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
var newURI = ios.newURI(url);
|
||||
var newURI = Services.io.newURI(url);
|
||||
Assert.equal(newURI.spec, url);
|
||||
Assert.equal(newURI.pathQueryRef, "/folder/file?/.");
|
||||
Assert.equal(newURI.resolve("./file?/."), url);
|
||||
|
@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
function run_test() {
|
||||
var tld = Cc["@mozilla.org/network/effective-tld-service;1"].getService(
|
||||
Ci.nsIEffectiveTLDService
|
||||
);
|
||||
var tld = Services.eTLD;
|
||||
Assert.equal(tld.getPublicSuffixFromHost("localhost"), "localhost");
|
||||
Assert.equal(tld.getPublicSuffixFromHost("localhost."), "localhost.");
|
||||
Assert.equal(tld.getPublicSuffixFromHost("domain.com"), "com");
|
||||
@ -95,11 +93,7 @@ function run_test() {
|
||||
|
||||
// check normalization: output should be consistent with
|
||||
// nsIURI::GetAsciiHost(), i.e. lowercased and ASCII/ACE encoded
|
||||
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
|
||||
var uri = ioService.newURI("http://b\u00FCcher.co.uk");
|
||||
var uri = Services.io.newURI("http://b\u00FCcher.co.uk");
|
||||
Assert.equal(tld.getBaseDomain(uri), "xn--bcher-kva.co.uk");
|
||||
Assert.equal(
|
||||
tld.getBaseDomainFromHost("b\u00FCcher.co.uk"),
|
||||
|
@ -1,19 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
function test_not_too_long() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
var spec = "jar:http://example.com/bar.jar!/";
|
||||
try {
|
||||
ios.newURI(spec);
|
||||
Services.io.newURI(spec);
|
||||
} catch (e) {
|
||||
do_throw("newURI threw even though it wasn't passed a large nested URI?");
|
||||
}
|
||||
}
|
||||
|
||||
function test_too_long() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
var i;
|
||||
var prefix = "jar:";
|
||||
for (i = 0; i < 16; i++) {
|
||||
@ -30,7 +26,7 @@ function test_too_long() {
|
||||
// unchecked would lead to a stack overflow. If we
|
||||
// do not crash here and thus an exception is caught
|
||||
// we have passed the test.
|
||||
ios.newURI(spec);
|
||||
Services.io.newURI(spec);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
|
@ -12,12 +12,8 @@ const testURLs = [
|
||||
];
|
||||
|
||||
function run_test() {
|
||||
var ioServ = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
|
||||
for (var i = 0; i < testURLs.length; i++) {
|
||||
var uri = ioServ.newURI(testURLs[i][0]);
|
||||
var uri = Services.io.newURI(testURLs[i][0]);
|
||||
Assert.equal(uri.spec, testURLs[i][1]);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
function run_test() {
|
||||
const ios = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
const ios = Services.io;
|
||||
|
||||
var base = ios.newURI("http://localhost/bug379034/index.html");
|
||||
|
||||
|
@ -13,10 +13,8 @@ const specs = [
|
||||
];
|
||||
|
||||
function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
for (var spec of specs) {
|
||||
var uri = ios.newURI(spec);
|
||||
var uri = Services.io.newURI(spec);
|
||||
if (uri.spec.includes("..")) {
|
||||
do_throw(
|
||||
"resource: traversal remains: '" + spec + "' ==> '" + uri.spec + "'"
|
||||
|
@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
function run_test() {
|
||||
const ios = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
const ios = Services.io;
|
||||
|
||||
var uri = ios.newURI("http://foo.com/file.txt");
|
||||
uri = uri
|
||||
|
@ -29,9 +29,7 @@ var prefData = [
|
||||
];
|
||||
|
||||
function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
var uri1 = ios.newURI("file:///");
|
||||
var uri1 = Services.io.newURI("file:///");
|
||||
Assert.ok(uri1 instanceof Ci.nsIFileURL);
|
||||
|
||||
var uri2 = uri1.mutate().finalize();
|
||||
@ -43,9 +41,7 @@ function run_test() {
|
||||
Assert.ok(uri1.equals(uri3));
|
||||
|
||||
// Make sure our prefs are set such that this test actually means something
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
var prefs = Services.prefs;
|
||||
for (var pref of prefData) {
|
||||
prefs.setBoolPref(pref.name, pref.newVal);
|
||||
}
|
||||
@ -53,7 +49,7 @@ function run_test() {
|
||||
try {
|
||||
// URI stolen from
|
||||
// http://lists.w3.org/Archives/Public/public-iri/2004Mar/0012.html
|
||||
var uri4 = ios.newURI("http://xn--jos-dma.example.net.ch/");
|
||||
var uri4 = Services.io.newURI("http://xn--jos-dma.example.net.ch/");
|
||||
Assert.equal(uri4.asciiHost, "xn--jos-dma.example.net.ch");
|
||||
Assert.equal(uri4.displayHost, "jos\u00e9.example.net.ch");
|
||||
|
||||
|
@ -26,10 +26,7 @@ function run_test() {
|
||||
httpserver.registerPathHandler("/content", contentHandler);
|
||||
httpserver.start(-1);
|
||||
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
prefs.setBoolPref("network.http.prompt-temp-redirect", false);
|
||||
Services.prefs.setBoolPref("network.http.prompt-temp-redirect", false);
|
||||
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: "http://localhost:" + httpserver.identity.primaryPort + "/redirect",
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
function run_test() {
|
||||
try {
|
||||
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
var cm = Services.cookies;
|
||||
Assert.notEqual(cm, null, "Retrieving the cookie manager failed");
|
||||
|
||||
const time = new Date("Jan 1, 2030").getTime() / 1000;
|
||||
|
@ -1,10 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
// check if hostname is unescaped before applying IDNA
|
||||
var newURI = ios.newURI("http://\u5341%2ecom/");
|
||||
var newURI = Services.io.newURI("http://\u5341%2ecom/");
|
||||
Assert.equal(newURI.asciiHost, "xn--kkr.com");
|
||||
|
||||
// escaped UTF8
|
||||
|
@ -2,9 +2,6 @@
|
||||
|
||||
const PR_RDONLY = 0x1;
|
||||
|
||||
var etld = Cc["@mozilla.org/network/effective-tld-service;1"].getService(
|
||||
Ci.nsIEffectiveTLDService
|
||||
);
|
||||
var idn = Cc["@mozilla.org/network/idn-service;1"].getService(Ci.nsIIDNService);
|
||||
|
||||
function run_test() {
|
||||
@ -57,6 +54,6 @@ function run_test() {
|
||||
|
||||
function checkPublicSuffix(host, expectedSuffix) {
|
||||
expectedSuffix = idn.convertUTF8toACE(expectedSuffix).toLowerCase();
|
||||
var actualSuffix = etld.getPublicSuffixFromHost(host);
|
||||
var actualSuffix = Services.eTLD.getPublicSuffixFromHost(host);
|
||||
Assert.equal(actualSuffix, expectedSuffix);
|
||||
}
|
||||
|
@ -25,10 +25,7 @@ function expected_fail(inputIDN) {
|
||||
|
||||
function run_test() {
|
||||
// add an IDN whitelist pref
|
||||
var pbi = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
pbi.setBoolPref("network.IDN.whitelist.com", true);
|
||||
Services.prefs.setBoolPref("network.IDN.whitelist.com", true);
|
||||
|
||||
idnService = Cc["@mozilla.org/network/idn-service;1"].getService(
|
||||
Ci.nsIIDNService
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var ios = Services.io;
|
||||
|
||||
var uri1 = ios.newURI("http://example.com#bar");
|
||||
var uri2 = ios.newURI("http://example.com/#bar");
|
||||
|
@ -11,7 +11,7 @@ function getUrlLinkFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
const ios = Services.io;
|
||||
|
||||
function NotificationCallbacks(origURI, newURI) {
|
||||
this._origURI = origURI;
|
||||
|
@ -47,9 +47,7 @@ function stringToURL(str) {
|
||||
|
||||
function run_test() {
|
||||
// Make sure our prefs are set such that this test actually means something
|
||||
let prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
let prefs = Services.prefs;
|
||||
for (let pref of prefData) {
|
||||
prefs.setBoolPref(pref.name, pref.newVal);
|
||||
}
|
||||
|
@ -25,9 +25,7 @@ function expected_fail(inputIDN) {
|
||||
|
||||
function run_test() {
|
||||
// add an IDN whitelist pref
|
||||
var pbi = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
var pbi = Services.prefs;
|
||||
var whitelistPref = "network.IDN.whitelist.com";
|
||||
|
||||
pbi.setBoolPref(whitelistPref, true);
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var ios = Services.io;
|
||||
|
||||
var test_port = function(port, exception_expected) {
|
||||
dump((port || "no port provided") + "\n");
|
||||
|
@ -31,8 +31,7 @@ function make_channel(aUrl) {
|
||||
}
|
||||
|
||||
function make_uri(aUrl) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
return ios.newURI(aUrl);
|
||||
return Services.io.newURI(aUrl);
|
||||
}
|
||||
|
||||
function resource_handler(aMetadata, aResponse) {
|
||||
|
@ -53,11 +53,9 @@ var invalid_URIs = [
|
||||
];
|
||||
|
||||
function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
for (var i = 0; i < valid_URIs.length; i++) {
|
||||
try {
|
||||
ios.newURI(valid_URIs[i]);
|
||||
Services.io.newURI(valid_URIs[i]);
|
||||
} catch (e) {
|
||||
do_throw("cannot create URI:" + valid_URIs[i]);
|
||||
}
|
||||
@ -65,7 +63,7 @@ function run_test() {
|
||||
|
||||
for (var i = 0; i < invalid_URIs.length; i++) {
|
||||
try {
|
||||
ios.newURI(invalid_URIs[i]);
|
||||
Services.io.newURI(invalid_URIs[i]);
|
||||
do_throw("should throw: " + invalid_URIs[i]);
|
||||
} catch (e) {
|
||||
Assert.equal(e.result, Cr.NS_ERROR_MALFORMED_URI);
|
||||
|
@ -4,7 +4,7 @@
|
||||
"use strict";
|
||||
|
||||
add_task(async () => {
|
||||
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
var cm = Services.cookies;
|
||||
var expiry = (Date.now() + 1000) * 1000;
|
||||
|
||||
cm.removeAll();
|
||||
@ -242,12 +242,12 @@ add_task(async () => {
|
||||
});
|
||||
|
||||
function getCookieCount() {
|
||||
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
var cm = Services.cookies;
|
||||
return cm.cookies.length;
|
||||
}
|
||||
|
||||
async function testDomainCookie(uriString, domain) {
|
||||
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
var cm = Services.cookies;
|
||||
|
||||
cm.removeAll();
|
||||
|
||||
@ -273,7 +273,7 @@ async function testDomainCookie(uriString, domain) {
|
||||
}
|
||||
|
||||
async function testTrailingDotCookie(uriString, domain) {
|
||||
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
var cm = Services.cookies;
|
||||
|
||||
cm.removeAll();
|
||||
|
||||
|
@ -36,10 +36,7 @@ function postRedirectHandler(metadata, response) {
|
||||
}
|
||||
|
||||
function inChildProcess() {
|
||||
return (
|
||||
Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
|
||||
);
|
||||
return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
add_task(async () => {
|
||||
@ -51,17 +48,12 @@ add_task(async () => {
|
||||
|
||||
if (!inChildProcess()) {
|
||||
// Disable third-party cookies in general.
|
||||
Cc["@mozilla.org/preferences-service;1"]
|
||||
.getService(Ci.nsIPrefBranch)
|
||||
.setIntPref("network.cookie.cookieBehavior", 1);
|
||||
Cc["@mozilla.org/preferences-service;1"]
|
||||
.getService(Ci.nsIPrefBranch)
|
||||
.setBoolPref("network.cookieJarSettings.unblocked_for_testing", true);
|
||||
}
|
||||
|
||||
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
Services.prefs.setIntPref("network.cookie.cookieBehavior", 1);
|
||||
Services.prefs.setBoolPref(
|
||||
"network.cookieJarSettings.unblocked_for_testing",
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
// Set up a channel with forceAllowThirdPartyCookie set to true. We'll use
|
||||
// the channel both to set a cookie and then to load the pre-redirect URI.
|
||||
@ -76,7 +68,7 @@ add_task(async () => {
|
||||
// Set a cookie on one of the URIs. It doesn't matter which one, since
|
||||
// they're both from the same host, which is enough for the cookie service
|
||||
// to send the cookie with both requests.
|
||||
var postRedirectURI = ioService.newURI(postRedirectURL);
|
||||
var postRedirectURI = Services.io.newURI(postRedirectURL);
|
||||
|
||||
await CookieXPCShellUtils.setCookieToDocument(
|
||||
postRedirectURI.spec,
|
||||
|
@ -1,10 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
function makeURL(spec) {
|
||||
return Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService)
|
||||
.newURI(spec)
|
||||
.QueryInterface(Ci.nsIURL);
|
||||
return Services.io.newURI(spec).QueryInterface(Ci.nsIURL);
|
||||
}
|
||||
|
||||
// Checks that nsIURL::GetRelativeSpec does what it claims to do.
|
||||
|
@ -1,8 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
var ioService = Services.io;
|
||||
var resProt = ioService
|
||||
.getProtocolHandler("resource")
|
||||
.QueryInterface(Ci.nsIResProtocolHandler);
|
||||
|
@ -46,10 +46,7 @@ function run_test() {
|
||||
);
|
||||
|
||||
// Ensure we're using system-properties
|
||||
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
prefs.setIntPref(
|
||||
Services.prefs.setIntPref(
|
||||
"network.proxy.type",
|
||||
Ci.nsIProtocolProxyService.PROXYCONFIG_SYSTEM
|
||||
);
|
||||
|
@ -7,12 +7,11 @@ add_task(async () => {
|
||||
Services.prefs.setBoolPref("network.cookie.sameSite.schemeful", false);
|
||||
Services.prefs.setBoolPref("dom.security.https_first", false);
|
||||
|
||||
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
var expiry = (Date.now() + 1000) * 1000;
|
||||
|
||||
// Test our handling of host names with a single character at the beginning
|
||||
// followed by a dot.
|
||||
cm.add(
|
||||
Services.cookies.add(
|
||||
"e.com",
|
||||
"/",
|
||||
"foo",
|
||||
@ -25,7 +24,7 @@ add_task(async () => {
|
||||
Ci.nsICookie.SAMESITE_NONE,
|
||||
Ci.nsICookie.SCHEME_HTTP
|
||||
);
|
||||
Assert.equal(cm.countCookiesFromHost("e.com"), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("e.com"), 1);
|
||||
|
||||
CookieXPCShellUtils.createServer({ hosts: ["e.com"] });
|
||||
const cookies = await CookieXPCShellUtils.getCookieStringFromDocument(
|
||||
|
@ -9,9 +9,7 @@ const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
|
||||
|
||||
do_get_profile();
|
||||
|
||||
const prefService = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
const prefService = Services.prefs;
|
||||
|
||||
const httpserver = new HttpServer();
|
||||
|
||||
|
@ -1,16 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var _PSvc;
|
||||
function get_pref_service() {
|
||||
if (_PSvc) {
|
||||
return _PSvc;
|
||||
}
|
||||
|
||||
return (_PSvc = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
));
|
||||
}
|
||||
|
||||
function gen_1MiB() {
|
||||
var i;
|
||||
var data = "x";
|
||||
@ -50,7 +39,7 @@ function write_datafile(status, entry) {
|
||||
entry.close();
|
||||
|
||||
// now change max_entry_size so that the existing entry is too big
|
||||
get_pref_service().setIntPref("browser.cache.disk.max_entry_size", 1024);
|
||||
Services.prefs.setIntPref("browser.cache.disk.max_entry_size", 1024);
|
||||
|
||||
// append to entry
|
||||
asyncOpenCacheEntry(
|
||||
|
@ -5,12 +5,11 @@
|
||||
|
||||
add_task(async () => {
|
||||
Services.prefs.setBoolPref("dom.security.https_first", false);
|
||||
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
var expiry = (Date.now() + 1000) * 1000;
|
||||
|
||||
// Test our handling of host names with a single character consisting only
|
||||
// of a single character
|
||||
cm.add(
|
||||
Services.cookies.add(
|
||||
"a",
|
||||
"/",
|
||||
"foo",
|
||||
@ -23,7 +22,7 @@ add_task(async () => {
|
||||
Ci.nsICookie.SAMESITE_NONE,
|
||||
Ci.nsICookie.SCHEME_HTTP
|
||||
);
|
||||
Assert.equal(cm.countCookiesFromHost("a"), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("a"), 1);
|
||||
|
||||
CookieXPCShellUtils.createServer({ hosts: ["a"] });
|
||||
const cookies = await CookieXPCShellUtils.getCookieStringFromDocument(
|
||||
|
@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
function makeURI(str) {
|
||||
return Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService)
|
||||
.newURI(str);
|
||||
return Services.io.newURI(str);
|
||||
}
|
||||
|
||||
add_task(async () => {
|
||||
|
@ -136,10 +136,7 @@ function getUA() {
|
||||
}
|
||||
|
||||
function setUA(value) {
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
prefs.setCharPref("general.useragent.override", value);
|
||||
Services.prefs.setCharPref("general.useragent.override", value);
|
||||
}
|
||||
|
||||
function getDateString(yearDelta) {
|
||||
|
@ -232,9 +232,7 @@ function run_test() {
|
||||
httpserv.registerPathHandler("/", handler);
|
||||
httpserv.start(-1);
|
||||
|
||||
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
const prefs = Services.prefs;
|
||||
prefs.setCharPref("network.proxy.http", "localhost");
|
||||
prefs.setIntPref("network.proxy.http_port", httpserv.identity.primaryPort);
|
||||
prefs.setBoolPref("network.proxy.allow_hijacking_localhost", true);
|
||||
|
@ -45,9 +45,7 @@ function RequestObserver() {
|
||||
RequestObserver.prototype = {
|
||||
register() {
|
||||
info("Registering " + notification);
|
||||
Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService)
|
||||
.addObserver(this, notification, true);
|
||||
Services.obs.addObserver(this, notification, true);
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI([
|
||||
|
@ -31,8 +31,7 @@ function make_channel(url, cache_control) {
|
||||
}
|
||||
|
||||
function make_uri(url) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
return ios.newURI(url);
|
||||
return Services.io.newURI(url);
|
||||
}
|
||||
|
||||
function resource_age_100_handler(metadata, response) {
|
||||
|
@ -21,8 +21,7 @@ function isParentProcess() {
|
||||
let appInfo = Cc["@mozilla.org/xre/app-info;1"];
|
||||
return (
|
||||
!appInfo ||
|
||||
appInfo.getService(Ci.nsIXULRuntime).processType ==
|
||||
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
|
||||
Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3,13 +3,9 @@
|
||||
function run_test() {
|
||||
// Just check the contract ID alias works well.
|
||||
try {
|
||||
var serviceA = Cc[
|
||||
"@mozilla.org/netwerk/cache-storage-service;1"
|
||||
].getService(Ci.nsICacheStorageService);
|
||||
var serviceA = Services.cache2;
|
||||
Assert.ok(serviceA);
|
||||
var serviceB = Cc[
|
||||
"@mozilla.org/network/cache-storage-service;1"
|
||||
].getService(Ci.nsICacheStorageService);
|
||||
var serviceB = Services.cache2;
|
||||
Assert.ok(serviceB);
|
||||
|
||||
Assert.equal(serviceA, serviceB);
|
||||
|
@ -1,10 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
function exitPB() {
|
||||
var obsvc = Cc["@mozilla.org/observer-service;1"].getService(
|
||||
Ci.nsIObserverService
|
||||
);
|
||||
obsvc.notifyObservers(null, "last-pb-context-exited");
|
||||
Services.obs.notifyObservers(null, "last-pb-context-exited");
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
|
@ -17,12 +17,8 @@ var oStr;
|
||||
function run_test() {
|
||||
do_get_profile();
|
||||
|
||||
var prefBranch = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
|
||||
// set max chunks memory so that only one full chunk fits within the limit
|
||||
prefBranch.setIntPref("browser.cache.disk.max_chunks_memory_usage", 300);
|
||||
Services.prefs.setIntPref("browser.cache.disk.max_chunks_memory_usage", 300);
|
||||
|
||||
asyncOpenCacheEntry(
|
||||
"http://a/",
|
||||
|
@ -93,10 +93,7 @@ function run_test() {
|
||||
|
||||
mc.fired(); // Goes to (2)
|
||||
|
||||
var os = Cc["@mozilla.org/observer-service;1"].getService(
|
||||
Ci.nsIObserverService
|
||||
);
|
||||
os.addObserver(
|
||||
Services.obs.addObserver(
|
||||
{
|
||||
observe(subject, topic, data) {
|
||||
// (3)
|
||||
|
@ -88,10 +88,7 @@ function run_test() {
|
||||
|
||||
mc.fired(); // Goes to (2)
|
||||
|
||||
var os = Cc["@mozilla.org/observer-service;1"].getService(
|
||||
Ci.nsIObserverService
|
||||
);
|
||||
os.addObserver(
|
||||
Services.obs.addObserver(
|
||||
{
|
||||
observe(subject, topic, data) {
|
||||
// (3)
|
||||
|
@ -49,8 +49,7 @@ async function run_all_tests() {
|
||||
|
||||
// We can't easily cause webapp data to be cleared from the child process, so skip
|
||||
// the rest of these tests.
|
||||
let procType = Cc["@mozilla.org/xre/runtime;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType;
|
||||
let procType = Services.appinfo.processType;
|
||||
if (procType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
|
||||
return;
|
||||
}
|
||||
|
@ -38,10 +38,6 @@ function run_test() {
|
||||
["view-source:http://mozilla.org/", "http://mozilla.org/", true],
|
||||
];
|
||||
|
||||
var secman = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(
|
||||
Ci.nsIScriptSecurityManager
|
||||
);
|
||||
|
||||
tests.forEach(function(aTest) {
|
||||
do_info("Comparing " + aTest[0] + " to " + aTest[1]);
|
||||
|
||||
@ -50,7 +46,12 @@ function run_test() {
|
||||
|
||||
var equal;
|
||||
try {
|
||||
secman.checkSameOriginURI(uri1, uri2, false, false);
|
||||
Services.scriptSecurityManager.checkSameOriginURI(
|
||||
uri1,
|
||||
uri2,
|
||||
false,
|
||||
false
|
||||
);
|
||||
equal = true;
|
||||
} catch (e) {
|
||||
equal = false;
|
||||
|
@ -178,7 +178,7 @@ function completeIter(request, data, ctx) {
|
||||
var prefs;
|
||||
var cePref;
|
||||
function run_test() {
|
||||
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
prefs = Services.prefs;
|
||||
cePref = prefs.getCharPref("network.http.accept-encoding");
|
||||
prefs.setCharPref("network.http.accept-encoding", "gzip, deflate, br");
|
||||
|
||||
|
@ -29,7 +29,7 @@ registerCleanupFunction(() => {
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
prefs = Services.prefs;
|
||||
enforcePrefStrict = prefs.getBoolPref("network.http.enforce-framing.http1");
|
||||
enforcePrefSoft = prefs.getBoolPref("network.http.enforce-framing.soft");
|
||||
enforcePrefStrictChunked = prefs.getBoolPref(
|
||||
|
@ -140,9 +140,7 @@ function run_test_iteration(index) {
|
||||
if (sniffing_enabled && index == 2) {
|
||||
// Register our sniffer only here
|
||||
// This also makes sure that dynamic registration is working
|
||||
var catMan = Cc["@mozilla.org/categorymanager;1"].getService(
|
||||
Ci.nsICategoryManager
|
||||
);
|
||||
var catMan = Services.catMan;
|
||||
catMan.nsICategoryManager.addCategoryEntry(
|
||||
categoryName,
|
||||
"unit test",
|
||||
|
@ -10,8 +10,9 @@ add_task(async () => {
|
||||
);
|
||||
Services.prefs.setBoolPref("dom.security.https_first", false);
|
||||
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var cookieURI = ios.newURI("http://mozilla.org/test_cookie_blacklist.js");
|
||||
var cookieURI = Services.io.newURI(
|
||||
"http://mozilla.org/test_cookie_blacklist.js"
|
||||
);
|
||||
const channel = NetUtil.newChannel({
|
||||
uri: cookieURI,
|
||||
loadUsingSystemPrincipal: true,
|
||||
|
@ -9,10 +9,7 @@ XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
});
|
||||
|
||||
function inChildProcess() {
|
||||
return (
|
||||
Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
|
||||
);
|
||||
return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
function check_request_header(chan, name, value) {
|
||||
|
@ -47,6 +47,5 @@ add_task(async function test_cookie_ipv6() {
|
||||
await new Promise(resolve => {
|
||||
chan.asyncOpen(new ChannelListener(resolve));
|
||||
});
|
||||
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
equal(cm.cookies.length, 1);
|
||||
equal(Services.cookies.cookies.length, 1);
|
||||
});
|
||||
|
@ -21,10 +21,7 @@ var cookieSetPath = "/setcookie";
|
||||
var cookieCheckPath = "/checkcookie";
|
||||
|
||||
function inChildProcess() {
|
||||
return (
|
||||
Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
|
||||
);
|
||||
return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
// Test array:
|
||||
|
@ -44,10 +44,7 @@ var safebrowsingGethashPath = "/safebrowsingGethash";
|
||||
var httpserver;
|
||||
|
||||
function inChildProcess() {
|
||||
return (
|
||||
Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
|
||||
);
|
||||
return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
function cookieSetHandler(metadata, response) {
|
||||
|
@ -47,10 +47,7 @@ var listener2 = {
|
||||
const defaultOriginAttributes = {};
|
||||
|
||||
function run_test() {
|
||||
var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
var mainThread = threadManager.currentThread;
|
||||
var mainThread = Services.tm.currentThread;
|
||||
|
||||
var flags = Ci.nsIDNSService.RESOLVE_BYPASS_CACHE;
|
||||
|
||||
|
@ -6,9 +6,6 @@
|
||||
"use strict";
|
||||
|
||||
var dns = Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService);
|
||||
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
|
||||
var listener = {
|
||||
onLookupComplete(inRequest, inRecord, inStatus) {
|
||||
|
@ -3,13 +3,10 @@
|
||||
const dns = Cc["@mozilla.org/network/dns-service;1"].getService(
|
||||
Ci.nsIDNSService
|
||||
);
|
||||
const threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
const override = Cc["@mozilla.org/network/native-dns-override;1"].getService(
|
||||
Ci.nsINativeDNSResolverOverride
|
||||
);
|
||||
const mainThread = threadManager.currentThread;
|
||||
const mainThread = Services.tm.currentThread;
|
||||
|
||||
function makeListenerBlock(next) {
|
||||
return {
|
||||
|
@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var dns = Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService);
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
var prefs = Services.prefs;
|
||||
|
||||
var nextTest;
|
||||
|
||||
@ -24,10 +22,7 @@ const defaultOriginAttributes = {};
|
||||
function run_test() {
|
||||
prefs.setCharPref("network.dns.localDomains", "local.vingtetun.org");
|
||||
|
||||
var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
var mainThread = threadManager.currentThread;
|
||||
var mainThread = Services.tm.currentThread;
|
||||
nextTest = do_test_2;
|
||||
dns.asyncResolve(
|
||||
"local.vingtetun.org",
|
||||
@ -43,10 +38,7 @@ function run_test() {
|
||||
}
|
||||
|
||||
function do_test_2() {
|
||||
var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
var mainThread = threadManager.currentThread;
|
||||
var mainThread = Services.tm.currentThread;
|
||||
nextTest = testsDone;
|
||||
prefs.setCharPref("network.dns.forceResolve", "localhost");
|
||||
dns.asyncResolve(
|
||||
|
@ -1,16 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var dns = Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService);
|
||||
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
var mainThread = threadManager.currentThread;
|
||||
var ioService = Services.io;
|
||||
var prefs = Services.prefs;
|
||||
var mainThread = Services.tm.currentThread;
|
||||
|
||||
var listener1 = {
|
||||
onLookupComplete(inRequest, inRecord, inStatus) {
|
||||
|
@ -1,16 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
var dns = Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService);
|
||||
var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
var mainThread = threadManager.currentThread;
|
||||
var mainThread = Services.tm.currentThread;
|
||||
|
||||
var onionPref;
|
||||
var localdomainPref;
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
var prefs = Services.prefs;
|
||||
|
||||
// check that we don't lookup .onion
|
||||
var listenerBlock = {
|
||||
|
@ -1,13 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var dns = Cc["@mozilla.org/network/dns-service;1"].getService(Ci.nsIDNSService);
|
||||
var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
var mainThread = threadManager.currentThread;
|
||||
var prefs = Services.prefs;
|
||||
var mainThread = Services.tm.currentThread;
|
||||
|
||||
var listener1 = {
|
||||
onLookupComplete(inRequest, inRecord, inStatus) {
|
||||
|
@ -7,10 +7,7 @@ const override = Cc["@mozilla.org/network/native-dns-override;1"].getService(
|
||||
Ci.nsINativeDNSResolverOverride
|
||||
);
|
||||
const defaultOriginAttributes = {};
|
||||
const threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
const mainThread = threadManager.currentThread;
|
||||
const mainThread = Services.tm.currentThread;
|
||||
|
||||
class Listener {
|
||||
constructor() {
|
||||
|
@ -7,10 +7,7 @@ const override = Cc["@mozilla.org/network/native-dns-override;1"].getService(
|
||||
Ci.nsINativeDNSResolverOverride
|
||||
);
|
||||
const defaultOriginAttributes = {};
|
||||
const threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
const mainThread = threadManager.currentThread;
|
||||
const mainThread = Services.tm.currentThread;
|
||||
|
||||
class Listener {
|
||||
constructor() {
|
||||
|
@ -4,13 +4,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(
|
||||
Ci.nsIIOService
|
||||
);
|
||||
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(
|
||||
Ci.nsIPrefBranch
|
||||
);
|
||||
var prefs = Services.prefs;
|
||||
|
||||
function setup() {
|
||||
prefs.setBoolPref("network.dns.notifyResolution", true);
|
||||
@ -33,9 +27,7 @@ var url = "ws://dnsleak.example.com";
|
||||
|
||||
var dnsRequestObserver = {
|
||||
register() {
|
||||
this.obs = Cc["@mozilla.org/observer-service;1"].getService(
|
||||
Ci.nsIObserverService
|
||||
);
|
||||
this.obs = Services.obs;
|
||||
this.obs.addObserver(this, "dns-resolution-request");
|
||||
},
|
||||
|
||||
@ -74,7 +66,7 @@ add_task(async function test_dns_websocket_channel() {
|
||||
Ci.nsIWebSocketChannel
|
||||
);
|
||||
|
||||
var uri = ioService.newURI(url);
|
||||
var uri = Services.io.newURI(url);
|
||||
chan.initLoadInfo(
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.createContentPrincipal(uri, {}),
|
||||
|
@ -4,10 +4,7 @@ const dns = Cc["@mozilla.org/network/dns-service;1"].getService(
|
||||
Ci.nsIDNSService
|
||||
);
|
||||
const defaultOriginAttributes = {};
|
||||
const threadManager = Cc["@mozilla.org/thread-manager;1"].getService(
|
||||
Ci.nsIThreadManager
|
||||
);
|
||||
const mainThread = threadManager.currentThread;
|
||||
const mainThread = Services.tm.currentThread;
|
||||
|
||||
const overrideService = Cc[
|
||||
"@mozilla.org/network/native-dns-override;1"
|
||||
@ -74,8 +71,7 @@ add_task(async function test_idn_cname() {
|
||||
add_task(
|
||||
{
|
||||
skip_if: () =>
|
||||
Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT,
|
||||
Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT,
|
||||
},
|
||||
async function test_long_domain() {
|
||||
let listener = new Listener();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user