Backed out changeset 3182a1d6debb (bug 1500142) for xpcshell failures at test_oob_cert_auth.js. CLOSED TREE

This commit is contained in:
Brindusan Cristian 2019-09-06 23:05:31 +03:00
parent 63f73c09e6
commit f2aabeaa59
5 changed files with 84 additions and 20 deletions

View File

@ -88,6 +88,7 @@ AccessibilityPanel.prototype = {
this.shouldRefresh = true; this.shouldRefresh = true;
this.panelWin.gToolbox = this._toolbox; this.panelWin.gToolbox = this._toolbox;
await this._toolbox.initInspector();
await this.startup.initAccessibility(); await this.startup.initAccessibility();
if (this.supports.enableDisable) { if (this.supports.enableDisable) {
this.picker = new Picker(this); this.picker = new Picker(this);

View File

@ -93,6 +93,7 @@ DebuggerPanel.prototype = {
}, },
openInspector: async function() { openInspector: async function() {
await this.toolbox.initInspector();
this.toolbox.selectTool("inspector"); this.toolbox.selectTool("inspector");
}, },

View File

@ -217,6 +217,8 @@ function Toolbox(
this._toolStartups = new Map(); this._toolStartups = new Map();
this._inspectorExtensionSidebars = new Map(); this._inspectorExtensionSidebars = new Map();
this._initInspector = null;
this._inspector = null;
this._netMonitorAPI = null; this._netMonitorAPI = null;
// Map of frames (id => frame-info) and currently selected frame id. // Map of frames (id => frame-info) and currently selected frame id.
@ -298,10 +300,6 @@ function Toolbox(
this._target.on("frame-update", this._updateFrames); this._target.on("frame-update", this._updateFrames);
this._target.on("inspect-object", this._onInspectObject); this._target.on("inspect-object", this._onInspectObject);
this._target.onFront("inspector", async inspectorFront => {
registerWalkerListeners(this.store, inspectorFront.walker);
});
this.on("host-changed", this._refreshHostTitle); this.on("host-changed", this._refreshHostTitle);
this.on("select", this._onToolSelected); this.on("select", this._onToolSelected);
@ -525,6 +523,14 @@ Toolbox.prototype = {
return this.win.document; return this.win.document;
}, },
/**
* Get the toolbox's inspector front. Note that it may not always have been
* initialized first. Use `initInspector()` if needed.
*/
get inspectorFront() {
return this._inspector;
},
/** /**
* Get the toggled state of the split console * Get the toggled state of the split console
*/ */
@ -1911,19 +1917,19 @@ Toolbox.prototype = {
* Update the buttons. * Update the buttons.
*/ */
updateToolboxButtons() { updateToolboxButtons() {
const inspectorFront = this.target.getCachedFront("inspectorFront"); const inspector = this.inspectorFront;
// two of the buttons have highlighters that need to be cleared // two of the buttons have highlighters that need to be cleared
// on will-navigate, otherwise we hold on to the stale highlighter // on will-navigate, otherwise we hold on to the stale highlighter
const hasHighlighters = const hasHighlighters =
inspectorFront && inspector &&
(inspectorFront.hasHighlighter("RulersHighlighter") || (inspector.hasHighlighter("RulersHighlighter") ||
inspectorFront.hasHighlighter("MeasuringToolHighlighter")); inspector.hasHighlighter("MeasuringToolHighlighter"));
if (hasHighlighters || this.isPaintFlashing) { if (hasHighlighters || this.isPaintFlashing) {
if (this.isPaintFlashing) { if (this.isPaintFlashing) {
this.togglePaintFlashing(); this.togglePaintFlashing();
} }
if (hasHighlighters) { if (hasHighlighters) {
inspectorFront.destroyHighlighters(); inspector.destroyHighlighters();
} }
this.component.setToolboxButtons(this.toolbarButtons); this.component.setToolboxButtons(this.toolbarButtons);
} }
@ -2159,7 +2165,7 @@ Toolbox.prototype = {
// Defer the extension sidebar creation if the inspector // Defer the extension sidebar creation if the inspector
// has not been created yet (and do not create the inspector // has not been created yet (and do not create the inspector
// only to register an extension sidebar). // only to register an extension sidebar).
if (!this.target.getCachedFront("inspector")) { if (!this._inspector) {
return; return;
} }
@ -2190,7 +2196,7 @@ Toolbox.prototype = {
// Remove the created sidebar instance if the inspector panel // Remove the created sidebar instance if the inspector panel
// has been already created. // has been already created.
if (!this.target.getCachedFront("inspector")) { if (!this._inspector) {
return; return;
} }
@ -2230,6 +2236,10 @@ Toolbox.prototype = {
* The id of the tool to load. * The id of the tool to load.
*/ */
loadTool: function(id) { loadTool: function(id) {
if (id === "inspector" && !this._inspector) {
this.initInspector();
}
let iframe = this.doc.getElementById("toolbox-panel-iframe-" + id); let iframe = this.doc.getElementById("toolbox-panel-iframe-" + id);
if (iframe) { if (iframe) {
const panel = this._toolPanels.get(id); const panel = this._toolPanels.get(id);
@ -2272,6 +2282,18 @@ Toolbox.prototype = {
} }
const onLoad = async () => { const onLoad = async () => {
if (id === "inspector") {
await this._initInspector;
// Stop loading the inspector if the toolbox is already being destroyed. This
// can happen in unit tests where the tests are rapidly opening and closing the
// toolbox and we encounter the scenario where the toolbox is closing as
// the inspector is still loading.
if (!this._inspector || !iframe.contentWindow) {
return;
}
}
// Prevent flicker while loading by waiting to make visible until now. // Prevent flicker while loading by waiting to make visible until now.
iframe.style.visibility = "visible"; iframe.style.visibility = "visible";
@ -3276,6 +3298,24 @@ Toolbox.prototype = {
this.emit("tool-unregistered", toolId); this.emit("tool-unregistered", toolId);
}, },
/**
* Initialize the inspector/walker/selection/highlighter fronts.
* Returns a promise that resolves when the fronts are initialized
*/
initInspector: function() {
if (!this._initInspector) {
this._initInspector = async function() {
// 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
// TODO: remove these bindings
this._inspector = await this.target.getFront("inspector");
registerWalkerListeners(this.store, this._inspector.walker);
}.bind(this)();
}
return this._initInspector;
},
/** /**
* An helper function that returns an object contain a highlighter and unhighlighter * An helper function that returns an object contain a highlighter and unhighlighter
* function. * function.
@ -3370,6 +3410,23 @@ Toolbox.prototype = {
} }
}, },
/**
* Destroy the inspector/walker/selection fronts
* Returns a promise that resolves when the fronts are destroyed
* TODO: move to the inspector front once we can have listener hooks into fronts
*/
destroyInspector: function() {
if (!this._inspector) {
return;
}
// Temporary fix for bug #1493131 - inspector has a different life cycle
// than most other fronts because it is closely related to the toolbox.
this._inspector.destroy();
this._inspector = null;
},
/** /**
* Get the toolbox's notification component * Get the toolbox's notification component
* *
@ -3533,6 +3590,9 @@ Toolbox.prototype = {
settleAll(outstanding) settleAll(outstanding)
.catch(console.error) .catch(console.error)
.then(async () => { .then(async () => {
// Destroying the walker and inspector fronts
this.destroyInspector();
this.selection.destroy(); this.selection.destroy();
this.selection = null; this.selection = null;

View File

@ -89,7 +89,7 @@ class Front extends Pool {
this._beforeListeners = null; this._beforeListeners = null;
} }
async manage(front) { manage(front) {
if (!front.actorID) { if (!front.actorID) {
throw new Error( throw new Error(
"Can't manage front without an actor ID.\n" + "Can't manage front without an actor ID.\n" +
@ -100,10 +100,6 @@ class Front extends Pool {
} }
super.manage(front); super.manage(front);
if (typeof front.initialize == "function") {
await front.initialize();
}
// Call listeners registered via `onFront` method // Call listeners registered via `onFront` method
this._frontListeners.emit(front.typeName, front); this._frontListeners.emit(front.typeName, front);
} }

View File

@ -497,7 +497,7 @@ exports.registerFront = function(cls) {
* If we are instantiating a target-scoped front, this is a reference to the front's * If we are instantiating a target-scoped front, this is a reference to the front's
* Target instance, otherwise this is null. * Target instance, otherwise this is null.
*/ */
async function getFront(client, typeName, form, target = null) { function getFront(client, typeName, form, target = null) {
const type = types.getType(typeName); const type = types.getType(typeName);
if (!type) { if (!type) {
throw new Error(`No spec for front type '${typeName}'.`); throw new Error(`No spec for front type '${typeName}'.`);
@ -521,13 +521,19 @@ async function getFront(client, typeName, form, target = null) {
` actor's form.` ` actor's form.`
); );
} }
// Historically, all global and target scoped front were the first protocol.js in the
// hierarchy of fronts. So that they have to self-own themself. But now, Root and Target
// are fronts and should own them. The only issue here is that we should manage the
// front *before* calling initialize which is going to try managing child fronts.
if (!target) { if (!target) {
await instance.manage(instance); instance.manage(instance);
} else { } else {
await target.manage(instance); target.manage(instance);
} }
if (typeof instance.initialize == "function") {
return instance.initialize().then(() => instance);
}
return instance; return instance;
} }
exports.getFront = getFront; exports.getFront = getFront;