Skip to content

Commit

Permalink
Bug 1834176 - Convert NetUtil.jsm to be an ES system module. r=arai,w…
Browse files Browse the repository at this point in the history
…ebdriver-reviewers,perftest-reviewers,valentin,extension-reviewers,devtools-reviewers,sync-reviewers,cookie-reviewers,robwu,afinder,whimboo

Differential Revision: https://phabricator.services.mozilla.com/D178589
  • Loading branch information
Standard8 committed May 23, 2023
1 parent f9b1e17 commit fbc15bd
Show file tree
Hide file tree
Showing 152 changed files with 349 additions and 291 deletions.
2 changes: 1 addition & 1 deletion browser/base/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ChromeUtils.defineESModuleGetters(this, {
LoginHelper: "resource://gre/modules/LoginHelper.sys.mjs",
LoginManagerParent: "resource://gre/modules/LoginManagerParent.sys.mjs",
MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
NewTabUtils: "resource://gre/modules/NewTabUtils.sys.mjs",
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
PageThumbs: "resource://gre/modules/PageThumbs.sys.mjs",
Expand Down Expand Up @@ -90,7 +91,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
CustomizableUI: "resource:///modules/CustomizableUI.jsm",
ExtensionsUI: "resource:///modules/ExtensionsUI.jsm",
HomePage: "resource:///modules/HomePage.jsm",
NetUtil: "resource://gre/modules/NetUtil.jsm",
OpenInTabsUtils: "resource:///modules/OpenInTabsUtils.jsm",
PageActions: "resource:///modules/PageActions.jsm",
ProcessHangMonitor: "resource:///modules/ProcessHangMonitor.jsm",
Expand Down
8 changes: 3 additions & 5 deletions browser/base/content/test/performance/PerfTestHelpers.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

const lazy = {};

ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm"
);
ChromeUtils.defineESModuleGetters(lazy, {
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
});

export var PerfTestHelpers = {
/**
Expand Down
2 changes: 1 addition & 1 deletion browser/components/BrowserGlue.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
Interactions: "resource:///modules/Interactions.sys.mjs",
Log: "resource://gre/modules/Log.sys.mjs",
LoginBreaches: "resource:///modules/LoginBreaches.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
NewTabUtils: "resource://gre/modules/NewTabUtils.sys.mjs",
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
Normandy: "resource://normandy/Normandy.sys.mjs",
Expand Down Expand Up @@ -88,7 +89,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
Discovery: "resource:///modules/Discovery.jsm",
ExtensionsUI: "resource:///modules/ExtensionsUI.jsm",
HomePage: "resource:///modules/HomePage.jsm",
NetUtil: "resource://gre/modules/NetUtil.jsm",
OnboardingMessageProvider:
"resource://activity-stream/lib/OnboardingMessageProvider.jsm",
PageActions: "resource:///modules/PageActions.jsm",
Expand Down
4 changes: 3 additions & 1 deletion browser/components/doh/test/unit/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

"use strict";

const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);
const { PromiseUtils } = ChromeUtils.importESModule(
"resource://gre/modules/PromiseUtils.sys.mjs"
);
Expand Down
2 changes: 1 addition & 1 deletion browser/components/downloads/DownloadsCommon.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ ChromeUtils.defineESModuleGetters(lazy, {
DownloadHistory: "resource://gre/modules/DownloadHistory.sys.mjs",
DownloadUtils: "resource://gre/modules/DownloadUtils.sys.mjs",
Downloads: "resource://gre/modules/Downloads.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
});

XPCOMUtils.defineLazyModuleGetters(lazy, {
NetUtil: "resource://gre/modules/NetUtil.jsm",
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
});

Expand Down
2 changes: 1 addition & 1 deletion browser/components/downloads/content/allDownloadsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ ChromeUtils.defineESModuleGetters(this, {
DownloadsCommon: "resource:///modules/DownloadsCommon.sys.mjs",
DownloadsViewUI: "resource:///modules/DownloadsViewUI.sys.mjs",
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
});

XPCOMUtils.defineLazyModuleGetters(this, {
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
NetUtil: "resource://gre/modules/NetUtil.jsm",
});

/**
Expand Down
6 changes: 1 addition & 5 deletions browser/components/downloads/content/downloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ var { XPCOMUtils } = ChromeUtils.importESModule(
ChromeUtils.defineESModuleGetters(this, {
DownloadsViewUI: "resource:///modules/DownloadsViewUI.sys.mjs",
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
});
ChromeUtils.defineModuleGetter(
this,
"NetUtil",
"resource://gre/modules/NetUtil.jsm"
);

const { Integration } = ChromeUtils.importESModule(
"resource://gre/modules/Integration.sys.mjs"
Expand Down
6 changes: 1 addition & 5 deletions browser/components/downloads/test/unit/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ ChromeUtils.defineESModuleGetters(this, {
DownloadsCommon: "resource:///modules/DownloadsCommon.sys.mjs",
FileTestUtils: "resource://testing-common/FileTestUtils.sys.mjs",
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
TestUtils: "resource://testing-common/TestUtils.sys.mjs",
});
ChromeUtils.defineModuleGetter(
this,
"NetUtil",
"resource://gre/modules/NetUtil.jsm"
);

async function createDownloadedFile(pathname, contents) {
info("createDownloadedFile: " + pathname);
Expand Down
2 changes: 1 addition & 1 deletion browser/components/extensions/test/xpcshell/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const { AppConstants } = ChromeUtils.importESModule(
// eslint-disable-next-line no-unused-vars
ChromeUtils.defineESModuleGetters(this, {
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
TestUtils: "resource://testing-common/TestUtils.sys.mjs",
});

Expand All @@ -20,7 +21,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
ExtensionData: "resource://gre/modules/Extension.jsm",
ExtensionTestUtils: "resource://testing-common/ExtensionXPCShellUtils.jsm",
HttpServer: "resource://testing-common/httpd.js",
NetUtil: "resource://gre/modules/NetUtil.jsm",
Schemas: "resource://gre/modules/Schemas.jsm",
});

Expand Down
6 changes: 1 addition & 5 deletions browser/components/migration/ChromeProfileMigrator.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const AUTH_TYPE = {
SCHEME_DIGEST: 2,
};

import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { MigrationUtils } from "resource:///modules/MigrationUtils.sys.mjs";
import { MigratorBase } from "resource:///modules/MigratorBase.sys.mjs";
Expand All @@ -20,14 +19,11 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
ChromeMigrationUtils: "resource:///modules/ChromeMigrationUtils.sys.mjs",
FormHistory: "resource://gre/modules/FormHistory.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
Qihoo360seMigrationUtils: "resource:///modules/360seMigrationUtils.sys.mjs",
});

XPCOMUtils.defineLazyModuleGetters(lazy, {
NetUtil: "resource://gre/modules/NetUtil.jsm",
});

/**
* Converts an array of chrome bookmark objects into one our own places code
* understands.
Expand Down
4 changes: 3 additions & 1 deletion browser/components/migration/tests/unit/head_migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ var { MigrationUtils } = ChromeUtils.importESModule(
var { LoginHelper } = ChromeUtils.importESModule(
"resource://gre/modules/LoginHelper.sys.mjs"
);
var { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
var { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);
var { PlacesUtils } = ChromeUtils.importESModule(
"resource://gre/modules/PlacesUtils.sys.mjs"
);
Expand Down
9 changes: 1 addition & 8 deletions browser/components/search/test/unit/test_urlTelemetry.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */

const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);

ChromeUtils.defineESModuleGetters(this, {
BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
SearchSERPTelemetry: "resource:///modules/SearchSERPTelemetry.sys.mjs",
SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});

XPCOMUtils.defineLazyModuleGetters(this, {
NetUtil: "resource://gre/modules/NetUtil.jsm",
});

const TESTS = [
{
title: "Google search access point",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */

const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);

ChromeUtils.defineESModuleGetters(this, {
BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
SearchSERPTelemetry: "resource:///modules/SearchSERPTelemetry.sys.mjs",
SearchSERPTelemetryUtils: "resource:///modules/SearchSERPTelemetry.sys.mjs",
SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});

XPCOMUtils.defineLazyModuleGetters(this, {
NetUtil: "resource://gre/modules/NetUtil.jsm",
});

const TEST_PROVIDER_INFO = [
{
telemetryId: "example",
Expand Down
4 changes: 3 additions & 1 deletion browser/components/sessionstore/test/coopHeaderCommon.sjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
function handleRequest(request, response) {
Cu.importGlobalProperties(["URLSearchParams"]);
let { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
let { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);
let query = new URLSearchParams(request.queryString);

response.setHeader("Cross-Origin-Opener-Policy", "same-origin", false);
Expand Down
4 changes: 3 additions & 1 deletion browser/modules/WindowsPreviewPerTab.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
*/
var EXPORTED_SYMBOLS = ["AeroPeek"];

const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);
const { PlacesUtils } = ChromeUtils.importESModule(
"resource://gre/modules/PlacesUtils.sys.mjs"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { UrlClassifierTestUtils } from "resource://testing-common/UrlClassifierT

import { SitePermissions } from "resource:///modules/SitePermissions.sys.mjs";

const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
import { NetUtil } from "resource://gre/modules/NetUtil.sys.mjs";

const CC_SELECTORS = ["#identity-popup", "#urlbar-input-container"];
const PP_SELECTORS = ["#protections-popup", "#urlbar-input-container"];
Expand Down
4 changes: 3 additions & 1 deletion chrome/test/unit/test_create_channel_chrome_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

"use strict";

const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);

function testURL(url) {
Services.io.newChannelFromURI(
Expand Down
6 changes: 1 addition & 5 deletions devtools/client/shared/remote-debugging/adb/adb-binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ ChromeUtils.defineModuleGetter(
);
ChromeUtils.defineESModuleGetters(lazy, {
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
});
ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm"
);
loader.lazyGetter(this, "UNPACKED_ROOT_PATH", () => {
return PathUtils.join(PathUtils.localProfileDir, "adb");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
const { ExtensionTestUtils } = ChromeUtils.import(
"resource://testing-common/ExtensionXPCShellUtils.jsm"
);
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);
const {
getFileForBinary,
} = require("resource://devtools/client/shared/remote-debugging/adb/adb-binary.js");
Expand Down
6 changes: 1 addition & 5 deletions devtools/client/styleeditor/StyleEditorUI.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ loader.lazyRequireGetter(

ChromeUtils.defineESModuleGetters(lazy, {
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
});
ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm"
);
loader.lazyRequireGetter(
lazy,
"ResponsiveUIManager",
Expand Down
6 changes: 1 addition & 5 deletions devtools/client/styleeditor/StyleSheetEditor.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ loader.lazyGetter(lazy, "BufferStream", () => {

ChromeUtils.defineESModuleGetters(lazy, {
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
});
ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm"
);

import {
getString,
Expand Down
6 changes: 1 addition & 5 deletions devtools/server/actors/network-monitor/network-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ const {
} = require("resource://devtools/shared/specs/network-content.js");

const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm"
);

ChromeUtils.defineESModuleGetters(lazy, {
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
NetworkUtils:
"resource://devtools/shared/network-observer/NetworkUtils.sys.mjs",
});
Expand Down
4 changes: 3 additions & 1 deletion devtools/server/tests/xpcshell/head_dbg.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const { worker } = ChromeUtils.import(
"resource://devtools/shared/loader/worker-loader.js"
);

const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);

// Always log packets when running tests. runxpcshelltests.py will throw
// the output away anyway, unless you give it the --verbose flag.
Expand Down
3 changes: 2 additions & 1 deletion devtools/shared/DevToolsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,8 @@ Object.defineProperty(exports, "assert", {
});

DevToolsUtils.defineLazyGetter(this, "NetUtil", () => {
return ChromeUtils.import("resource://gre/modules/NetUtil.jsm").NetUtil;
return ChromeUtils.importESModule("resource://gre/modules/NetUtil.sys.mjs")
.NetUtil;
});

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ add_task(async function testParentProcessRequests() {
tab.linkedBrowser,
[requestUrl],
async function (uri) {
const { NetUtil } = ChromeUtils.import(
"resource://gre/modules/NetUtil.jsm"
const { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);
const channel = NetUtil.newChannel({
uri,
Expand Down Expand Up @@ -198,8 +198,8 @@ add_task(async function testParentProcessRequests() {
secondTab.linkedBrowser,
[requestUrl],
async function (uri) {
const { NetUtil } = ChromeUtils.import(
"resource://gre/modules/NetUtil.jsm"
const { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);
const channel = NetUtil.newChannel({
uri,
Expand Down
8 changes: 3 additions & 5 deletions devtools/shared/layout/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ loader.lazyRequireGetter(
"resource://devtools/shared/DevToolsUtils.js"
);
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm"
);
ChromeUtils.defineESModuleGetters(lazy, {
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
});

const SHEET_TYPE = {
agent: "AGENT_SHEET",
Expand Down
8 changes: 3 additions & 5 deletions devtools/shared/loader/base-loader.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ XPCOMUtils.defineLazyServiceGetter(
"nsIResProtocolHandler"
);

ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm"
);
ChromeUtils.defineESModuleGetters(lazy, {
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
});

// Define some shortcuts.
function* getOwnIdentifiers(x) {
Expand Down
Loading

0 comments on commit fbc15bd

Please sign in to comment.