Bug 1566850 - Remove target.activeConsole usage in Netmonitor. r=Honza.

Differential Revision: https://phabricator.services.mozilla.com/D56689

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Chevobbe 2019-12-13 09:11:44 +00:00
parent 018643b9e6
commit 684b113226
4 changed files with 10 additions and 6 deletions

View File

@ -81,7 +81,8 @@ if (window.location.protocol === "chrome:" && url.search.length > 1) {
const target = await targetFromURL(url);
// Start the network event listening as it is done in the toolbox code
await target.activeConsole.startListeners(["NetworkActivity"]);
const consoleFront = await target.getFront("console");
await consoleFront.startListeners(["NetworkActivity"]);
// Create a fake toolbox object
const toolbox = {

View File

@ -58,7 +58,7 @@ class FirefoxConnector {
// The owner object (NetMonitorAPI) received all events.
this.owner = connection.owner;
this.webConsoleFront = this.tabTarget.activeConsole;
this.webConsoleFront = await this.tabTarget.getFront("console");
this.dataProvider = new FirefoxDataProvider({
webConsoleFront: this.webConsoleFront,

View File

@ -59,13 +59,13 @@ HarAutomation.prototype = {
// Automation
startMonitoring: function(client, callback) {
startMonitoring: async function(client, callback) {
if (!client) {
return;
}
this.debuggerClient = client;
this.webConsoleFront = this.toolbox.target.activeConsole;
this.webConsoleFront = await this.toolbox.target.getFront("console");
this.tabWatcher = new TabWatcher(this.toolbox, this);
this.tabWatcher.connect();

View File

@ -362,15 +362,18 @@ function initNetMonitor(url, enableCache) {
info(
"Cache disabled when the current and all future toolboxes are open."
);
const consoleFront = await target.getFront("console");
// Remove any requests generated by the reload while toggling the cache to
// avoid interfering with the test.
isnot(
[...target.activeConsole.getNetworkEvents()].length,
[...consoleFront.getNetworkEvents()].length,
0,
"Request to reconfigure the tab was recorded."
);
info("Clearing requests in the console client.");
target.activeConsole.clearNetworkRequests();
await consoleFront.clearNetworkRequests();
info("Clearing requests in the UI.");
store.dispatch(Actions.clearRequests());