forked from jsantell/firefox-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1111020-fix-key-events.patch
228 lines (213 loc) · 8.5 KB
/
1111020-fix-key-events.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
From: Jordan Santell <[email protected]>
Date: Fri, 6 Feb 2015 13:28:55 -0800
Subject: Bug 1111020 - Fix key events in perf tool's call trees. r=vp
diff --git a/browser/devtools/performance/test/browser.ini b/browser/devtools/performance/test/browser.ini
index 5bcc986..1982286 100644
--- a/browser/devtools/performance/test/browser.ini
+++ b/browser/devtools/performance/test/browser.ini
@@ -17,16 +17,17 @@ support-files =
[browser_perf-details-calltree-render.js]
[browser_perf-details-flamegraph-render.js]
[browser_perf-details-memory-calltree-render.js]
[browser_perf-details-memory-flamegraph-render.js]
[browser_perf-details-waterfall-render.js]
[browser_perf-details-01.js]
[browser_perf-details-02.js]
[browser_perf-details-03.js]
+[browser_perf-events-calltree.js]
[browser_perf-front-basic-profiler-01.js]
[browser_perf-front-basic-timeline-01.js]
#[browser_perf-front-profiler-01.js] bug 1077464
[browser_perf-front-profiler-02.js]
[browser_perf-front-profiler-03.js]
[browser_perf-front-profiler-04.js]
#[browser_perf-front-profiler-05.js] bug 1077464
#[browser_perf-front-profiler-06.js]
diff --git a/browser/devtools/performance/test/browser_perf-events-calltree.js b/browser/devtools/performance/test/browser_perf-events-calltree.js
new file mode 100644
index 0000000..f006f09
--- /dev/null
+++ b/browser/devtools/performance/test/browser_perf-events-calltree.js
@@ -0,0 +1,79 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that the call tree up/down events work for js calltree and memory calltree.
+ */
+let { ThreadNode } = devtools.require("devtools/profiler/tree-model");
+function spawnTest () {
+ let focus = 0;
+ let focusEvent = () => focus++;
+
+ Services.prefs.setBoolPref(MEMORY_PREF, true);
+
+ let { panel } = yield initPerformance(SIMPLE_URL);
+ let { EVENTS, $, DetailsView, JsCallTreeView, MemoryCallTreeView } = panel.panelWin;
+
+ yield DetailsView.selectView("js-calltree");
+ ok(DetailsView.isViewSelected(JsCallTreeView), "The call tree is now selected.");
+
+ // Make a recording just so the performance tool is in the correct state
+ yield startRecording(panel);
+ let rendered = once(JsCallTreeView, EVENTS.JS_CALL_TREE_RENDERED);
+ yield stopRecording(panel);
+ yield rendered;
+
+ // Mock the profile used so we can get a deterministic tree created
+ let threadNode = new ThreadNode(gSamples);
+ JsCallTreeView._populateCallTree(threadNode);
+ JsCallTreeView.emit(EVENTS.JS_CALL_TREE_RENDERED);
+
+ JsCallTreeView.on("focus", focusEvent);
+
+ click(panel.panelWin, $("#js-calltree-view .call-tree-item"));
+ fireKey("VK_DOWN");
+ fireKey("VK_DOWN");
+ fireKey("VK_DOWN");
+ fireKey("VK_DOWN");
+
+ JsCallTreeView.off("focus", focusEvent);
+
+ is(focus, 4, "several focus events are fired for the js calltree.");
+
+ yield teardown(panel);
+ finish();
+};
+
+let gSamples = [{
+ time: 5,
+ frames: [
+ { category: 8, location: "(root)" },
+ { category: 8, location: "A (http://foo/bar/baz:12)" },
+ { category: 16, location: "B (http://foo/bar/baz:34)" },
+ { category: 32, location: "C (http://foo/bar/baz:56)" }
+ ]
+}, {
+ time: 5 + 1,
+ frames: [
+ { category: 8, location: "(root)" },
+ { category: 8, location: "A (http://foo/bar/baz:12)" },
+ { category: 16, location: "B (http://foo/bar/baz:34)" },
+ { category: 64, location: "D (http://foo/bar/baz:78)" }
+ ]
+}, {
+ time: 5 + 1 + 2,
+ frames: [
+ { category: 8, location: "(root)" },
+ { category: 8, location: "A (http://foo/bar/baz:12)" },
+ { category: 16, location: "B (http://foo/bar/baz:34)" },
+ { category: 64, location: "D (http://foo/bar/baz:78)" }
+ ]
+}, {
+ time: 5 + 1 + 2 + 7,
+ frames: [
+ { category: 8, location: "(root)" },
+ { category: 8, location: "A (http://foo/bar/baz:12)" },
+ { category: 128, location: "E (http://foo/bar/baz:90)" },
+ { category: 256, location: "F (http://foo/bar/baz:99)" }
+ ]
+}];
diff --git a/browser/devtools/performance/test/head.js b/browser/devtools/performance/test/head.js
index 760b6bd..be905b5 100644
--- a/browser/devtools/performance/test/head.js
+++ b/browser/devtools/performance/test/head.js
@@ -386,8 +386,15 @@ function dropSelection(graph) {
graph.dropSelection();
graph.emit("selecting");
}
function getSourceActor(aSources, aURL) {
let item = aSources.getItemForAttachment(a => a.source.url === aURL);
return item && item.value;
}
+
+/**
+ * Fires a key event, like "VK_UP", "VK_DOWN", etc.
+ */
+function fireKey (e) {
+ EventUtils.synthesizeKey(e, {});
+}
diff --git a/browser/devtools/performance/views/details-js-call-tree.js b/browser/devtools/performance/views/details-js-call-tree.js
index 0d7a176..4e87a82 100644
--- a/browser/devtools/performance/views/details-js-call-tree.js
+++ b/browser/devtools/performance/views/details-js-call-tree.js
@@ -90,16 +90,19 @@ let JsCallTreeView = Heritage.extend(DetailsSubview, {
// Call trees should only auto-expand when not inverted. Passing undefined
// will default to the CALL_TREE_AUTO_EXPAND depth.
autoExpandDepth: options.inverted ? 0 : undefined,
});
// Bind events.
root.on("link", this._onLink);
+ // Pipe "focus" events to the view, mostly for tests
+ root.on("focus", () => this.emit("focus"));
+
// Clear out other call trees.
let container = $("#js-calltree-view > .call-tree-cells-container");
container.innerHTML = "";
root.attachTo(container);
// Profiler data does not contain memory allocations information.
root.toggleAllocations(false);
diff --git a/browser/devtools/performance/views/details-memory-call-tree.js b/browser/devtools/performance/views/details-memory-call-tree.js
index 802a746..4119593 100644
--- a/browser/devtools/performance/views/details-memory-call-tree.js
+++ b/browser/devtools/performance/views/details-memory-call-tree.js
@@ -89,16 +89,19 @@ let MemoryCallTreeView = Heritage.extend(DetailsSubview, {
// Call trees should only auto-expand when not inverted. Passing undefined
// will default to the CALL_TREE_AUTO_EXPAND depth.
autoExpandDepth: options.inverted ? 0 : undefined,
});
// Bind events.
root.on("link", this._onLink);
+ // Pipe "focus" events to the view, mostly for tests
+ root.on("focus", () => this.emit("focus"));
+
// Clear out other call trees.
let container = $("#memory-calltree-view > .call-tree-cells-container");
container.innerHTML = "";
root.attachTo(container);
// Memory allocation samples don't contain cateogry labels.
root.toggleCategories(false);
},
diff --git a/browser/devtools/performance/views/details-waterfall.js b/browser/devtools/performance/views/details-waterfall.js
index 7836e00..66f4e6f 100644
--- a/browser/devtools/performance/views/details-waterfall.js
+++ b/browser/devtools/performance/views/details-waterfall.js
@@ -11,17 +11,17 @@ let WaterfallView = Heritage.extend(DetailsSubview, {
rangeChangeDebounceTime: 10, // ms
/**
* Sets up the view with event binding.
*/
initialize: function () {
DetailsSubview.initialize.call(this);
- this.waterfall = new Waterfall($("#waterfall-breakdown"), $("#details-pane"), TIMELINE_BLUEPRINT);
+ this.waterfall = new Waterfall($("#waterfall-breakdown"), $("#waterfall-view"), TIMELINE_BLUEPRINT);
this.details = new MarkerDetails($("#waterfall-details"), $("#waterfall-view > splitter"));
this._onMarkerSelected = this._onMarkerSelected.bind(this);
this._onResize = this._onResize.bind(this);
this.waterfall.on("selected", this._onMarkerSelected);
this.waterfall.on("unselected", this._onMarkerSelected);
this.details.on("resize", this._onResize);
diff --git a/browser/devtools/timeline/widgets/waterfall.js b/browser/devtools/timeline/widgets/waterfall.js
index 7a218d1..50f831e 100644
--- a/browser/devtools/timeline/widgets/waterfall.js
+++ b/browser/devtools/timeline/widgets/waterfall.js
@@ -125,17 +125,17 @@ Waterfall.prototype = {
this._blueprint = blueprint;
},
/**
* Keybindings.
*/
setupKeys: function() {
let pane = this._container;
- pane.parentNode.parentNode.addEventListener("keydown", e => {
+ pane.addEventListener("keydown", e => {
if (e.keyCode === Ci.nsIDOMKeyEvent.DOM_VK_UP) {
e.preventDefault();
this.selectNearestRow(this._selectedRowIdx - 1);
}
if (e.keyCode === Ci.nsIDOMKeyEvent.DOM_VK_DOWN) {
e.preventDefault();
this.selectNearestRow(this._selectedRowIdx + 1);
}
--
2.2.1