Bug 1499357 - Move inline script out of new aboutdebugging index.html;r=ladybenko
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 18 Oct 2018 16:10:35 +0000
changeset 490378 35b493a84e94f453975520a95b85145344d2fe70
parent 490377 d12de5ab68a2371f00fd20575f225ffeed8e41a0
child 490379 9ae0b64741cbf08fcd0ee6b031befd93fa10d184
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersladybenko
bugs1499357
milestone64.0a1
Bug 1499357 - Move inline script out of new aboutdebugging index.html;r=ladybenko This preparatory work will be necessary to enable CSP for the new about debugging. Differential Revision: https://phabricator.services.mozilla.com/D8854
devtools/client/aboutdebugging-new/index.html
devtools/client/aboutdebugging-new/initializer.js
devtools/client/aboutdebugging-new/moz.build
--- a/devtools/client/aboutdebugging-new/index.html
+++ b/devtools/client/aboutdebugging-new/index.html
@@ -2,24 +2,14 @@
    - 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/. -->
 <!DOCTYPE html>
 <html>
   <head>
     <meta charset="utf-8" />
     <link rel="stylesheet" href="chrome://global/skin/in-content/common.css" type="text/css"/>
     <link rel="stylesheet" href="chrome://devtools/content/aboutdebugging-new/aboutdebugging.css"/>
-    <script>
-    "use strict";
-
-    const { BrowserLoader } =
-      ChromeUtils.import("resource://devtools/client/shared/browser-loader.js", {});
-    const { require } = BrowserLoader({
-      baseURI: "resource://devtools/client/aboutdebugging-new/",
-      window,
-    });
-    require("./aboutdebugging");
-    </script>
+    <script type="application/javascript" src="resource://devtools/client/aboutdebugging-new/initializer.js"></script>
   </head>
   <body>
     <div id="mount"></div>
   </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/initializer.js
@@ -0,0 +1,22 @@
+/* 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 { BrowserLoader } =
+  ChromeUtils.import("resource://devtools/client/shared/browser-loader.js", {});
+const { require } = BrowserLoader({
+  baseURI: "resource://devtools/client/aboutdebugging-new/",
+  window,
+});
+
+// The only purpose of this module is to load the real aboutdebugging module via the
+// BrowserLoader.
+// This cannot be done using an inline script tag in index.html because we are applying
+// CSP for about: pages in Bug 1492063.
+// And this module cannot be merged with aboutdebugging.js because modules loaded with
+// script tags are using Promises bound to the lifecycle of the document, while modules
+// loaded with a devtools loader use Promises that will still resolve if the document is
+// destroyed. This is particularly useful to ensure asynchronous destroy() calls succeed.
+require("./aboutdebugging");
--- a/devtools/client/aboutdebugging-new/moz.build
+++ b/devtools/client/aboutdebugging-new/moz.build
@@ -1,14 +1,15 @@
 # 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/.
 
 DevToolsModules(
     'aboutdebugging.js',
+    'initializer.js',
 )
 
 DIRS += [
     'src',
 ]
 
 XPCSHELL_TESTS_MANIFESTS += [
     'test/unit/xpcshell.ini'