forked from jsantell/firefox-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1024787-devtools-framework-rejections.patch
152 lines (129 loc) · 5.07 KB
/
1024787-devtools-framework-rejections.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
From 4a0c95c8d1dc06859b941b22eb820e0bb83c3406 Mon Sep 17 00:00:00 2001
From: Jordan Santell <[email protected]>
Date: Thu, 12 Jun 2014 17:00:01 -0700
Subject: Bug 1024787 - Fix uncaught promise rejections in devtools/framework. r=jryans
---
.../framework/test/browser_devtools_api.js | 23 +++++++++++++++++++---
.../test/browser_new_activation_workflow.js | 12 ++++++-----
2 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/browser/devtools/framework/test/browser_devtools_api.js b/browser/devtools/framework/test/browser_devtools_api.js
index 938c3a3..f1349f9 100644
--- a/browser/devtools/framework/test/browser_devtools_api.js
+++ b/browser/devtools/framework/test/browser_devtools_api.js
@@ -33,21 +33,28 @@ function runTests(aTab) {
is(gDevTools.getToolDefinitionMap().has(toolId), false,
"The tool is not registered");
gDevTools.registerTool(toolDefinition);
is(gDevTools.getToolDefinitionMap().has(toolId), true,
"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) {
ok(toolbox.getCurrentPanel(), "panel value is correct");
is(toolbox.currentToolId, toolId, "toolbox _currentToolId is correct");
ok(!toolbox.doc.getElementById("toolbox-tab-" + toolId).hasAttribute("icon-invertable"),
"The tool tab does not have the invertable attribute");
@@ -60,23 +67,33 @@ function continueTests(toolbox, panel) {
let toolDefinition = toolDefinitions.get(toolId);
is(toolDefinition.id, toolId, "toolDefinition id is correct");
gDevTools.unregisterTool(toolId);
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() {
tempScope = null;
gBrowser.removeCurrentTab();
finish();
}
diff --git a/browser/devtools/framework/test/browser_new_activation_workflow.js b/browser/devtools/framework/test/browser_new_activation_workflow.js
index 16b426c..96fe179 100644
--- a/browser/devtools/framework/test/browser_new_activation_workflow.js
+++ b/browser/devtools/framework/test/browser_new_activation_workflow.js
@@ -9,38 +9,38 @@ let toolbox, target;
let tempScope = {};
function test() {
addTab("about:blank", function(aBrowser, aTab) {
target = TargetFactory.forTab(gBrowser.selectedTab);
loadWebConsole(aTab).then(function() {
console.log('loaded');
- }, console.error);
+ });
});
}
function loadWebConsole(aTab) {
ok(gDevTools, "gDevTools exists");
return gDevTools.showToolbox(target, "webconsole").then(function(aToolbox) {
toolbox = aToolbox;
checkToolLoading();
- }, console.error);
+ });
}
function checkToolLoading() {
is(toolbox.currentToolId, "webconsole", "The web console is selected");
ok(toolbox.isReady, "toolbox is ready")
selectAndCheckById("jsdebugger").then(function() {
selectAndCheckById("styleeditor").then(function() {
testToggle();
});
- }, console.error);
+ });
}
function selectAndCheckById(id) {
let doc = toolbox.frame.contentDocument;
return toolbox.selectTool(id).then(function() {
let tab = doc.getElementById("toolbox-tab-" + id);
is(tab.hasAttribute("selected"), true, "The " + id + " tab is selected");
@@ -48,18 +48,20 @@ function selectAndCheckById(id) {
}
function testToggle() {
toolbox.once("destroyed", function() {
// Cannot reuse a target after it's destroyed.
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));
toolbox.destroy();
}
function finishUp() {
toolbox.destroy().then(function() {
--
1.8.4.2