mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1024787 - Fix uncaught promise rejections in devtools/framework. r=jryans
This commit is contained in:
parent
a89979d405
commit
08f1f645c8
@ -38,11 +38,18 @@ function runTests(aTab) {
|
||||
"The tool is registered");
|
||||
|
||||
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
|
||||
gDevTools.showToolbox(target, toolId).then(function(toolbox) {
|
||||
// Wait for the test tool to be visible and selected.
|
||||
let { promise: testToolShown, resolve } = promise.defer();
|
||||
toolbox.once("test-tool-selected", resolve);
|
||||
|
||||
return testToolShown.then(() => toolbox);
|
||||
}).then(function (toolbox) {
|
||||
is(toolbox.target, target, "toolbox target is correct");
|
||||
is(toolbox._host.hostTab, gBrowser.selectedTab, "toolbox host is correct");
|
||||
continueTests(toolbox);
|
||||
}).then(null, console.error);
|
||||
});
|
||||
}
|
||||
|
||||
function continueTests(toolbox, panel) {
|
||||
@ -65,13 +72,23 @@ function continueTests(toolbox, panel) {
|
||||
is(gDevTools.getToolDefinitionMap().has(toolId), false,
|
||||
"The tool is no longer registered");
|
||||
|
||||
// Wait for unregisterTool to select the next tool before
|
||||
// attempting to destroy.
|
||||
toolbox.on("select", function selectListener (_, id) {
|
||||
if (id !== "test-tool") {
|
||||
toolbox.off("select", selectListener);
|
||||
destroyToolbox(toolbox);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function destroyToolbox(toolbox) {
|
||||
toolbox.destroy().then(function() {
|
||||
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
ok(gDevTools._toolboxes.get(target) == null, "gDevTools doesn't know about target");
|
||||
ok(toolbox._target == null, "toolbox doesn't know about target.");
|
||||
|
||||
finishUp();
|
||||
}).then(null, console.error);
|
||||
});
|
||||
}
|
||||
|
||||
function finishUp() {
|
||||
|
@ -14,7 +14,7 @@ function test() {
|
||||
target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
loadWebConsole(aTab).then(function() {
|
||||
console.log('loaded');
|
||||
}, console.error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ function loadWebConsole(aTab) {
|
||||
return gDevTools.showToolbox(target, "webconsole").then(function(aToolbox) {
|
||||
toolbox = aToolbox;
|
||||
checkToolLoading();
|
||||
}, console.error);
|
||||
});
|
||||
}
|
||||
|
||||
function checkToolLoading() {
|
||||
@ -35,7 +35,7 @@ function checkToolLoading() {
|
||||
selectAndCheckById("styleeditor").then(function() {
|
||||
testToggle();
|
||||
});
|
||||
}, console.error);
|
||||
});
|
||||
}
|
||||
|
||||
function selectAndCheckById(id) {
|
||||
@ -53,8 +53,10 @@ function testToggle() {
|
||||
target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
gDevTools.showToolbox(target, "styleeditor").then(function(aToolbox) {
|
||||
toolbox = aToolbox;
|
||||
is(toolbox.currentToolId, "styleeditor", "The style editor is selected");
|
||||
finishUp();
|
||||
aToolbox.once("styleeditor-selected", () => {
|
||||
is(toolbox.currentToolId, "styleeditor", "The style editor is selected");
|
||||
finishUp();
|
||||
});
|
||||
});
|
||||
}.bind(this));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user