Bug 1449931 - Remove old-event-emitter usage from devtools/shared/webconsole; r=bgrins.
MozReview-Commit-ID: HkbUm0XkeJs
--- a/devtools/client/framework/target.js
+++ b/devtools/client/framework/target.js
@@ -452,17 +452,17 @@ TabTarget.prototype = {
let onConsoleAttached = (response, consoleClient) => {
if (!consoleClient) {
this._remote.reject("Unable to attach to the console");
return;
}
this.activeConsole = consoleClient;
- this._onInspectObject = (event, packet) => this.emit("inspect-object", packet);
+ this._onInspectObject = packet => this.emit("inspect-object", packet);
this.activeConsole.on("inspectObject", this._onInspectObject);
this._remote.resolve(null);
};
let attachConsole = () => {
this._client.attachConsole(this._form.consoleActor, [], onConsoleAttached);
};
--- a/devtools/client/netmonitor/src/connector/firefox-connector.js
+++ b/devtools/client/netmonitor/src/connector/firefox-connector.js
@@ -173,20 +173,20 @@ class FirefoxConnector {
}
/**
* Display any network events already in the cache.
*/
displayCachedEvents() {
for (let networkInfo of this.webConsoleClient.getNetworkEvents()) {
// First add the request to the timeline.
- this.dataProvider.onNetworkEvent("networkEvent", networkInfo);
+ this.dataProvider.onNetworkEvent(networkInfo);
// Then replay any updates already received.
for (let updateType of networkInfo.updates) {
- this.dataProvider.onNetworkEventUpdate("networkEventUpdate", {
+ this.dataProvider.onNetworkEventUpdate({
packet: { updateType },
networkInfo,
});
}
}
}
/**
@@ -210,17 +210,17 @@ class FirefoxConnector {
/**
* The "DOMContentLoaded" and "Load" events sent by the console actor.
*
* Only used by FF60+.
*
* @param {object} marker
*/
- onDocEvent(type, event) {
+ onDocEvent(event) {
this.actions.addTimingMarker(event);
window.emit(EVENTS.TIMELINE_EVENT, event);
}
/**
* Send a HTTP request data payload
*
* @param {object} data data payload would like to sent to backend
--- a/devtools/client/netmonitor/src/connector/firefox-data-provider.js
+++ b/devtools/client/netmonitor/src/connector/firefox-data-provider.js
@@ -283,20 +283,19 @@ class FirefoxDataProvider {
*/
getLongString(stringGrip) {
return this.webConsoleClient.getString(stringGrip);
}
/**
* The "networkEvent" message type handler.
*
- * @param {string} type message type
* @param {object} networkInfo network request information
*/
- async onNetworkEvent(type, networkInfo) {
+ async onNetworkEvent(networkInfo) {
let {
actor,
cause,
fromCache,
fromServiceWorker,
isXHR,
request: {
method,
@@ -316,21 +315,20 @@ class FirefoxDataProvider {
});
emit(EVENTS.NETWORK_EVENT, actor);
}
/**
* The "networkEventUpdate" message type handler.
*
- * @param {string} type message type
* @param {object} packet the message received from the server.
* @param {object} networkInfo the network request information.
*/
- onNetworkEventUpdate(type, data) {
+ onNetworkEventUpdate(data) {
let { packet, networkInfo } = data;
let { actor } = networkInfo;
let { updateType } = packet;
switch (updateType) {
case "securityInfo":
this.pushRequestToQueue(actor, { securityState: networkInfo.securityInfo });
break;
--- a/devtools/client/webconsole/new-console-output/store.js
+++ b/devtools/client/webconsole/new-console-output/store.js
@@ -211,19 +211,19 @@ function enableNetProvider(hud) {
// from the backend. It can happen (especially in test) that
// the message is opened before all network event updates are
// received. The rest of updates will be handled below, see:
// NETWORK_MESSAGE_UPDATE action handler.
if (type == MESSAGE_OPEN) {
let updates = getAllNetworkMessagesUpdateById(newState);
let message = updates[action.id];
if (message && !message.openedOnce && message.source == "network") {
- dataProvider.onNetworkEvent(null, message);
+ dataProvider.onNetworkEvent(message);
message.updates.forEach(updateType => {
- dataProvider.onNetworkEventUpdate(null, {
+ dataProvider.onNetworkEventUpdate({
packet: { updateType: updateType },
networkInfo: message,
});
});
}
}
// Process all incoming HTTP details packets. Note that
@@ -233,17 +233,17 @@ function enableNetProvider(hud) {
// Make sure to call `dataProvider.onNetworkEventUpdate`
// to fetch data from the backend.
if (type == NETWORK_MESSAGE_UPDATE) {
let actor = action.response.networkInfo.actor;
let open = getAllMessagesUiById(state).includes(actor);
if (open) {
let message = getMessage(state, actor);
message.updates.forEach(updateType => {
- dataProvider.onNetworkEventUpdate(null, {
+ dataProvider.onNetworkEventUpdate({
packet: { updateType },
networkInfo: message,
});
});
}
}
return newState;
--- a/devtools/client/webconsole/new-console-output/test/fixtures/stub-generators/head.js
+++ b/devtools/client/webconsole/new-console-output/test/fixtures/stub-generators/head.js
@@ -420,17 +420,17 @@ async function generateNetworkEventStubs
};
let toolbox = await openNewTabAndToolbox(TEST_URI, "webconsole");
let {ui} = toolbox.getCurrentPanel().hud;
for (let [key, {keys, code}] of networkEvent) {
let onNetwork = new Promise(resolve => {
let i = 0;
- toolbox.target.activeConsole.on("networkEvent", function onNetworkEvent(type, res) {
+ toolbox.target.activeConsole.on("networkEvent", function onNetworkEvent(res) {
stubs.packets.push(formatPacket(keys[i], res));
stubs.preparedMessages.push(formatNetworkEventStub(keys[i], res));
if (++i === keys.length) {
toolbox.target.activeConsole.off("networkEvent", onNetworkEvent);
resolve();
}
});
});
--- a/devtools/client/webconsole/webconsole-connection-proxy.js
+++ b/devtools/client/webconsole/webconsole-connection-proxy.js
@@ -349,42 +349,38 @@ WebConsoleConnectionProxy.prototype = {
this.webConsoleFrame.handleConsoleAPICall(packet.message);
}
},
/**
* The "networkEvent" message type handler. We redirect any message to
* the UI for displaying.
*
* @private
- * @param string type
- * Message type.
* @param object networkInfo
* The network request information.
*/
- _onNetworkEvent: function(type, networkInfo) {
+ _onNetworkEvent: function(networkInfo) {
if (!this.webConsoleFrame) {
return;
}
if (this.webConsoleFrame.NEW_CONSOLE_OUTPUT_ENABLED) {
this.dispatchMessageAdd(networkInfo);
} else {
this.webConsoleFrame.handleNetworkEvent(networkInfo);
}
},
/**
* The "networkEventUpdate" message type handler. We redirect any message to
* the UI for displaying.
*
* @private
- * @param string type
- * Message type.
* @param object response
* The update response received from the server.
*/
- _onNetworkEventUpdate: function(type, response) {
+ _onNetworkEventUpdate: function(response) {
if (!this.webConsoleFrame) {
return;
}
let { packet, networkInfo } = response;
if (this.webConsoleFrame.NEW_CONSOLE_OUTPUT_ENABLED) {
this.dispatchMessageUpdate(networkInfo, response);
} else {
this.webConsoleFrame.handleNetworkEventUpdate(networkInfo, packet);
--- a/devtools/shared/webconsole/client.js
+++ b/devtools/shared/webconsole/client.js
@@ -2,17 +2,17 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* 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 DevToolsUtils = require("devtools/shared/DevToolsUtils");
-const EventEmitter = require("devtools/shared/old-event-emitter");
+const EventEmitter = require("devtools/shared/event-emitter");
const LongStringClient = require("devtools/shared/client/long-string-client");
/**
* A WebConsoleClient is used as a front end for the WebConsoleActor that is
* created on the server, hiding implementation details.
*
* @param object debuggerClient
* The DebuggerClient instance we live for.