Bug 1513565 - Convert the last manually instantiated fronts to target.getFront. r=yulia
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 18 Dec 2018 23:35:59 +0000
changeset 451302 835e98747541301ba1beb317a6ea3fcd7dd0b310
parent 451301 69c7978b620c3a89b068bcfef8cd69c5c5ada60d
child 451303 3d30fc6ff7c4c6b007b554ef8c185b6a81ef117e
push id110646
push userebalazs@mozilla.com
push dateWed, 19 Dec 2018 16:05:18 +0000
treeherdermozilla-inbound@1acd86ad823c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyulia
bugs1513565
milestone66.0a1
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
Bug 1513565 - Convert the last manually instantiated fronts to target.getFront. r=yulia Depends on D14279 Differential Revision: https://phabricator.services.mozilla.com/D14280
devtools/client/canvasdebugger/panel.js
devtools/client/canvasdebugger/test/call-watcher-front.js
devtools/client/canvasdebugger/test/head.js
devtools/client/framework/test/browser_target_support.js
devtools/client/webaudioeditor/panel.js
devtools/client/webaudioeditor/test/head.js
devtools/shared/fronts/reflow.js
testing/talos/talos/tests/devtools/addon/content/tests/server/protocol.js
--- a/devtools/client/canvasdebugger/panel.js
+++ b/devtools/client/canvasdebugger/panel.js
@@ -25,17 +25,17 @@ CanvasDebuggerPanel.prototype = {
    * Open is effectively an asynchronous constructor.
    *
    * @return object
    *         A promise that is resolved when the Canvas Debugger completes opening.
    */
   open: async function() {
     this.panelWin.gToolbox = this._toolbox;
     this.panelWin.gTarget = this.target;
-    this.panelWin.gFront = new CanvasFront(this.target.client, this.target.form);
+    this.panelWin.gFront = await this.target.getFront("canvas");
 
     await this.panelWin.startupCanvasDebugger();
 
     this.isReady = true;
     this.emit("ready");
     return this;
   },
 
--- a/devtools/client/canvasdebugger/test/call-watcher-front.js
+++ b/devtools/client/canvasdebugger/test/call-watcher-front.js
@@ -13,8 +13,9 @@ const protocol = require("devtools/share
  */
 class CallWatcherFront extends protocol.FrontClassWithSpec(callWatcherSpec) {
   constructor(client, { callWatcherActor }) {
     super(client, { actor: callWatcherActor });
     this.manage(this);
   }
 }
 exports.CallWatcherFront = CallWatcherFront;
+protocol.registerFront(CallWatcherFront);
--- a/devtools/client/canvasdebugger/test/head.js
+++ b/devtools/client/canvasdebugger/test/head.js
@@ -17,17 +17,16 @@ Services.scriptloader.loadSubScript(
   "chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/helpers/context.js",
   this);
 
 var { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
 
 var { DebuggerClient } = require("devtools/shared/client/debugger-client");
 var { DebuggerServer } = require("devtools/server/main");
 var { METHOD_FUNCTION } = require("devtools/shared/fronts/function-call");
-var { CallWatcherFront } = require("chrome://mochitests/content/browser/devtools/client/canvasdebugger/test/call-watcher-front");
 var { CanvasFront } = require("devtools/shared/fronts/canvas");
 var { Toolbox } = require("devtools/client/framework/toolbox");
 var { isWebGLSupported } = require("devtools/client/shared/webgl-utils");
 
 const EXAMPLE_URL = "http://example.com/browser/devtools/client/canvasdebugger/test/";
 const SET_TIMEOUT_URL = EXAMPLE_URL + "doc_settimeout.html";
 const NO_CANVAS_URL = EXAMPLE_URL + "doc_no-canvas.html";
 const RAF_NO_CANVAS_URL = EXAMPLE_URL + "doc_raf-no-canvas.html";
@@ -132,17 +131,20 @@ function initCallWatcherBackend(aUrl) {
       prefix: "callWatcher",
       constructor: "CallWatcherActor",
       type: { target: true },
     });
 
     const target = await TargetFactory.forTab(tab);
     await target.attach();
 
-    const front = new CallWatcherFront(target.client, target.form);
+    // Load the Front module in order to register it and have getFront to find it.
+    require("chrome://mochitests/content/browser/devtools/client/canvasdebugger/test/call-watcher-front.js");
+
+    const front = await target.getFront("call-watcher");
     return { target, front };
   })();
 }
 
 function initCanvasDebuggerBackend(aUrl) {
   info("Initializing a canvas debugger front.");
   initServer();
 
--- a/devtools/client/framework/test/browser_target_support.js
+++ b/devtools/client/framework/test/browser_target_support.js
@@ -1,27 +1,24 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test support methods on Target, such as `hasActor`, `getActorDescription`,
 // `actorHasMethod` and `getTrait`.
 
-var { WebAudioFront } =
-  require("devtools/shared/fronts/webaudio");
-
 async function testTarget(client, target) {
   await target.attach();
 
   is(target.hasActor("inspector"), true, "target.hasActor() true when actor exists.");
   is(target.hasActor("webaudio"), true, "target.hasActor() true when actor exists.");
   is(target.hasActor("notreal"), false, "target.hasActor() false when actor does not exist.");
   // Create a front to ensure the actor is loaded
-  new WebAudioFront(target.client, target.form);
+  await target.getFront("webaudio");
 
   let desc = await target.getActorDescription("webaudio");
   is(desc.typeName, "webaudio",
     "target.getActorDescription() returns definition data for corresponding actor");
   is(desc.events["start-context"].type, "startContext",
     "target.getActorDescription() returns event data for corresponding actor");
 
   desc = await target.getActorDescription("nope");
--- a/devtools/client/webaudioeditor/panel.js
+++ b/devtools/client/webaudioeditor/panel.js
@@ -19,17 +19,17 @@ function WebAudioEditorPanel(iframeWindo
 
 exports.WebAudioEditorPanel = WebAudioEditorPanel;
 
 WebAudioEditorPanel.prototype = {
   open: async function() {
     this.panelWin.gToolbox = this._toolbox;
     this.panelWin.gTarget = this.target;
 
-    this.panelWin.gFront = new WebAudioFront(this.target.client, this.target.form);
+    this.panelWin.gFront = await this.target.getFront("webaudio");
 
     await this.panelWin.startupWebAudioEditor();
 
     this.isReady = true;
     this.emit("ready");
     return this;
   },
 
--- a/devtools/client/webaudioeditor/test/head.js
+++ b/devtools/client/webaudioeditor/test/head.js
@@ -63,17 +63,17 @@ function initBackend(aUrl) {
   DebuggerServer.registerAllActors();
 
   return (async function() {
     const tab = await addTab(aUrl);
     const target = await TargetFactory.forTab(tab);
 
     await target.attach();
 
-    const front = new WebAudioFront(target.client, target.form);
+    const front = await target.getFront("webaudio");
     return { target, front };
   })();
 }
 
 /**
  * Adds a new tab, and open the toolbox for that tab, selecting the audio editor
  * panel.
  * This requires calling teardown before the test ends.
--- a/devtools/shared/fronts/reflow.js
+++ b/devtools/shared/fronts/reflow.js
@@ -5,17 +5,17 @@
 "use strict";
 
 const {reflowSpec} = require("devtools/shared/specs/reflow");
 const { FrontClassWithSpec, registerFront } = require("devtools/shared/protocol");
 
 /**
  * Usage example of the reflow front:
  *
- * let front = new ReflowFront(toolbox.target.client, toolbox.target.form);
+ * let front = await target.getFront("reflow");
  * front.on("reflows", this._onReflows);
  * front.start();
  * // now wait for events to come
  */
 class ReflowFront extends FrontClassWithSpec(reflowSpec) {
   constructor(client, {reflowActor}) {
     super(client, {actor: reflowActor});
     this.manage(this);
--- a/testing/talos/talos/tests/devtools/addon/content/tests/server/protocol.js
+++ b/testing/talos/talos/tests/devtools/addon/content/tests/server/protocol.js
@@ -20,16 +20,17 @@ const REPEAT = 300;
 class DampTestFront extends FrontClassWithSpec(dampTestSpec) {
   constructor(client, tabForm) {
     super(client, tabForm);
     this.actorID = tabForm.dampTestActor;
     // Root owns itself.
     this.manage(this);
   }
 }
+protocol.registerFront(DampTestFront);
 
 module.exports = async function() {
   let tab = await testSetup(SIMPLE_URL);
   let messageManager = tab.linkedBrowser.messageManager;
 
   let url = module.uri.replace(/protocol\.js$/, "actor.js");
 
   // Register a test actor within the content process
@@ -59,17 +60,17 @@ module.exports = async function() {
 
   let bigArray = Array.from({length: ARRAY_SIZE}, (_, i) => bigObject);
 
   // Open against options to avoid noise from tools
   let toolbox = await openToolbox("options");
 
   // Instanciate a front for this test actor
   let { target } = toolbox;
-  let front = new DampTestFront(target.client, target.form);
+  let front = await target.getFront("dampTest");
 
   // Execute the core of this test, call one method multiple times
   // and listen for an event sent by this method
   let test = runTest("server.protocoljs.DAMP");
   for (let i = 0; i < REPEAT; i++) {
     let onEvent = front.once("testEvent");
     await front.testMethod(bigArray, { option: bigArray }, ARRAY_SIZE);
     await onEvent;