Bug 1702078 - [devtools] a11y panel should emit ready event after rendering the UI r=ochameau,perftest-reviewers

With the previous implementation, the toolbox would resolve the panel before all the initialization data had been retrieved.
This could lead to issues if we tried to destroy the toolbox right after the panel got selected.

Differential Revision: https://phabricator.services.mozilla.com/D110247
This commit is contained in:
Julian Descottes 2021-04-08 11:48:52 +00:00
Родитель 337d33442c
Коммит 6ab57dcec5
7 изменённых файлов: 48 добавлений и 32 удалений

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

@ -61,25 +61,12 @@ async function testReloadAboutDevToolsToolbox(toolId) {
const toolbox = getToolbox(devtoolsWindow);
await toolbox.selectTool(toolId);
// The a11y panel finishes its initialization after selectTool resolves.
// TODO: The a11y panel init should only resolve when the UI is ready and all
// initial requests are completed. See Bug 1702078.
if (toolId === "accessibility") {
await waitForA11yPanel(toolbox);
}
info("Wait for requests to settle before reloading");
await toolbox.target.client.waitForRequestsToSettle();
info("Reload about:devtools-toolbox page");
devtoolsBrowser.reload();
const newToolbox = await gDevTools.once("toolbox-ready");
// Again, wait for the delayed a11y panel initialization.
if (toolId === "accessibility") {
await waitForA11yPanel(newToolbox);
}
await gDevTools.once("toolbox-ready");
ok(true, "Toolbox is re-created again");
// Check that about:devtools-toolbox is still selected tab. See Bug 1570692.
@ -98,8 +85,3 @@ async function testReloadAboutDevToolsToolbox(toolId) {
await closeAboutDevtoolsToolbox(document, devtoolsTab, window);
await removeTab(tab);
}
async function waitForA11yPanel(toolbox) {
const panel = toolbox.getPanel("accessibility");
await panel._accessibilityViewInitialized;
}

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

@ -103,10 +103,6 @@ AccessibilityPanel.prototype = {
EVENTS.ACCESSIBILITY_INSPECTOR_UPDATED,
this.onAccessibilityInspectorUpdated
);
// Expose a promise so that tests can wait for the UI to be ready.
this._accessibilityViewInitialized = this.panelWin.once(EVENTS.INITIALIZED);
this.shouldRefresh = true;
this.accessibilityProxy = new AccessibilityProxy(this._commands);
this.accessibilityProxy.startListeningForTargetUpdated(
@ -131,6 +127,12 @@ AccessibilityPanel.prototype = {
shutdown: this.onLifecycleEvent,
});
// Force refresh to render the UI and wait for the INITIALIZED event.
const onInitialized = this.panelWin.once(EVENTS.INITIALIZED);
this.shouldRefresh = true;
this.refresh();
await onInitialized;
resolver(this);
return this._opening;
},

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

@ -42,7 +42,16 @@ const tests = [
keyboardShortcut: "",
childCount: 2,
indexInParent: 0,
states: ["readonly", "focusable", "opaque", "enabled", "sensitive"],
states: [
// The focused state is an outdated state, since the toolbox should now
// have the focus and not the content page. See Bug 1702709.
"focused",
"readonly",
"focusable",
"opaque",
"enabled",
"sensitive",
],
},
},
},

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

@ -33,7 +33,16 @@ const tests = [
keyboardShortcut: "",
childCount: 0,
indexInParent: 0,
states: ["readonly", "focusable", "opaque", "enabled", "sensitive"],
states: [
// The focused state is an outdated state, since the toolbox should now
// have the focus and not the content page. See Bug 1702709.
"focused",
"readonly",
"focusable",
"opaque",
"enabled",
"sensitive",
],
},
},
},

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

@ -42,7 +42,16 @@ const tests = [
keyboardShortcut: "",
childCount: 2,
indexInParent: 0,
states: ["readonly", "focusable", "opaque", "enabled", "sensitive"],
states: [
// The focused state is an outdated state, since the toolbox should now
// have the focus and not the content page. See Bug 1702709.
"focused",
"readonly",
"focusable",
"opaque",
"enabled",
"sensitive",
],
},
},
},

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

@ -34,7 +34,16 @@ const tests = [
keyboardShortcut: "",
childCount: 1,
indexInParent: 0,
states: ["readonly", "focusable", "opaque", "enabled", "sensitive"],
states: [
// The focused state is an outdated state, since the toolbox should now
// have the focus and not the content page. See Bug 1702709.
"focused",
"readonly",
"focusable",
"opaque",
"enabled",
"sensitive",
],
},
},
},

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

@ -25,11 +25,7 @@ exports.shutdownAccessibilityService = function() {
};
exports.openAccessibilityAndLog = function(label) {
return openToolboxAndLog(
`${label}.accessibility`,
"accessibility",
(toolbox, panel) => panel.panelWin.once(INITIALIZED_EVENT)
);
return openToolboxAndLog(`${label}.accessibility`, "accessibility");
};
exports.reloadAccessibilityAndLog = async function(label, toolbox) {