Bug 1488381 - Use target.getFront to instantiate WebExtensionInspectedWindowFront; r=ochameau
authoryulia <ystartsev@mozilla.com>
Fri, 28 Sep 2018 17:52:26 +0000
changeset 494644 570fdc8386296f3f6f5c008800b978aeacf7a17a
parent 494643 2d9900b114f1fce25926a83638c5946efdca3e4c
child 494645 c3d7f8a2a6d4febb937ef7ee6ee79f3b96fed55c
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1488381
milestone64.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 1488381 - Use target.getFront to instantiate WebExtensionInspectedWindowFront; r=ochameau Depends on D6768 Differential Revision: https://phabricator.services.mozilla.com/D7063
devtools/client/framework/devtools.js
devtools/client/framework/target.js
devtools/client/inspector/extensions/test/browser_inspector_extension_sidebar.js
devtools/server/tests/browser/browser_webextension_inspected_window.js
--- a/devtools/client/framework/devtools.js
+++ b/devtools/client/framework/devtools.js
@@ -11,19 +11,16 @@ const {DevToolsShim} = require("chrome:/
 
 loader.lazyRequireGetter(this, "TargetFactory", "devtools/client/framework/target", true);
 loader.lazyRequireGetter(this, "ToolboxHostManager", "devtools/client/framework/toolbox-host-manager", true);
 loader.lazyRequireGetter(this, "HUDService", "devtools/client/webconsole/hudservice", true);
 loader.lazyRequireGetter(this, "Telemetry", "devtools/client/shared/telemetry");
 loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm");
 loader.lazyImporter(this, "BrowserToolboxProcess", "resource://devtools/client/framework/ToolboxProcess.jsm");
 
-loader.lazyRequireGetter(this, "WebExtensionInspectedWindowFront",
-      "devtools/shared/fronts/addon/webextension-inspected-window", true);
-
 const {defaultTools: DefaultTools, defaultThemes: DefaultThemes} =
   require("devtools/client/definitions");
 const EventEmitter = require("devtools/shared/event-emitter");
 const {getTheme, setTheme, addThemeObserver, removeThemeObserver} =
   require("devtools/client/shared/theme");
 
 const FORBIDDEN_IDS = new Set(["toolbox", ""]);
 const MAX_ORDINAL = 99;
@@ -621,17 +618,17 @@ DevTools.prototype = {
     return TargetFactory.createTargetForTab(tab);
   },
 
   /**
    * Compatibility layer for web-extensions. Used by DevToolsShim for
    * browser/components/extensions/ext-devtools-inspectedWindow.js
    */
   createWebExtensionInspectedWindowFront: function(tabTarget) {
-    return new WebExtensionInspectedWindowFront(tabTarget.client, tabTarget.form);
+    return tabTarget.getFront("webExtensionInspectedWindow");
   },
 
   /**
    * Compatibility layer for web-extensions. Used by DevToolsShim for
    * toolkit/components/extensions/ext-c-toolkit.js
    */
   openBrowserConsole: function() {
     const {HUDService} = require("devtools/client/webconsole/hudservice");
--- a/devtools/client/framework/target.js
+++ b/devtools/client/framework/target.js
@@ -359,17 +359,18 @@ TabTarget.prototype = {
   get root() {
     return this.client.mainRoot.rootForm;
   },
 
   // Get a Front for a target-scoped actor.
   // i.e. an actor served by RootActor.listTabs or RootActorActor.getTab requests
   getFront(typeName) {
     let front = this.fronts.get(typeName);
-    if (front) {
+    // the front might have been destroyed and no longer have an actor ID
+    if (front && front.actorID) {
       return front;
     }
     front = getFront(this.client, typeName, this.form);
     this.fronts.set(typeName, front);
     return front;
   },
 
   get client() {
--- a/devtools/client/inspector/extensions/test/browser_inspector_extension_sidebar.js
+++ b/devtools/client/inspector/extensions/test/browser_inspector_extension_sidebar.js
@@ -2,22 +2,16 @@
 /* Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 ChromeUtils.defineModuleGetter(this, "ContentTaskUtils",
                                "resource://testing-common/ContentTaskUtils.jsm");
 
-loader.lazyGetter(this, "WebExtensionInspectedWindowFront", () => {
-  return require(
-    "devtools/shared/fronts/addon/webextension-inspected-window"
-  ).WebExtensionInspectedWindowFront;
-}, true);
-
 const SIDEBAR_ID = "an-extension-sidebar";
 const SIDEBAR_TITLE = "Sidebar Title";
 
 let extension;
 let fakeExtCallerInfo;
 
 let toolbox;
 let inspector;
@@ -108,20 +102,17 @@ add_task(async function testSidebarSetOb
   assertTreeView(sidebarPanelContent, {
     expectedTreeTables: 1,
     expectedStringCells: 0,
     expectedNumberCells: 1,
   });
 });
 
 add_task(async function testSidebarSetObjectValueGrip() {
-  const inspectedWindowFront = new WebExtensionInspectedWindowFront(
-    toolbox.target.client, toolbox.target.form
-  );
-
+  const inspectedWindowFront = toolbox.target.getFront("webExtensionInspectedWindow");
   const sidebar = inspector.getPanel(SIDEBAR_ID);
   const sidebarPanelContent = inspector.sidebar.getTabPanel(SIDEBAR_ID);
 
   info("Testing sidebar.setObjectValueGrip with rootTitle");
 
   const expression = `
     var obj = Object.create(null);
     obj.prop1 = 123;
@@ -153,20 +144,17 @@ add_task(async function testSidebarSetOb
     nodesLength: 4,
     propertiesNames: ["cyclic", "prop1", "Symbol(sym1)"],
   });
 
   inspectedWindowFront.destroy();
 });
 
 add_task(async function testSidebarDOMNodeHighlighting() {
-  const inspectedWindowFront = new WebExtensionInspectedWindowFront(
-    toolbox.target.client, toolbox.target.form
-  );
-
+  const inspectedWindowFront = toolbox.target.getFront("webExtensionInspectedWindow");
   const sidebar = inspector.getPanel(SIDEBAR_ID);
   const sidebarPanelContent = inspector.sidebar.getTabPanel(SIDEBAR_ID);
 
   const expression = "({ body: document.body })";
 
   const evalResult = await inspectedWindowFront.eval(fakeExtCallerInfo, expression, {
     evalResultAsGrip: true,
     toolboxConsoleActorID: toolbox.target.form.consoleActor
--- a/devtools/server/tests/browser/browser_webextension_inspected_window.js
+++ b/devtools/server/tests/browser/browser_webextension_inspected_window.js
@@ -1,18 +1,14 @@
 /* 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/ */
 
 "use strict";
 
-const {
-  WebExtensionInspectedWindowFront
-} = require("devtools/shared/fronts/addon/webextension-inspected-window");
-
 const TEST_RELOAD_URL = `${MAIN_DOMAIN}/inspectedwindow-reload-target.sjs`;
 
 async function setup(pageUrl) {
   const extension = ExtensionTestUtils.loadExtension({
     background() {
       // This is just an empty extension used to ensure that the caller extension uuid
       // actually exists.
     }
@@ -21,27 +17,25 @@ async function setup(pageUrl) {
   await extension.startup();
 
   const fakeExtCallerInfo = {
     url: WebExtensionPolicy.getByID(extension.id).getURL("fake-caller-script.js"),
     lineNumber: 1,
     addonId: extension.id,
   };
 
-  await addTab(pageUrl);
-  initDebuggerServer();
+  const target = await addTabTarget(pageUrl);
 
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  const form = await connectDebuggerClient(client);
+  const { client, form } = target;
 
   const [, tabClient] = await client.attachTarget(form.actor);
 
   const [, consoleClient] = await client.attachConsole(form.consoleActor, []);
 
-  const inspectedWindowFront = new WebExtensionInspectedWindowFront(client, form);
+  const inspectedWindowFront = target.getFront("webExtensionInspectedWindow");
 
   return {
     client, form,
     tabClient, consoleClient,
     inspectedWindowFront,
     extension, fakeExtCallerInfo,
   };
 }