Bug 1268073 - Misleading error if you click "Debug" twice; r?janx
MozReview-Commit-ID: DVW2ahqAO2Q
--- a/devtools/client/aboutdebugging/components/addons/target.js
+++ b/devtools/client/aboutdebugging/components/addons/target.js
@@ -1,33 +1,30 @@
/* 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 browser */
-/* globals BrowserToolboxProcess */
"use strict";
-loader.lazyImporter(this, "BrowserToolboxProcess",
- "resource://devtools/client/framework/ToolboxProcess.jsm");
-
const { createClass, DOM: dom } =
require("devtools/client/shared/vendor/react");
+const { debugAddon } = require("../../modules/addon");
const Services = require("Services");
const Strings = Services.strings.createBundle(
"chrome://devtools/locale/aboutdebugging.properties");
module.exports = createClass({
displayName: "AddonTarget",
debug() {
let { target } = this.props;
- BrowserToolboxProcess.init({ addonID: target.addonID });
+ debugAddon(target.addonID);
},
reload() {
let { client, target } = this.props;
// This function sometimes returns a partial promise that only
// implements then().
client.request({
to: target.addonActor,
new file mode 100644
--- /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;
+ }
+ });
+};
--- a/devtools/client/aboutdebugging/modules/moz.build
+++ b/devtools/client/aboutdebugging/modules/moz.build
@@ -1,7 +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',
)