Bug 1568151 - Replace `target.getInspector()` by `target.getFront("inspector")`. r=ochameau

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gabriel Luong 2019-08-06 19:55:15 +00:00
Родитель ae7379da44
Коммит 2365ba00a8
38 изменённых файлов: 41 добавлений и 74 удалений

Просмотреть файл

@ -31,9 +31,8 @@ add_task(async function() {
// Ensure hovering over button highlights the node in content pane
const view = inspectorNode.ownerDocument.defaultView;
const onNodeHighlight = toolbox.target
.once("inspector")
.then(inspector => inspector.highlighter.once("node-highlight"));
const inspectorFront = await toolbox.target.getFront("inspector");
const onNodeHighlight = inspectorFront.highlighter.once("node-highlight");
EventUtils.synthesizeMouseAtCenter(
inspectorNode,
{ type: "mousemove" },

Просмотреть файл

@ -631,11 +631,7 @@ function createHighlightButton(highlighterName, id) {
isChecked(toolbox) {
// if the inspector doesn't exist, then the highlighter has not yet been connected
// to the front end.
// TODO: we are using target._inspector here, but we should be using
// target.getCachedFront. This is a temporary solution until the inspector no
// longer relies on the toolbox and can be destroyed the same way any other
// front would be. Related: #1487677
const inspectorFront = toolbox.target._inspector;
const inspectorFront = toolbox.target.getCachedFront("inspector");
if (!inspectorFront) {
// initialize the inspector front asyncronously. There is a potential for buggy
// behavior here, but we need to change how the buttons get data (have them

Просмотреть файл

@ -18,9 +18,8 @@ add_task(async function() {
let node = getRowByIndex(panel, 2).querySelector(".objectBox-node");
// the inspector should be initialized first and then the node should
// highlight after the hover effect.
let onNodeHighlight = toolbox.target
.once("inspector")
.then(inspector => inspector.highlighter.once("node-highlight"));
const inspectorFront = await toolbox.target.getFront("inspector");
let onNodeHighlight = inspectorFront.highlighter.once("node-highlight");
EventUtils.synthesizeMouseAtCenter(
node,
{

Просмотреть файл

@ -3279,7 +3279,7 @@ Toolbox.prototype = {
// than most other fronts because it is closely related to the toolbox.
// TODO: replace with getFront once inspector is separated from the toolbox
// TODO: remove these bindings
this._inspector = await this.target.getInspector();
this._inspector = await this.target.getFront("inspector");
this._walker = this.inspectorFront.walker;
this._highlighter = this.inspectorFront.highlighter;
this._selection = this.inspectorFront.selection;

Просмотреть файл

@ -154,10 +154,7 @@ exports.menuitems = [
const window = event.target.ownerDocument.defaultView;
const target = await TargetFactory.forTab(window.gBrowser.selectedTab);
await target.attach();
// Temporary fix for bug #1493131 - inspector has a different life cycle
// than most other fronts because it is closely related to the toolbox.
// TODO: replace with getFront once inspector is separated from the toolbox
const inspectorFront = await target.getInspector();
const inspectorFront = await target.getFront("inspector");
inspectorFront.pickColorFromPage({ copyOnSelect: true, fromMenu: true });
},
checkbox: true,

Просмотреть файл

@ -93,7 +93,7 @@ add_task(async function test() {
async function runTests() {
const target = await TargetFactory.forTab(gBrowser.selectedTab);
await target.attach();
inspector = await target.getInspector();
inspector = await target.getFront("inspector");
const walker = inspector.walker;
completer = new CSSCompleter({
walker: walker,

Просмотреть файл

@ -16,7 +16,7 @@ add_task(async function() {
async function runTests() {
const target = await TargetFactory.forTab(gBrowser.selectedTab);
await target.attach();
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
const walker = inspector.walker;
const { ed, win, edWin } = await setup({
autocomplete: true,

Просмотреть файл

@ -50,9 +50,8 @@ add_task(async function() {
// the inspector should be initialized first and then the node should
// highlight after the hover effect.
let onNodeHighlight = toolbox.target
.once("inspector")
.then(inspector => inspector.highlighter.once("node-highlight"));
const inspectorFront = await toolbox.target.getFront("inspector");
let onNodeHighlight = inspectorFront.highlighter.once("node-highlight");
EventUtils.synthesizeMouseAtCenter(node, { type: "mousemove" }, view);

Просмотреть файл

@ -82,7 +82,7 @@ async function initLayoutFrontForUrl(url) {
async function initAccessibilityFrontForUrl(url) {
const target = await addTabTarget(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
const walker = inspector.walker;
const accessibility = await target.getFront("accessibility");
@ -113,8 +113,7 @@ async function initPerfFront() {
async function initInspectorFront(url) {
const target = await addTabTarget(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
const walker = inspector.walker;
return { inspector, walker, target };

Просмотреть файл

@ -25,7 +25,7 @@ addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
gInspectee = doc;
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
runNextTest();
});

Просмотреть файл

@ -25,7 +25,7 @@ addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
gInspectee = doc;
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
runNextTest();
});

Просмотреть файл

@ -25,7 +25,7 @@ addAsyncTest(async function() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
gDoc = doc;
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
runNextTest();
});

Просмотреть файл

@ -23,7 +23,7 @@ var gWalker;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
runNextTest();
});

Просмотреть файл

@ -23,7 +23,7 @@ let gWalker = null;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
runNextTest();
});

Просмотреть файл

@ -24,7 +24,7 @@ let gInspectee = null;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gInspectee = doc;
gWalker = inspector.walker;
runNextTest();

Просмотреть файл

@ -26,7 +26,7 @@ let attrFront;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gInspectee = doc;
gWalker = inspector.walker;
runNextTest();

Просмотреть файл

@ -33,7 +33,7 @@ window.onload = function() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
inspectee = doc;
inspector = await target.getInspector();
inspector = await target.getFront("inspector");
walker = inspector.walker;
runNextTest();

Просмотреть файл

@ -38,7 +38,7 @@ var shortString2 = "str2";
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gInspectee = doc;
gWalker = inspector.walker;
runNextTest();

Просмотреть файл

@ -26,7 +26,7 @@ window.onload = function() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
inspector = await target.getInspector();
inspector = await target.getFront("inspector");
win = doc.defaultView;
runNextTest();
});

Просмотреть файл

@ -29,7 +29,7 @@ async function setup(callback) {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
gInspectee = doc;
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
ok(inspector.walker, "getWalker() should return an actor.");
gWalker = inspector.walker;
runNextTest();

Просмотреть файл

@ -24,7 +24,7 @@ let gWalker = null;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gInspectee = doc;
const walker = inspector.walker;
gWalker = await inspector.getWalker();

Просмотреть файл

@ -25,7 +25,7 @@ window.onload = function() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
inspector = await target.getInspector();
inspector = await target.getFront("inspector");
win = doc.defaultView;
runNextTest();
});

Просмотреть файл

@ -24,7 +24,7 @@ let gDoc;
addTest(async function() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
gInspector = await target.getInspector();
gInspector = await target.getFront("inspector");
gDoc = doc;
runNextTest();
});

Просмотреть файл

@ -25,7 +25,7 @@ addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
gInspectee = doc;
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
runNextTest();
});

Просмотреть файл

@ -29,7 +29,7 @@ window.onload = function() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
inspector = await target.getInspector();
inspector = await target.getFront("inspector");
walkerFront = inspector.walker;
runNextTest();

Просмотреть файл

@ -23,7 +23,7 @@ window.onload = function() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
runNextTest();

Просмотреть файл

@ -44,7 +44,7 @@ let gWalker = null;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
gNodeFront = await gWalker.querySelector(gWalker.rootNode, "img.custom");
gImg = doc.querySelector("img.custom");

Просмотреть файл

@ -23,7 +23,7 @@ let gWalker = null;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
runNextTest();
});

Просмотреть файл

@ -41,7 +41,7 @@ let gInspector = null;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
gInspector = await target.getInspector();
gInspector = await target.getFront("inspector");
runNextTest();
});

Просмотреть файл

@ -23,7 +23,7 @@ let gWalker;
addTest(async function() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
runNextTest();
});

Просмотреть файл

@ -25,7 +25,7 @@ var gBodyNode;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
gBodyNode = await gWalker.querySelector(gWalker.rootNode, "body");
gHTMLNode = await gWalker.querySelector(gWalker.rootNode, "html");

Просмотреть файл

@ -24,7 +24,7 @@ let gStyles = null;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
gStyles = await inspector.getPageStyle();
runNextTest();

Просмотреть файл

@ -24,7 +24,7 @@ let gStyles = null;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
gStyles = await inspector.getPageStyle();
runNextTest();

Просмотреть файл

@ -20,7 +20,7 @@ let gStyles = null;
addTest(async function() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
gStyles = await inspector.getPageStyle();
runNextTest();

Просмотреть файл

@ -28,7 +28,7 @@ addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
gInspectee = doc;
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
gStyles = await inspector.getPageStyle();
runNextTest();

Просмотреть файл

@ -28,7 +28,7 @@ addAsyncTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target, doc } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gInspectee = doc;
gWalker = inspector.walker;

Просмотреть файл

@ -25,7 +25,7 @@ let gStyles = null;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
const inspector = await target.getInspector();
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
gStyles = await inspector.getPageStyle();
runNextTest();

Просмотреть файл

@ -67,10 +67,6 @@ function TargetMixin(parentClass) {
// Cache of already created targed-scoped fronts
// [typeName:string => Front instance]
this.fronts = new Map();
// Temporary fix for bug #1493131 - inspector has a different life cycle
// than most other fronts because it is closely related to the toolbox.
// TODO: remove once inspector is separated from the toolbox
this._inspector = null;
this._setupRemoteListeners();
}
@ -191,24 +187,6 @@ function TargetMixin(parentClass) {
return this.client.mainRoot.rootForm;
}
// Temporary fix for bug #1493131 - inspector has a different life cycle
// than most other fronts because it is closely related to the toolbox.
// TODO: remove once inspector is separated from the toolbox
async getInspector() {
// the front might have been destroyed and no longer have an actor ID
if (this._inspector && this._inspector.actorID) {
return this._inspector;
}
this._inspector = await getFront(
this.client,
"inspector",
this.targetForm,
this
);
this.emit("inspector", this._inspector);
return this._inspector;
}
// Run callback on every front of this type that currently exists, and on every
// instantiation of front type in the future.
onFront(typeName, callback) {