Bug 1485676 - Refactor gDevTools.getTargetForTab callsites to assume getTargetForTab is async. r=yulia

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexandre Poirot 2018-09-21 08:06:16 +00:00
Родитель 8218d8a740
Коммит 3d286eae18
8 изменённых файлов: 15 добавлений и 15 удалений

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

@ -106,7 +106,7 @@ add_task(async function test_devtools_inspectedWindow_tabId() {
let backgroundPageCurrentTabId = await extension.awaitMessage("current-tab-id"); let backgroundPageCurrentTabId = await extension.awaitMessage("current-tab-id");
let target = gDevTools.getTargetForTab(tab); let target = await gDevTools.getTargetForTab(tab);
await gDevTools.showToolbox(target, "webconsole"); await gDevTools.showToolbox(target, "webconsole");
info("developer toolbox opened"); info("developer toolbox opened");
@ -174,7 +174,7 @@ add_task(async function test_devtools_inspectedWindow_eval() {
await extension.startup(); await extension.startup();
let target = gDevTools.getTargetForTab(tab); let target = await gDevTools.getTargetForTab(tab);
await gDevTools.showToolbox(target, "webconsole"); await gDevTools.showToolbox(target, "webconsole");
info("developer toolbox opened"); info("developer toolbox opened");
@ -336,7 +336,7 @@ add_task(async function test_devtools_inspectedWindow_eval_in_page_and_panel() {
await extension.startup(); await extension.startup();
const target = gDevTools.getTargetForTab(tab); const target = await gDevTools.getTargetForTab(tab);
const toolbox = await gDevTools.showToolbox(target, "webconsole"); const toolbox = await gDevTools.showToolbox(target, "webconsole");
info("developer toolbox opened"); info("developer toolbox opened");

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

@ -54,7 +54,7 @@ add_task(async function test_devtools_inspectedWindow_eval_bindings() {
await extension.startup(); await extension.startup();
const target = gDevTools.getTargetForTab(tab); const target = await gDevTools.getTargetForTab(tab);
// Open the toolbox on the styleeditor, so that the inspector and the // Open the toolbox on the styleeditor, so that the inspector and the
// console panel have not been explicitly activated yet. // console panel have not been explicitly activated yet.
const toolbox = await gDevTools.showToolbox(target, "styleeditor"); const toolbox = await gDevTools.showToolbox(target, "styleeditor");

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

@ -37,7 +37,7 @@ async function runReloadTestCase({urlParams, background, devtoolsPage, testCase}
await extension.startup(); await extension.startup();
let target = gDevTools.getTargetForTab(tab); let target = await gDevTools.getTargetForTab(tab);
await gDevTools.showToolbox(target, "webconsole"); await gDevTools.showToolbox(target, "webconsole");
info("developer toolbox opened"); info("developer toolbox opened");

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

@ -134,7 +134,7 @@ add_task(async function test_devtools_network_on_navigated() {
await extension.startup(); await extension.startup();
await extension.awaitMessage("ready"); await extension.awaitMessage("ready");
let target = gDevTools.getTargetForTab(tab); let target = await gDevTools.getTargetForTab(tab);
await gDevTools.showToolbox(target, "webconsole"); await gDevTools.showToolbox(target, "webconsole");
info("Developer toolbox opened."); info("Developer toolbox opened.");
@ -172,7 +172,7 @@ add_task(async function test_devtools_network_get_har() {
await extension.startup(); await extension.startup();
await extension.awaitMessage("ready"); await extension.awaitMessage("ready");
let target = gDevTools.getTargetForTab(tab); let target = await gDevTools.getTargetForTab(tab);
// Open the Toolbox // Open the Toolbox
let toolbox = await gDevTools.showToolbox(target, "webconsole"); let toolbox = await gDevTools.showToolbox(target, "webconsole");
@ -223,7 +223,7 @@ add_task(async function test_devtools_network_on_request_finished() {
await extension.startup(); await extension.startup();
await extension.awaitMessage("ready"); await extension.awaitMessage("ready");
let target = gDevTools.getTargetForTab(tab); let target = await gDevTools.getTargetForTab(tab);
// Open the Toolbox // Open the Toolbox
let toolbox = await gDevTools.showToolbox(target, "webconsole"); let toolbox = await gDevTools.showToolbox(target, "webconsole");

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

@ -119,7 +119,7 @@ add_task(async function test_devtools_page_runtime_api_messaging() {
info("Wait the content script load"); info("Wait the content script load");
await extension.awaitMessage("content_script_loaded"); await extension.awaitMessage("content_script_loaded");
let target = gDevTools.getTargetForTab(tab); let target = await gDevTools.getTargetForTab(tab);
info("Open the developer toolbox"); info("Open the developer toolbox");
await gDevTools.showToolbox(target, "webconsole"); await gDevTools.showToolbox(target, "webconsole");
@ -247,7 +247,7 @@ add_task(async function test_devtools_page_and_extension_tab_messaging() {
info("Wait the extension tab page load"); info("Wait the extension tab page load");
await extension.awaitMessage("extension_tab_loaded"); await extension.awaitMessage("extension_tab_loaded");
let target = gDevTools.getTargetForTab(tab); let target = await gDevTools.getTargetForTab(tab);
info("Open the developer toolbox"); info("Open the developer toolbox");
await gDevTools.showToolbox(target, "webconsole"); await gDevTools.showToolbox(target, "webconsole");

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

@ -25,14 +25,14 @@ const DEVTOOLS_THEME_PREF = "devtools.theme";
*/ */
async function openToolboxForTab(tab) { async function openToolboxForTab(tab) {
const target = gDevTools.getTargetForTab(tab); const target = await gDevTools.getTargetForTab(tab);
const toolbox = await gDevTools.showToolbox(target, "testBlankPanel"); const toolbox = await gDevTools.showToolbox(target, "testBlankPanel");
info("Developer toolbox opened"); info("Developer toolbox opened");
return {toolbox, target}; return {toolbox, target};
} }
async function closeToolboxForTab(tab) { async function closeToolboxForTab(tab) {
const target = gDevTools.getTargetForTab(tab); const target = await gDevTools.getTargetForTab(tab);
await gDevTools.closeToolbox(target); await gDevTools.closeToolbox(target);
await target.destroy(); await target.destroy();
info("Developer toolbox closed"); info("Developer toolbox closed");

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

@ -18,7 +18,7 @@ add_task(async function() {
}); });
async function testToolboxInitialization(tab, inspector, toolbox) { async function testToolboxInitialization(tab, inspector, toolbox) {
const target = TargetFactory.forTab(tab); const target = await TargetFactory.forTab(tab);
ok(true, "Inspector started, and notification received."); ok(true, "Inspector started, and notification received.");
ok(inspector, "Inspector instance is accessible."); ok(inspector, "Inspector instance is accessible.");

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

@ -709,11 +709,11 @@ DevToolsStartup.prototype = {
}, },
// Open the toolbox on the selected tab once the browser starts up. // Open the toolbox on the selected tab once the browser starts up.
handleDevToolsFlag: function(window) { handleDevToolsFlag: async function(window) {
const require = this.initDevTools("CommandLine"); const require = this.initDevTools("CommandLine");
const {gDevTools} = require("devtools/client/framework/devtools"); const {gDevTools} = require("devtools/client/framework/devtools");
const {TargetFactory} = require("devtools/client/framework/target"); const {TargetFactory} = require("devtools/client/framework/target");
const target = TargetFactory.forTab(window.gBrowser.selectedTab); const target = await TargetFactory.forTab(window.gBrowser.selectedTab);
gDevTools.showToolbox(target); gDevTools.showToolbox(target);
}, },