Bug 1780543 - Part 3: Add mozilla/process-script environment as alias to frame-script. r=Standard8,perftest-reviewers,webcompat-reviewers,necko-reviewers,twisniewski,sparky,dragana
authorTooru Fujisawa <arai_a@mac.com>
Tue, 26 Jul 2022 02:46:29 +0000
changeset 625123 e0ba4db5a86b7d10aad1ebf44415dbc73fa775d7
parent 625122 ae908c7f89f2cb87fec252a908a08bb8a510ab36
child 625124 3b36e3518d0f066a1a461925e690c00af438bc42
push id166788
push userarai_a@mac.com
push dateTue, 26 Jul 2022 02:49:43 +0000
treeherderautoland@b1c809ded882 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, perftest-reviewers, webcompat-reviewers, necko-reviewers, twisniewski, sparky, dragana
bugs1780543
milestone105.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1780543 - Part 3: Add mozilla/process-script environment as alias to frame-script. r=Standard8,perftest-reviewers,webcompat-reviewers,necko-reviewers,twisniewski,sparky,dragana Differential Revision: https://phabricator.services.mozilla.com/D152428
browser/extensions/webcompat/about-compat/aboutPageProcessScript.js
devtools/client/shared/test/shared-head.js
devtools/server/actors/webconsole/content-process-forward.js
devtools/server/startup/content-process-script.js
devtools/server/startup/content-process.js
devtools/server/tests/browser/browser_getProcess.js
dom/base/test/browser_messagemanager_loadprocessscript.js
dom/base/test/chrome/file_bug1139964.xhtml
dom/base/test/chrome/window_swapFrameLoaders.xhtml
dom/ipc/tests/test_blob_sliced_from_child_process.js
dom/ipc/tests/test_blob_sliced_from_parent_process.js
dom/ipc/tests/test_bug1086684.js
dom/ipc/tests/test_child_docshell.js
dom/security/test/mixedcontentblocker/file_main_bug803225.html
netwerk/test/browser/browser_nsIFormPOSTActionChannel.js
testing/mochitest/BrowserTestUtils/content/content-about-page-utils.js
testing/talos/talos/tests/tabswitch/content/tabswitch-content-process.js
toolkit/components/extensions/extensionProcessScriptLoader.js
toolkit/content/process-content.js
tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js
tools/lint/eslint/eslint-plugin-mozilla/lib/index.js
--- a/browser/extensions/webcompat/about-compat/aboutPageProcessScript.js
+++ b/browser/extensions/webcompat/about-compat/aboutPageProcessScript.js
@@ -1,12 +1,14 @@
 /* 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/. */
 
+/* eslint-env mozilla/process-script */
+
 "use strict";
 
 // Note: This script is used only when a static registration for our
 // component is not already present in the libxul binary.
 
 const Cm = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
 
 const classID = Components.ID("{97bf9550-2a7b-11e9-b56e-0800200c9a66}");
