Backed out 2 changesets (bug 1625942) for causing devtools failures at devtools/client/netmonitor/test/browser_net_reload-markers.js
authorDaniel Varga <dvarga@mozilla.com>
Fri, 17 Apr 2020 13:39:11 +0300
changeset 524575 84a01c8388d5b4a5cd11f29e2107469f2decb6c8
parent 524574 d64c9eb2f326524738c7889c1bc953455b6921a5
child 524576 6daca7282599cf1c8618e4cf1debfb583f58f4b2
push id37323
push userdluca@mozilla.com
push dateFri, 17 Apr 2020 16:25:55 +0000
treeherdermozilla-central@b4b1d6f91ef0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1625942
milestone77.0a1
backs out4255bd054e34fcaf2a5e5d2c9b1dba9f2fe4e2d8
743e1ce65e061403c0fca63f0b76301c08b480a4
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 2 changesets (bug 1625942) for causing devtools failures at devtools/client/netmonitor/test/browser_net_reload-markers.js CLOSED TREE Backed out changeset 4255bd054e34 (bug 1625942) Backed out changeset 743e1ce65e06 (bug 1625942)
devtools/client/netmonitor/src/connector/firefox-connector.js
devtools/server/actors/webconsole/listeners/document-events.js
devtools/shared/resources/resource-watcher.js
devtools/shared/resources/tests/browser.ini
devtools/shared/resources/tests/browser_resources_document_events.js
--- a/devtools/client/netmonitor/src/connector/firefox-connector.js
+++ b/devtools/client/netmonitor/src/connector/firefox-connector.js
@@ -28,30 +28,30 @@ loader.lazyRequireGetter(
 class FirefoxConnector {
   constructor() {
     // Public methods
     this.connect = this.connect.bind(this);
     this.disconnect = this.disconnect.bind(this);
     this.willNavigate = this.willNavigate.bind(this);
     this.navigate = this.navigate.bind(this);
     this.displayCachedEvents = this.displayCachedEvents.bind(this);
+    this.onDocEvent = this.onDocEvent.bind(this);
     this.sendHTTPRequest = this.sendHTTPRequest.bind(this);
     this.setPreferences = this.setPreferences.bind(this);
     this.triggerActivity = this.triggerActivity.bind(this);
     this.getTabTarget = this.getTabTarget.bind(this);
     this.viewSourceInDebugger = this.viewSourceInDebugger.bind(this);
     this.requestData = this.requestData.bind(this);
     this.getTimingMarker = this.getTimingMarker.bind(this);
     this.updateNetworkThrottling = this.updateNetworkThrottling.bind(this);
 
     // Internals
     this.getLongString = this.getLongString.bind(this);
     this.getNetworkRequest = this.getNetworkRequest.bind(this);
     this.onTargetAvailable = this.onTargetAvailable.bind(this);
-    this.onResourceAvailable = this.onResourceAvailable.bind(this);
   }
 
   get currentTarget() {
     return this.toolbox.targetList.targetFront;
   }
 
   /**
    * Connect to the backend.
@@ -67,41 +67,31 @@ class FirefoxConnector {
 
     // The owner object (NetMonitorAPI) received all events.
     this.owner = connection.owner;
 
     await this.toolbox.targetList.watchTargets(
       [this.toolbox.targetList.TYPES.FRAME],
       this.onTargetAvailable
     );
-
-    await this.toolbox.resourceWatcher.watch(
-      [this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENTS],
-      this.onResourceAvailable
-    );
   }
 
   disconnect() {
     // As this function might be called twice, we need to guard if already called.
     if (this._destroyed) {
       return;
     }
 
     this._destroyed = true;
 
     this.toolbox.targetList.unwatchTargets(
       [this.toolbox.targetList.TYPES.FRAME],
       this.onTargetAvailable
     );
 
-    this.toolbox.resourceWatcher.unwatch(
-      [this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENTS],
-      this.onResourceAvailable
-    );
-
     if (this.actions) {
       this.actions.batchReset();
     }
 
     this.removeListeners();
 
     this.currentTarget.off("will-navigate", this.willNavigate);
     this.currentTarget.off("navigate", this.navigate);
@@ -150,28 +140,23 @@ class FirefoxConnector {
     this.responsiveFront = await this.currentTarget.getFront("responsive");
 
     // Displaying cache events is only intended for the UI panel.
     if (this.actions) {
       this.displayCachedEvents();
     }
   }
 
-  async onResourceAvailable({ resourceType, targetFront, resource }) {
-    if (resourceType === this.toolbox.resourceWatcher.TYPES.DOCUMENT_EVENTS) {
-      this.onDocEvent(resource);
-    }
-  }
-
   async addListeners() {
     this.webConsoleFront.on("networkEvent", this.dataProvider.onNetworkEvent);
     this.webConsoleFront.on(
       "networkEventUpdate",
       this.dataProvider.onNetworkEventUpdate
     );
+    this.webConsoleFront.on("documentEvent", this.onDocEvent);
 
     // Support for WebSocket monitoring is currently hidden behind this pref.
     if (Services.prefs.getBoolPref("devtools.netmonitor.features.webSockets")) {
       try {
         // Initialize WebSocket front to intercept websocket traffic.
         const webSocketFront = await this.currentTarget.getFront("webSocket");
         webSocketFront.startListening();
 
@@ -184,16 +169,20 @@ class FirefoxConnector {
           this.dataProvider.onWebSocketClosed
         );
         webSocketFront.on("frameReceived", this.dataProvider.onFrameReceived);
         webSocketFront.on("frameSent", this.dataProvider.onFrameSent);
       } catch (e) {
         // Support for FF68 or older
       }
     }
+
+    // The console actor supports listening to document events like
+    // DOMContentLoaded and load.
+    await this.webConsoleFront.startListeners(["DocumentEvents"]);
   }
 
   removeListeners() {
     const webSocketFront = this.currentTarget.getCachedFront("webSocket");
     if (webSocketFront) {
       webSocketFront.off(
         "webSocketOpened",
         this.dataProvider.onWebSocketOpened
@@ -210,16 +199,17 @@ class FirefoxConnector {
       this.webConsoleFront.off(
         "networkEvent",
         this.dataProvider.onNetworkEvent
       );
       this.webConsoleFront.off(
         "networkEventUpdate",
         this.dataProvider.onNetworkEventUpdate
       );
+      this.webConsoleFront.off("docEvent", this.onDocEvent);
     }
   }
 
   enableActions(enable) {
     this.dataProvider.enableActions(enable);
   }
 
   willNavigate() {
--- a/devtools/server/actors/webconsole/listeners/document-events.js
+++ b/devtools/server/actors/webconsole/listeners/document-events.js
@@ -41,24 +41,16 @@ DocumentEventsListener.prototype = {
       return;
     }
 
     // Ignore iframes
     if (!isTopLevel) {
       return;
     }
 
-    const packet = {
-      from: this.console.actorID,
-      type: "documentEvent",
-      name: "dom-loading",
-      time: window.performance.timing.navigationStart,
-    };
-    this.console.conn.send(packet);
-
     const { readyState } = window.document;
     if (readyState != "interactive" && readyState != "complete") {
       window.addEventListener("DOMContentLoaded", this.onContentLoaded, {
         once: true,
       });
     } else {
       this.onContentLoaded({ target: window.document });
     }
--- a/devtools/shared/resources/resource-watcher.js
+++ b/devtools/shared/resources/resource-watcher.js
@@ -296,17 +296,16 @@ class ResourceWatcher {
     // We are aware of one case where that might be useful.
     // When a panel is disabled via the options panel, after it has been opened.
     // Would that justify doing this? Is there another usecase?
   }
 }
 
 ResourceWatcher.TYPES = ResourceWatcher.prototype.TYPES = {
   CONSOLE_MESSAGES: "console-messages",
-  DOCUMENT_EVENTS: "document-events",
 };
 module.exports = { ResourceWatcher };
 
 // Backward compat code for each type of resource.
 // Each section added here should eventually be removed once the equivalent server
 // code is implement in Firefox, in its release channel.
 const LegacyListeners = {
   // Bug 1620243 aims at implementing this from the actor and will eventually replace
@@ -347,25 +346,9 @@ const LegacyListeners = {
       "ConsoleAPI",
     ]);
     // Wrap the message into a `message` attribute, to match `consoleAPICall` behavior
     messages.map(message => ({ message })).forEach(onAvailable);
 
     // Forward new message events
     webConsoleFront.on("consoleAPICall", onAvailable);
   },
-  async [ResourceWatcher.TYPES.DOCUMENT_EVENTS]({
-    targetList,
-    targetType,
-    targetFront,
-    isTopLevel,
-    onAvailable,
-  }) {
-    // DocumentEventsListener of webconsole handles only top level document.
-    if (!isTopLevel) {
-      return;
-    }
-
-    const webConsoleFront = await targetFront.getFront("console");
-    webConsoleFront.on("documentEvent", onAvailable);
-    await webConsoleFront.startListeners(["DocumentEvents"]);
-  },
 };
--- a/devtools/shared/resources/tests/browser.ini
+++ b/devtools/shared/resources/tests/browser.ini
@@ -7,15 +7,14 @@ support-files =
   !/devtools/client/shared/test/test-actor.js
   head.js
   fission_document.html
   fission_iframe.html
   test_service_worker.js
   test_worker.js
 
 [browser_resources_console_messages.js]
-[browser_resources_document_events.js]
 [browser_target_list_frames.js]
 [browser_target_list_preffedoff.js]
 [browser_target_list_processes.js]
 [browser_target_list_switchToTarget.js]
 [browser_target_list_watchTargets.js]
 [browser_target_list_workers.js]
deleted file mode 100644
--- a/devtools/shared/resources/tests/browser_resources_document_events.js
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-// Test the ResourceWatcher API around DOCUMENT_EVENTS
-
-const { TargetList } = require("devtools/shared/resources/target-list");
-const {
-  ResourceWatcher,
-} = require("devtools/shared/resources/resource-watcher");
-
-add_task(async function() {
-  // Open a test tab
-  const tab = await addTab("data:text/html,Document Events");
-
-  // Create a TargetList for the test tab
-  const client = await createLocalClient();
-  const target = await client.mainRoot.getTab({ tab });
-  const targetList = new TargetList(client.mainRoot, target);
-  await targetList.startListening();
-
-  // Activate ResourceWatcher
-  const listener = new ResourceListener();
-  const resourceWatcher = new ResourceWatcher(targetList);
-
-  info(
-    "Check whether the document events are fired correctly even when the document was already loaded"
-  );
-  const onLoadingAtInit = listener.once("dom-loading");
-  const onInteractiveAtInit = listener.once("dom-interactive");
-  const onCompleteAtInit = listener.once("dom-complete");
-  await resourceWatcher.watch(
-    [ResourceWatcher.TYPES.DOCUMENT_EVENTS],
-    parameters => listener.dispatch(parameters)
-  );
-  await assertEvents(onLoadingAtInit, onInteractiveAtInit, onCompleteAtInit);
-  ok(
-    true,
-    "Document events are fired even when the document was already loaded"
-  );
-
-  info("Check whether the document events are fired correctly when reloading");
-  const onLoadingAtReloaded = listener.once("dom-loading");
-  const onInteractiveAtReloaded = listener.once("dom-interactive");
-  const onCompleteAtReloaded = listener.once("dom-complete");
-  gBrowser.reloadTab(tab);
-  await assertEvents(
-    onLoadingAtReloaded,
-    onInteractiveAtReloaded,
-    onCompleteAtReloaded
-  );
-  ok(true, "Document events are fired after reloading");
-
-  await targetList.stopListening();
-  await client.close();
-});
-
-async function assertEvents(onLoading, onInteractive, onComplete) {
-  const loadingEvent = await onLoading;
-  const interactiveEvent = await onInteractive;
-  const completeEvent = await onComplete;
-  is(
-    typeof loadingEvent.time,
-    "number",
-    "Type of time attribute for loading event is correct"
-  );
-  is(
-    typeof interactiveEvent.time,
-    "number",
-    "Type of time attribute for interactive event is correct"
-  );
-  is(
-    typeof completeEvent.time,
-    "number",
-    "Type of time attribute for complete event is correct"
-  );
-
-  ok(
-    loadingEvent.time < interactiveEvent.time,
-    "Timestamp for interactive event is greater than loading event"
-  );
-  ok(
-    interactiveEvent.time < completeEvent.time,
-    "Timestamp for complete event is greater than interactive event"
-  );
-}
-
-class ResourceListener {
-  _listeners = new Map();
-
-  dispatch({ resourceType, targetFront, resource }) {
-    const resolve = this._listeners.get(resource.name);
-    if (resolve) {
-      resolve(resource);
-      this._listeners.delete(resource.name);
-    }
-  }
-
-  once(resourceName) {
-    return new Promise(r => this._listeners.set(resourceName, r));
-  }
-}