summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/modules
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/aboutdebugging/modules
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/aboutdebugging/modules')
-rw-r--r--devtools/client/aboutdebugging/modules/addon.js23
-rw-r--r--devtools/client/aboutdebugging/modules/moz.build8
-rw-r--r--devtools/client/aboutdebugging/modules/worker.js77
3 files changed, 108 insertions, 0 deletions
diff --git a/devtools/client/aboutdebugging/modules/addon.js b/devtools/client/aboutdebugging/modules/addon.js
new file mode 100644
index 000000000..d800462b9
--- /dev/null
+++ b/devtools/client/aboutdebugging/modules/addon.js
@@ -0,0 +1,23 @@
+/* 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";
+
+loader.lazyImporter(this, "BrowserToolboxProcess",
+ "resource://devtools/client/framework/ToolboxProcess.jsm");
+
+let toolbox = null;
+
+exports.debugAddon = function (addonID) {
+ if (toolbox) {
+ toolbox.close();
+ }
+
+ toolbox = BrowserToolboxProcess.init({
+ addonID,
+ onClose: () => {
+ toolbox = null;
+ }
+ });
+};
diff --git a/devtools/client/aboutdebugging/modules/moz.build b/devtools/client/aboutdebugging/modules/moz.build
new file mode 100644
index 000000000..de840f957
--- /dev/null
+++ b/devtools/client/aboutdebugging/modules/moz.build
@@ -0,0 +1,8 @@
+# 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(
+ 'addon.js',
+ 'worker.js',
+)
diff --git a/devtools/client/aboutdebugging/modules/worker.js b/devtools/client/aboutdebugging/modules/worker.js
new file mode 100644
index 000000000..1623088c6
--- /dev/null
+++ b/devtools/client/aboutdebugging/modules/worker.js
@@ -0,0 +1,77 @@
+/* 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 { Task } = require("devtools/shared/task");
+
+loader.lazyRequireGetter(this, "gDevTools",
+ "devtools/client/framework/devtools", true);
+loader.lazyRequireGetter(this, "TargetFactory",
+ "devtools/client/framework/target", true);
+loader.lazyRequireGetter(this, "Toolbox",
+ "devtools/client/framework/toolbox", true);
+
+/**
+ * Open a window-hosted toolbox to debug the worker associated to the provided
+ * worker actor.
+ *
+ * @param {DebuggerClient} client
+ * @param {Object} workerActor
+ * worker actor form to debug
+ */
+exports.debugWorker = function (client, workerActor) {
+ client.attachWorker(workerActor, (response, workerClient) => {
+ let workerTarget = TargetFactory.forWorker(workerClient);
+ gDevTools.showToolbox(workerTarget, "jsdebugger", Toolbox.HostType.WINDOW)
+ .then(toolbox => {
+ toolbox.once("destroy", () => workerClient.detach());
+ });
+ });
+};
+
+/**
+ * Retrieve all service worker registrations as well as workers from the parent
+ * and child processes.
+ *
+ * @param {DebuggerClient} client
+ * @return {Object}
+ * - {Array} registrations
+ * Array of ServiceWorkerRegistrationActor forms
+ * - {Array} workers
+ * Array of WorkerActor forms
+ */
+exports.getWorkerForms = Task.async(function* (client) {
+ let registrations = [];
+ let workers = [];
+
+ try {
+ // List service worker registrations
+ ({ registrations } =
+ yield client.mainRoot.listServiceWorkerRegistrations());
+
+ // List workers from the Parent process
+ ({ workers } = yield client.mainRoot.listWorkers());
+
+ // And then from the Child processes
+ let { processes } = yield client.mainRoot.listProcesses();
+ for (let process of processes) {
+ // Ignore parent process
+ if (process.parent) {
+ continue;
+ }
+ let { form } = yield client.getProcess(process.id);
+ let processActor = form.actor;
+ let response = yield client.request({
+ to: processActor,
+ type: "listWorkers"
+ });
+ workers = workers.concat(response.workers);
+ }
+ } catch (e) {
+ // Something went wrong, maybe our client is disconnected?
+ }
+
+ return { registrations, workers };
+});