Bug 1471795 - Part 17: Update worker list ui when the actual tabs were changed. r?jdescottes
MozReview-Commit-ID: EksBI4CDHZP
--- a/devtools/client/aboutdebugging-new/src/components/DebugTargetsPane.js
+++ b/devtools/client/aboutdebugging-new/src/components/DebugTargetsPane.js
@@ -26,16 +26,17 @@ class DebugTargetsPane extends PureCompo
};
}
constructor(props) {
super(props);
this.onExtensionsUpdated = this.onExtensionsUpdated.bind(this);
this.onTabsUpdated = this.onTabsUpdated.bind(this);
+ this.onWorkersUpdated = this.onWorkersUpdated.bind(this);
this.state = {
info: {},
installedExtensions: [],
otherWorkers: [],
tabs: [],
temporaryExtensions: [],
serviceWorkers: [],
@@ -44,34 +45,37 @@ class DebugTargetsPane extends PureCompo
this.update(props.runtime);
}
componentDidUpdate(prevProps) {
if (prevProps.runtime !== this.props.runtime) {
const { runtime } = prevProps;
runtime.removeExtensionsUpdateListener(this.onExtensionsUpdated);
runtime.removeTabsUpdateListener(this.onTabsUpdated);
+ runtime.removeWorkersUpdateListener(this.onWorkersUpdated);
this.update(this.props.runtime);
}
}
componentWillUnmount() {
const { runtime } = this.props;
runtime.removeExtensionsUpdateListener(this.onExtensionsUpdated);
runtime.removeTabsUpdateListener(this.onTabsUpdated);
+ runtime.removeWorkersUpdateListener(this.onWorkersUpdated);
}
update(runtime) {
this.updateRuntimeInfo(runtime);
this.updateTabs(runtime);
this.updateExtensions(runtime);
this.updateWorkers(runtime);
runtime.addExtensionsUpdateListener(this.onExtensionsUpdated);
runtime.addTabsUpdateListener(this.onTabsUpdated);
+ runtime.addWorkersUpdateListener(this.onWorkersUpdated);
}
async updateExtensions(runtime) {
const extensions = (await runtime.getExtensions()).filter(t => t.debuggable);
const installedExtensions = extensions.filter(t => !t.temporarilyInstalled);
const temporaryExtensions = extensions.filter(t => t.temporarilyInstalled);
this.setState({ installedExtensions, temporaryExtensions });
}
@@ -99,16 +103,20 @@ class DebugTargetsPane extends PureCompo
onExtensionsUpdated() {
this.updateExtensions(this.props.runtime);
}
onTabsUpdated() {
this.updateTabs(this.props.runtime);
}
+ onWorkersUpdated() {
+ this.updateWorkers(this.props.runtime);
+ }
+
render() {
const { runtime } = this.props;
const {
info,
installedExtensions,
otherWorkers,
tabs,
temporaryExtensions,
--- a/devtools/client/aboutdebugging-new/src/runtimes/runtime.js
+++ b/devtools/client/aboutdebugging-new/src/runtimes/runtime.js
@@ -22,16 +22,25 @@ class Runtime {
* Subclass should override this method.
* @param {function}
*/
addTabsUpdateListener(listener) {
throw new Error("Subclass of Runtime should override addTabsUpdateListener()");
}
/**
+ * Add a worker update listener to detect workers change.
+ * Subclass should override this method.
+ * @param {function}
+ */
+ addWorkersUpdateListener(listener) {
+ throw new Error("Subclass of Runtime should override addWorkersUpdateListener()");
+ }
+
+ /**
* Connect to this runtime.
* Subclass should override this method.
*/
async connect() {
throw new Error("Subclass of Runtime should override connect()");
}
/**
@@ -153,16 +162,25 @@ class Runtime {
* Subclass should override this method.
* @param {function}
*/
removeTabsUpdateListener(listener) {
throw new Error("Subclass of Runtime should override removeTabsUpdateListener()");
}
/**
+ * Remove a worker update listener.
+ * Subclass should override this method.
+ * @param {function}
+ */
+ removeWorkersUpdateListener(listener) {
+ throw new Error("Subclass of Runtime should override removeWorkersUpdateListener()");
+ }
+
+ /**
* Send given request to this runtime.
* Subclass should override this method.
* @return {Object}
*/
async sendRequest(params) {
throw new Error("Subclass of Runtime should override sendRequest()");
}
}
--- a/devtools/client/aboutdebugging-new/src/runtimes/this-firefox.js
+++ b/devtools/client/aboutdebugging-new/src/runtimes/this-firefox.js
@@ -29,16 +29,24 @@ class ThisFirefox extends Runtime {
addExtensionsUpdateListener(listener) {
this.extensionsListeners.push(listener);
}
addTabsUpdateListener(listener) {
this.client.addListener("tabListChanged", listener);
}
+ addWorkersUpdateListener(listener) {
+ this.client.addListener("workerListChanged", listener);
+ this.client.addListener("serviceWorkerRegistrationListChanged", listener);
+ this.client.addListener("processListChanged", listener);
+ this.client.addListener("registration-changed", listener);
+ this.client.addListener("push-subscription-modified", listener);
+ }
+
async connect() {
// Setup a server if we don't have one already running
DebuggerServer.init();
DebuggerServer.registerAllActors();
const transport = DebuggerServer.connectPipe();
this.client = new DebuggerClient(transport);
return this.client.connect();
}
@@ -141,16 +149,24 @@ class ThisFirefox extends Runtime {
this.extensionsListeners.splice(index, 1);
}
}
removeTabsUpdateListener(listener) {
this.client.removeListener("tabListChanged", listener);
}
+ removeWorkersUpdateListener(listener) {
+ this.client.removeListener("workerListChanged", listener);
+ this.client.removeListener("serviceWorkerRegistrationListChanged", listener);
+ this.client.removeListener("processListChanged", listener);
+ this.client.removeListener("registration-changed", listener);
+ this.client.removeListener("push-subscription-modified", listener);
+ }
+
async sendRequest(params) {
return this.client.request(params);
}
onExtensionsUpdated() {
for (const listener of this.extensionsListeners) {
listener();
}