--- a/devtools/client/shared/test/shared-head.js
+++ b/devtools/client/shared/test/shared-head.js
@@ -317,16 +317,17 @@ async function safeCloseBrowserConsole({
  * As a single test may create several DevTools servers, we keep the observer
  * alive until the test ends.
  *
  * To avoid leaks, the observer needs to be removed at the end of each test.
  * The test cleanup will send the async message "remove-devtools-highlightertestactor-observer",
  * we listen to this message to cleanup the observer.
  */
 function highlighterTestActorBootstrap() {
+  /* eslint-env mozilla/process-script */
   const HIGHLIGHTER_TEST_ACTOR_URL =
     "chrome://mochitests/content/browser/devtools/client/shared/test/highlighter-test-actor.js";
 
   const { require: _require } = ChromeUtils.import(
     "resource://devtools/shared/loader/Loader.jsm"
   );
   _require(HIGHLIGHTER_TEST_ACTOR_URL);
 
--- a/devtools/server/actors/webconsole/content-process-forward.js
+++ b/devtools/server/actors/webconsole/content-process-forward.js
@@ -1,12 +1,14 @@
 /* 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/. */
 
+/* eslint-env mozilla/process-script */
+
 "use strict";
 
 const { XPCOMUtils } = ChromeUtils.importESModule(
   "resource://gre/modules/XPCOMUtils.sys.mjs"
 );
 
 ChromeUtils.defineModuleGetter(
   this,
--- a/devtools/server/startup/content-process-script.js
+++ b/devtools/server/startup/content-process-script.js
@@ -1,12 +1,14 @@
 /* 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/. */
 
+/* eslint-env mozilla/process-script */
+
 "use strict";
 
 /**
  * Main entry point for DevTools in content processes.
  *
  * This module is loaded early when a content process is started.
  * Note that (at least) JS XPCOM registered at app-startup, will be running before.
  * It is used by the multiprocess browser toolbox in order to debug privileged resources.
--- a/devtools/server/startup/content-process.js
+++ b/devtools/server/startup/content-process.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-/* global addMessageListener, removeMessageListener */
+/* eslint-env mozilla/process-script */
 
 "use strict";
 
 /*
  * Process script that listens for requests to start a `DevToolsServer` for an entire
  * content process.  Loaded into content processes by the main process during
  * content-process-connector.js' `connectToContentProcess`.
  *
--- a/devtools/server/tests/browser/browser_getProcess.js
+++ b/devtools/server/tests/browser/browser_getProcess.js
@@ -74,18 +74,18 @@ add_task(async () => {
     is(
       front,
       firstTargetFront,
       "Second call to getProcess with the same id returns the same form"
     );
   }
 
   function processScript() {
+    /* eslint-env mozilla/process-script */
     const listener = function() {
-      /* global sendAsyncMessage */
       Services.obs.removeObserver(listener, "devtools:loader:destroy");
       sendAsyncMessage("test:getProcess-destroy", null);
     };
     Services.obs.addObserver(listener, "devtools:loader:destroy");
   }
 
   async function closeClient() {
     const onLoaderDestroyed = new Promise(done => {
--- a/dom/base/test/browser_messagemanager_loadprocessscript.js
+++ b/dom/base/test/browser_messagemanager_loadprocessscript.js
@@ -25,32 +25,34 @@ function checkBaseProcessCount(descripti
   const extraCount = baseProcessCount + 1;
   ok(
     childCount === baseProcessCount || childCount === extraCount,
     `${description} (${baseProcessCount} or ${extraCount})`
   );
 }
 
 function processScript() {
+  /* eslint-env mozilla/process-script */
   if (Services.cpmm !== this) {
     dump("Test failed: wrong global object\n");
     return;
   }
 
   this.cpmm = Services.cpmm;
 
   addMessageListener("ProcessTest:Reply", function listener(msg) {
     removeMessageListener("ProcessTest:Reply", listener);
     sendAsyncMessage("ProcessTest:Finished");
   });
   sendSyncMessage("ProcessTest:Loaded");
 }
 var processScriptURL = "data:,(" + processScript.toString() + ").call(this)";
 
 function initTestScript() {
+  /* eslint-env mozilla/process-script */
   let init = initialProcessData;
   if (init.test123 != "hello") {
     dump("Initial data incorrect\n");
     return;
   }
 
   sendAsyncMessage("ProcessTest:InitGood", init.test456.get("hi"));
 }
--- a/dom/base/test/chrome/file_bug1139964.xhtml
+++ b/dom/base/test/chrome/file_bug1139964.xhtml
@@ -16,16 +16,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   function ok(cond, msg) {
     window.arguments[0].ok(cond, msg);
   }
 
   var msgName = "TEST:Global_has_Promise";
 
   function mmScriptForPromiseTest() {
+    /* eslint-env mozilla/process-script */
     sendAsyncMessage("TEST:Global_has_Promise",
                      {
                        hasPromise: ("Promise" in this),
                        hasTextEncoder: ("TextEncoder" in this),
                        hasWindow: ("Window" in this),
                      });
   }
 
--- a/dom/base/test/chrome/window_swapFrameLoaders.xhtml
+++ b/dom/base/test/chrome/window_swapFrameLoaders.xhtml
@@ -36,18 +36,18 @@ Test swapFrameLoaders with different fra
     ["xul", "html", { userContextId: 2, remote: true }],
   ];
 
   const HEIGHTS = [
     200,
     400
   ];
 
-  /* eslint-env mozilla/frame-script */
   function frameScript() {
+    /* eslint-env mozilla/frame-script */
     addEventListener("load", function onLoad() {
       sendAsyncMessage("test:load");
     }, true);
   }
 
   // Watch for loads in new frames
   window.messageManager.loadFrameScript(`data:,(${frameScript})();`, true);
 
@@ -105,16 +105,17 @@ Test swapFrameLoaders with different fra
       info(`Adding frame A, type ${typeA}, options ${JSON.stringify(options)}, height ${heightA}`);
       let frameA = await addFrame(typeA, options, heightA);
 
       let heightB = HEIGHTS[1];
       info(`Adding frame B, type ${typeB}, options ${JSON.stringify(options)}, height ${heightB}`);
       let frameB = await addFrame(typeB, options, heightB);
 
       let frameScriptFactory = function(name) {
+        /* eslint-env mozilla/frame-script */
         return `function() {
           addMessageListener("ping", function() {
             sendAsyncMessage("pong", "${name}");
           });
           addMessageListener("check-browser-api", function() {
             let exists = "api" in this;
             sendAsyncMessage("check-browser-api", {
               exists,
--- a/dom/ipc/tests/test_blob_sliced_from_child_process.js
+++ b/dom/ipc/tests/test_blob_sliced_from_child_process.js
@@ -1,18 +1,18 @@
 "use strict";
-/* eslint-env mozilla/frame-script */
 
 const { XPCShellContentUtils } = ChromeUtils.import(
   "resource://testing-common/XPCShellContentUtils.jsm"
 );
 
 XPCShellContentUtils.init(this);
 
 function childFrameScript() {
+  /* eslint-env mozilla/frame-script */
   "use strict";
 
   const messageName = "test:blob-slice-test";
   const blobData = ["So", " ", "many", " ", "blobs!"];
   const blobType = "text/plain";
 
   let blob = new Blob(blobData, { type: blobType });
 
--- a/dom/ipc/tests/test_blob_sliced_from_parent_process.js
+++ b/dom/ipc/tests/test_blob_sliced_from_parent_process.js
@@ -1,18 +1,18 @@
 "use strict";
-/* eslint-env mozilla/frame-script */
 
 const { XPCShellContentUtils } = ChromeUtils.import(
   "resource://testing-common/XPCShellContentUtils.jsm"
 );
 
 XPCShellContentUtils.init(this);
 
 function childFrameScript() {
+  /* eslint-env mozilla/frame-script */
   const messageName = "test:blob-slice-test";
   const blobData = ["So", " ", "many", " ", "blobs!"];
   const blobText = blobData.join("");
   const blobType = "text/plain";
 
   const sliceText = "an";
 
   function info(msg) {
--- a/dom/ipc/tests/test_bug1086684.js
+++ b/dom/ipc/tests/test_bug1086684.js
@@ -1,10 +1,9 @@
 "use strict";
-/* eslint-env mozilla/frame-script */
 
 const { XPCShellContentUtils } = ChromeUtils.import(
   "resource://testing-common/XPCShellContentUtils.jsm"
 );
 
 XPCShellContentUtils.init(this);
 
 const childFramePath = "/file_bug1086684.html";
@@ -25,16 +24,17 @@ const childFrameContents = `<!DOCTYPE ht
 const server = XPCShellContentUtils.createHttpServer({
   hosts: ["example.com"],
 });
 server.registerPathHandler(childFramePath, (request, response) => {
   response.write(childFrameContents);
 });
 
 function childFrameScript() {
+  /* eslint-env mozilla/frame-script */
   "use strict";
 
   let { MockFilePicker } = ChromeUtils.import(
     "resource://testing-common/MockFilePicker.jsm"
   );
 
   function parentReady(message) {
     MockFilePicker.init(content);
--- a/dom/ipc/tests/test_child_docshell.js
+++ b/dom/ipc/tests/test_child_docshell.js
@@ -1,10 +1,9 @@
 "use strict";
-/* eslint-env mozilla/frame-script */
 
 const { XPCShellContentUtils } = ChromeUtils.import(
   "resource://testing-common/XPCShellContentUtils.jsm"
 );
 
 XPCShellContentUtils.init(this);
 
 add_task(async function test() {
@@ -39,16 +38,17 @@ add_task(async function test() {
         result.iframeHasSameChromeEventHandler,
         "but iframe has the same chrome event handler"
       );
       resolve();
     });
 
     // Inject a frame script in the child process:
     page.loadFrameScript(async function() {
+      /* eslint-env mozilla/frame-script */
       var chromeEventHandler = docShell.chromeEventHandler;
       sendAsyncMessage("chromeEventHandler", {
         processType: Services.appinfo.processType,
         hasCorrectInterface:
           chromeEventHandler && EventTarget.isInstance(chromeEventHandler),
       });
 
       /*
--- a/dom/security/test/mixedcontentblocker/file_main_bug803225.html
+++ b/dom/security/test/mixedcontentblocker/file_main_bug803225.html
@@ -108,16 +108,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     Services.ppmm.addMessageListener("Test:content-ready", function contentReadyListener() {
       Services.ppmm.removeMessageListener("Test:content-ready", contentReadyListener);
       sendAsyncMessage("Test:content-ready-forward");
       Services.ppmm.removeDelayedProcessScript(pScript);
     })
 
     var pScript = "data:,new " + function () {
+      /* eslint-env mozilla/process-script */
       var os = Cc["@mozilla.org/observer-service;1"]
         .getService(Ci.nsIObserverService);
       var observer = {
         observe(subject, topic, data) {
         if (topic == "content-document-global-created" && data == "http://example.com") {
            sendAsyncMessage("Test:content-ready");
            os.removeObserver(observer, "content-document-global-created");
         }
--- a/netwerk/test/browser/browser_nsIFormPOSTActionChannel.js
+++ b/netwerk/test/browser/browser_nsIFormPOSTActionChannel.js
@@ -1,15 +1,13 @@
 /*
  * Tests for bug 1241377: A channel with nsIFormPOSTActionChannel interface
  * should be able to accept form POST.
  */
 
-/* eslint-env mozilla/frame-script */
-
 "use strict";
 
 const SCHEME = "x-bug1241377";
 
 const FORM_BASE = SCHEME + "://dummy/form/";
 const NORMAL_FORM_URI = FORM_BASE + "normal.html";
 const UPLOAD_FORM_URI = FORM_BASE + "upload.html";
 const POST_FORM_URI = FORM_BASE + "post.html";
@@ -193,16 +191,17 @@ document.getElementById('form').submit()
   loadGroup: null,
   loadFlags:
     Ci.nsIRequest.LOAD_NORMAL |
     Ci.nsIRequest.INHIBIT_CACHING |
     Ci.nsIRequest.LOAD_BYPASS_CACHE,
 };
 
 function frameScript() {
+  /* eslint-env mozilla/frame-script */
   addMessageListener("Test:WaitForIFrame", function() {
     var check = function() {
       if (content) {
         var frame = content.document.getElementById("frame");
         if (frame) {
           var upload_stream = frame.contentDocument.getElementById(
             "upload_stream"
           );
--- a/testing/mochitest/BrowserTestUtils/content/content-about-page-utils.js
+++ b/testing/mochitest/BrowserTestUtils/content/content-about-page-utils.js
@@ -1,9 +1,9 @@
-/* eslint-env mozilla/frame-script */
+/* eslint-env mozilla/process-script */
 
 "use strict";
 
 var Cm = Components.manager;
 
 function AboutPage(aboutHost, chromeURL, uriFlags) {
   this.chromeURL = chromeURL;
   this.aboutHost = aboutHost;
--- a/testing/talos/talos/tests/tabswitch/content/tabswitch-content-process.js
+++ b/testing/talos/talos/tests/tabswitch/content/tabswitch-content-process.js
@@ -1,8 +1,10 @@
+/* eslint-env mozilla/process-script */
+
 const { ComponentUtils } = ChromeUtils.import(
   "resource://gre/modules/ComponentUtils.jsm"
 );
 
 const WEBEXTENSION_ID = "tabswitch-talos@mozilla.org";
 const ABOUT_PAGE_NAME = "tabswitch";
 const Registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
 const UUID = "0f459ab4-b4ba-4741-ac89-ee47dea07adb";
--- a/toolkit/components/extensions/extensionProcessScriptLoader.js
+++ b/toolkit/components/extensions/extensionProcessScriptLoader.js
@@ -1,6 +1,9 @@
 /* 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/. */
+
+/* eslint-env mozilla/process-script */
+
 "use strict";
 
 ChromeUtils.import("resource://gre/modules/ExtensionProcessScript.jsm");
--- a/toolkit/content/process-content.js
+++ b/toolkit/content/process-content.js
@@ -1,11 +1,14 @@
 /* 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/. */
+
+/* eslint-env mozilla/process-script */
+
 "use strict";
 
 // Creates a new PageListener for this process. This will listen for page loads
 // and for those that match URLs provided by the parent process will set up
 // a dedicated message port and notify the parent process.
 
 Services.cpmm.addMessageListener("gmp-plugin-crash", ({ data }) => {
   Cc["@mozilla.org/gecko-media-plugin-service;1"]
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js
@@ -1,10 +1,10 @@
 /**
- * @fileoverview Defines the environment for frame scripts.
+ * @fileoverview Defines the environment for frame scripts and process script.
  *
  * 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";
 
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js
@@ -19,16 +19,17 @@ module.exports = {
     recommended: require("../lib/configs/recommended"),
     "xpcshell-test": require("../lib/configs/xpcshell-test"),
   },
   environments: {
     "browser-window": require("../lib/environments/browser-window.js"),
     "chrome-worker": require("../lib/environments/chrome-worker.js"),
     "frame-script": require("../lib/environments/frame-script.js"),
     jsm: require("../lib/environments/jsm.js"),
+    "process-script": require("../lib/environments/frame-script.js"),
     simpletest: require("../lib/environments/simpletest.js"),
     sjs: require("../lib/environments/sjs.js"),
     privileged: require("../lib/environments/privileged.js"),
     xpcshell: require("../lib/environments/xpcshell.js"),
   },
   rules: {
     "avoid-Date-timing": require("../lib/rules/avoid-Date-timing"),
     "avoid-removeChild": require("../lib/rules/avoid-removeChild"),