mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1819960 - Convert some netwerk files to ES modules. r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D171489
This commit is contained in:
parent
8561f9a888
commit
6c4b226572
@ -3,9 +3,6 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["CookieXPCShellUtils"];
|
||||
|
||||
const { ExtensionTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/ExtensionXPCShellUtils.jsm"
|
||||
@ -15,7 +12,7 @@ const { AddonTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/AddonTestUtils.jsm"
|
||||
);
|
||||
|
||||
const CookieXPCShellUtils = {
|
||||
export const CookieXPCShellUtils = {
|
||||
init(scope) {
|
||||
AddonTestUtils.maybeInit(scope);
|
||||
ExtensionTestUtils.init(scope);
|
@ -66,7 +66,7 @@ LOCAL_INCLUDES += [
|
||||
]
|
||||
|
||||
TESTING_JS_MODULES += [
|
||||
"CookieXPCShellUtils.jsm",
|
||||
"CookieXPCShellUtils.sys.mjs",
|
||||
]
|
||||
|
||||
include("/ipc/chromium/chromium-config.mozbuild")
|
||||
|
@ -1,21 +1,17 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const { RemoteSettings } = ChromeUtils.importESModule(
|
||||
"resource://services-settings/remote-settings.sys.mjs"
|
||||
);
|
||||
import { RemoteSettings } from "resource://services-settings/remote-settings.sys.mjs";
|
||||
|
||||
const FileUtils = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/FileUtils.sys.mjs"
|
||||
).FileUtils;
|
||||
|
||||
const EXPORTED_SYMBOLS = ["PublicSuffixList"];
|
||||
|
||||
const RECORD_ID = "tld-dafsa";
|
||||
const SIGNAL = "public-suffix-list-updated";
|
||||
|
||||
const PublicSuffixList = {
|
||||
export const PublicSuffixList = {
|
||||
CLIENT: RemoteSettings("public-suffix-list"),
|
||||
|
||||
init() {
|
@ -25,7 +25,7 @@ XPIDL_SOURCES += [
|
||||
XPIDL_MODULE = "necko_dns"
|
||||
|
||||
EXTRA_JS_MODULES["netwerk-dns"] += [
|
||||
"PublicSuffixList.jsm",
|
||||
"PublicSuffixList.sys.mjs",
|
||||
]
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += ["tests/unit/xpcshell.ini"]
|
||||
|
@ -3,9 +3,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
function WellKnownOpportunisticUtils() {
|
||||
export function WellKnownOpportunisticUtils() {
|
||||
this.valid = false;
|
||||
this.mixed = false;
|
||||
this.lifetime = 0;
|
||||
@ -26,5 +24,3 @@ WellKnownOpportunisticUtils.prototype = {
|
||||
this.valid = true;
|
||||
},
|
||||
};
|
||||
|
||||
var EXPORTED_SYMBOLS = ["WellKnownOpportunisticUtils"];
|
@ -8,7 +8,7 @@ Classes = [
|
||||
{
|
||||
'cid': '{b4f96c89-5238-450c-8bda-e12c26f1d150}',
|
||||
'contract_ids': ['@mozilla.org/network/well-known-opportunistic-utils;1'],
|
||||
'jsm': 'resource://gre/modules/WellKnownOpportunisticUtils.jsm',
|
||||
'esModule': 'resource://gre/modules/WellKnownOpportunisticUtils.sys.mjs',
|
||||
'constructor': 'WellKnownOpportunisticUtils',
|
||||
},
|
||||
{
|
||||
|
@ -207,7 +207,7 @@ if CONFIG["MOZ_AUTH_EXTENSION"]:
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
"WellKnownOpportunisticUtils.jsm",
|
||||
"WellKnownOpportunisticUtils.sys.mjs",
|
||||
]
|
||||
|
||||
XPCOM_MANIFESTS += [
|
||||
|
@ -102,20 +102,20 @@ skip-if =
|
||||
[browser_103_telemetry.js]
|
||||
[browser_103_preload.js]
|
||||
support-files =
|
||||
early_hint_preload_test_helper.jsm
|
||||
early_hint_preload_test_helper.sys.mjs
|
||||
[browser_103_preload_2.js]
|
||||
support-files =
|
||||
early_hint_preload_test_helper.jsm
|
||||
early_hint_preload_test_helper.sys.mjs
|
||||
[browser_103_redirect.js]
|
||||
support-files =
|
||||
early_hint_preload_test_helper.jsm
|
||||
early_hint_preload_test_helper.sys.mjs
|
||||
[browser_103_error.js]
|
||||
support-files =
|
||||
early_hint_preload_test_helper.jsm
|
||||
early_hint_preload_test_helper.sys.mjs
|
||||
[browser_103_assets.js]
|
||||
[browser_103_no_cancel_on_error.js]
|
||||
support-files =
|
||||
early_hint_preload_test_helper.jsm
|
||||
early_hint_preload_test_helper.sys.mjs
|
||||
[browser_103_redirect_from_server.js]
|
||||
[browser_cookie_filtering_basic.js]
|
||||
[browser_cookie_filtering_insecure.js]
|
||||
@ -124,20 +124,20 @@ support-files =
|
||||
[browser_cookie_filtering_subdomain.js]
|
||||
[browser_103_user_load.js]
|
||||
support-files =
|
||||
early_hint_preload_test_helper.jsm
|
||||
early_hint_preload_test_helper.sys.mjs
|
||||
[browser_103_referrer_policy.js]
|
||||
support-files =
|
||||
early_hint_referrer_policy_html.sjs
|
||||
early_hint_preload_test_helper.jsm
|
||||
early_hint_preload_test_helper.sys.mjs
|
||||
[browser_103_csp.js]
|
||||
support-files =
|
||||
early_hint_preload_test_helper.jsm
|
||||
early_hint_preload_test_helper.sys.mjs
|
||||
[browser_103_csp_images.js]
|
||||
support-files =
|
||||
early_hint_preload_test_helper.jsm
|
||||
early_hint_preload_test_helper.sys.mjs
|
||||
[browser_103_csp_styles.js]
|
||||
support-files =
|
||||
early_hint_preload_test_helper.jsm
|
||||
early_hint_preload_test_helper.sys.mjs
|
||||
[browser_103_preconnect.js]
|
||||
[browser_103_cleanup.js]
|
||||
[browser_bug1629307.js]
|
||||
|
@ -2,7 +2,6 @@
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
// The functions in this file will run in the content process in a test
|
||||
// scope.
|
||||
@ -13,39 +12,25 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
const info = console.log;
|
||||
|
||||
var EXPORTED_SYMBOLS = [
|
||||
"HTTPS_EXAMPLE_ORG",
|
||||
"HTTPS_EXAMPLE_COM",
|
||||
"HTTP_EXAMPLE_COM",
|
||||
"browserTestPath",
|
||||
"waitForAllExpectedTests",
|
||||
"cleanupObservers",
|
||||
"triggerSetCookieFromHttp",
|
||||
"triggerSetCookieFromHttpPrivate",
|
||||
"checkExpectedCookies",
|
||||
"fetchHelper",
|
||||
"preclean_test",
|
||||
"cleanup_test",
|
||||
];
|
||||
var HTTPS_EXAMPLE_ORG = "https://example.org";
|
||||
var HTTPS_EXAMPLE_COM = "https://example.com";
|
||||
var HTTP_EXAMPLE_COM = "http://example.com";
|
||||
export var HTTPS_EXAMPLE_ORG = "https://example.org";
|
||||
export var HTTPS_EXAMPLE_COM = "https://example.com";
|
||||
export var HTTP_EXAMPLE_COM = "http://example.com";
|
||||
|
||||
function browserTestPath(uri) {
|
||||
export function browserTestPath(uri) {
|
||||
return uri + "/browser/netwerk/test/browser/";
|
||||
}
|
||||
|
||||
function waitForAllExpectedTests() {
|
||||
export function waitForAllExpectedTests() {
|
||||
return ContentTaskUtils.waitForCondition(() => {
|
||||
return content.testDone === true;
|
||||
});
|
||||
}
|
||||
|
||||
function cleanupObservers() {
|
||||
export function cleanupObservers() {
|
||||
Services.obs.notifyObservers(null, "cookie-content-filter-cleanup");
|
||||
}
|
||||
|
||||
async function preclean_test() {
|
||||
export async function preclean_test() {
|
||||
// enable all cookies for the set-cookie trigger via setCookieStringFromHttp
|
||||
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
|
||||
Services.prefs.setBoolPref(
|
||||
@ -63,7 +48,7 @@ async function preclean_test() {
|
||||
Services.cookies.removeAll();
|
||||
}
|
||||
|
||||
async function cleanup_test() {
|
||||
export async function cleanup_test() {
|
||||
Services.prefs.clearUserPref("network.cookie.cookieBehavior");
|
||||
Services.prefs.clearUserPref(
|
||||
"network.cookieJarSettings.unblocked_for_testing"
|
||||
@ -76,7 +61,7 @@ async function cleanup_test() {
|
||||
Services.cookies.removeAll();
|
||||
}
|
||||
|
||||
async function fetchHelper(url, cookie, secure, domain = "") {
|
||||
export async function fetchHelper(url, cookie, secure, domain = "") {
|
||||
let headers = new Headers();
|
||||
|
||||
headers.append("return-set-cookie", cookie);
|
||||
@ -95,7 +80,7 @@ async function fetchHelper(url, cookie, secure, domain = "") {
|
||||
|
||||
// cookie header strings with multiple name=value pairs delimited by \n
|
||||
// will trigger multiple "cookie-changed" signals
|
||||
function triggerSetCookieFromHttp(uri, cookie, fpd = "", ucd = 0) {
|
||||
export function triggerSetCookieFromHttp(uri, cookie, fpd = "", ucd = 0) {
|
||||
info("about to trigger set-cookie: " + uri + " " + cookie);
|
||||
let channel = NetUtil.newChannel({
|
||||
uri,
|
||||
@ -113,7 +98,7 @@ function triggerSetCookieFromHttp(uri, cookie, fpd = "", ucd = 0) {
|
||||
Services.cookies.setCookieStringFromHttp(uri, cookie, channel);
|
||||
}
|
||||
|
||||
async function triggerSetCookieFromHttpPrivate(uri, cookie) {
|
||||
export async function triggerSetCookieFromHttpPrivate(uri, cookie) {
|
||||
info("about to trigger set-cookie: " + uri + " " + cookie);
|
||||
let channel = NetUtil.newChannel({
|
||||
uri,
|
||||
@ -127,7 +112,7 @@ async function triggerSetCookieFromHttpPrivate(uri, cookie) {
|
||||
|
||||
// observer/listener function that will be run on the content processes
|
||||
// listens and checks for the expected cookies
|
||||
function checkExpectedCookies(expected, browserName) {
|
||||
export function checkExpectedCookies(expected, browserName) {
|
||||
const COOKIE_FILTER_TEST_MESSAGE = "cookie-content-filter-test";
|
||||
const COOKIE_FILTER_TEST_CLEANUP = "cookie-content-filter-cleanup";
|
||||
|
@ -2,24 +2,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
import { Assert } from "resource://testing-common/Assert.sys.mjs";
|
||||
import { BrowserTestUtils } from "resource://testing-common/BrowserTestUtils.sys.mjs";
|
||||
|
||||
const EXPORTED_SYMBOLS = [
|
||||
"request_count_checking",
|
||||
"test_hint_preload",
|
||||
"test_hint_preload_internal",
|
||||
"test_preload_hint_and_request",
|
||||
];
|
||||
|
||||
const { Assert } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/Assert.sys.mjs"
|
||||
);
|
||||
const { BrowserTestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/BrowserTestUtils.sys.mjs"
|
||||
);
|
||||
const { gBrowser } = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
|
||||
async function request_count_checking(testName, got, expected) {
|
||||
export async function request_count_checking(testName, got, expected) {
|
||||
// stringify to pretty print assert output
|
||||
let g = JSON.stringify(got);
|
||||
let e = JSON.stringify(expected);
|
||||
@ -38,7 +26,7 @@ async function request_count_checking(testName, got, expected) {
|
||||
);
|
||||
}
|
||||
|
||||
async function test_hint_preload(
|
||||
export async function test_hint_preload(
|
||||
testName,
|
||||
requestFrom,
|
||||
imgUrl,
|
||||
@ -63,7 +51,7 @@ async function test_hint_preload(
|
||||
// - urls are in the form [[url1, uuid1], ...]. The uuids are there to make each preload
|
||||
// unique and not available in the cache from other test cases
|
||||
// - expectedRequestCount is the sum of all requested objects { normal: count, hinted: count }
|
||||
async function test_hint_preload_internal(
|
||||
export async function test_hint_preload_internal(
|
||||
testName,
|
||||
requestFrom,
|
||||
imgUrls,
|
||||
@ -113,7 +101,7 @@ async function test_hint_preload_internal(
|
||||
// Client-side, we verify that the image was loaded or not loaded, depending on the scenario
|
||||
|
||||
// This verifies preload hints and requests
|
||||
async function test_preload_hint_and_request(input, expected_results) {
|
||||
export async function test_preload_hint_and_request(input, expected_results) {
|
||||
// reset the count
|
||||
let headers = new Headers();
|
||||
headers.append("X-Early-Hint-Count-Start", "");
|
@ -19,8 +19,8 @@ XPCSHELL_TESTS_MANIFESTS += [
|
||||
]
|
||||
|
||||
TESTING_JS_MODULES += [
|
||||
"browser/cookie_filtering_helper.jsm",
|
||||
"browser/early_hint_preload_test_helper.jsm",
|
||||
"browser/cookie_filtering_helper.sys.mjs",
|
||||
"browser/early_hint_preload_test_helper.sys.mjs",
|
||||
"unit/test_http3_prio_helpers.js",
|
||||
]
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
function UrlClassifierExceptionListService() {}
|
||||
export function UrlClassifierExceptionListService() {}
|
||||
|
||||
const lazy = {};
|
||||
|
||||
@ -166,5 +166,3 @@ UrlClassifierExceptionListService.prototype = {
|
||||
this.entries = null;
|
||||
},
|
||||
};
|
||||
|
||||
var EXPORTED_SYMBOLS = ["UrlClassifierExceptionListService"];
|
@ -16,7 +16,7 @@ Classes = [
|
||||
{
|
||||
'cid': '{b9f4fd03-9d87-4bfd-9958-85a821750ddc}',
|
||||
'contract_ids': ['@mozilla.org/url-classifier/exception-list-service;1'],
|
||||
'jsm': 'resource://gre/modules/UrlClassifierExceptionListService.jsm',
|
||||
'esModule': 'resource://gre/modules/UrlClassifierExceptionListService.sys.mjs',
|
||||
'constructor': 'UrlClassifierExceptionListService',
|
||||
},
|
||||
]
|
||||
|
@ -17,7 +17,7 @@ XPIDL_SOURCES += [
|
||||
XPIDL_MODULE = "url-classifier"
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
"UrlClassifierExceptionListService.jsm",
|
||||
"UrlClassifierExceptionListService.sys.mjs",
|
||||
]
|
||||
|
||||
XPCOM_MANIFESTS += [
|
||||
|
Loading…
Reference in New Issue
Block a user