-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1058898-perf-e10s.patch
442 lines (390 loc) · 16.9 KB
/
1058898-perf-e10s.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
From: Jordan Santell <[email protected]>
Date: Sun, 10 May 2015 01:20:56 -0700
Subject: Bug 1058898 - Enable e10s tests on the performance tool. r=vp
diff --git a/browser/devtools/performance/test/browser.ini b/browser/devtools/performance/test/browser.ini
index 428e558..6f8f20f 100644
--- a/browser/devtools/performance/test/browser.ini
+++ b/browser/devtools/performance/test/browser.ini
@@ -1,23 +1,23 @@
[DEFAULT]
tags = devtools
-skip-if = e10s # Handle in Bug 1077464 for profiler
subsuite = devtools
support-files =
doc_innerHTML.html
doc_simple-test.html
head.js
# Commented out tests are profiler tests
# that need to be moved over to performance tool
-[browser_perf-aaa-run-first-leaktest.js]
+[browser_aaa-run-first-leaktest.js]
[browser_marker-utils.js]
[browser_markers-gc.js]
+skip-if = e10s # GC events seem unreliable in multiprocess
[browser_markers-parse-html.js]
[browser_markers-styles.js]
[browser_markers-timestamp.js]
[browser_perf-allocations-to-samples.js]
[browser_perf-categories-js-calltree.js]
[browser_perf-compatibility-01.js]
[browser_perf-compatibility-02.js]
[browser_perf-compatibility-03.js]
diff --git a/browser/devtools/performance/test/browser_perf-aaa-run-first-leaktest.js b/browser/devtools/performance/test/browser_aaa-run-first-leaktest.js
similarity index 100%
rename from browser/devtools/performance/test/browser_perf-aaa-run-first-leaktest.js
rename to browser/devtools/performance/test/browser_aaa-run-first-leaktest.js
diff --git a/browser/devtools/performance/test/browser_perf-front-profiler-02.js b/browser/devtools/performance/test/browser_perf-front-profiler-02.js
index 04bf949..86ecf0f 100644
--- a/browser/devtools/performance/test/browser_perf-front-profiler-02.js
+++ b/browser/devtools/performance/test/browser_perf-front-profiler-02.js
@@ -5,33 +5,37 @@
* Tests if the profiler connection front does not activate the built-in
* profiler module if not necessary, and doesn't deactivate it when
* a recording is stopped.
*/
let test = Task.async(function*() {
let { target, panel, toolbox } = yield initPerformance(SIMPLE_URL);
let front = panel.panelWin.gFront;
+ loadFrameScripts();
- ok(!nsIProfilerModule.IsActive(),
+ ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should not have been automatically started.");
let activated = front.once("profiler-activated");
let rec = yield front.startRecording();
yield activated;
yield front.stopRecording(rec);
- ok(nsIProfilerModule.IsActive(),
+ ok((yield PMM_isProfilerActive()),
"The built-in profiler module should still be active (1).");
let alreadyActive = front.once("profiler-already-active");
rec = yield front.startRecording();
yield alreadyActive;
yield front.stopRecording(rec);
- ok(nsIProfilerModule.IsActive(),
+ ok((yield PMM_isProfilerActive()),
"The built-in profiler module should still be active (2).");
- yield teardown(panel);
-
- ok(!nsIProfilerModule.IsActive(),
- "The built-in profiler module should have been automatically stoped.");
+ // Manually tear down so we can check profiler status
+ let tab = panel.target.tab;
+ yield panel._toolbox.destroy();
+ ok(!(yield PMM_isProfilerActive()),
+ "The built-in profiler module should no longer be active.");
+ yield removeTab(tab);
+ tab = null;
finish();
});
diff --git a/browser/devtools/performance/test/browser_perf-front-profiler-03.js b/browser/devtools/performance/test/browser_perf-front-profiler-03.js
index c93c3a7..2244af0 100644
--- a/browser/devtools/performance/test/browser_perf-front-profiler-03.js
+++ b/browser/devtools/performance/test/browser_perf-front-profiler-03.js
@@ -11,23 +11,30 @@ let test = Task.async(function*() {
let firstFront = firstPanel.panelWin.gFront;
let activated = firstFront.once("profiler-activated");
yield firstFront.startRecording();
yield activated;
let { panel: secondPanel } = yield initPerformance(SIMPLE_URL);
let secondFront = secondPanel.panelWin.gFront;
+ loadFrameScripts();
let alreadyActive = secondFront.once("profiler-already-active");
yield secondFront.startRecording();
yield alreadyActive;
- yield teardown(firstPanel);
- ok(nsIProfilerModule.IsActive(),
+ // Manually teardown the tabs so we can check profiler status
+ let tab1 = firstPanel.target.tab;
+ let tab2 = secondPanel.target.tab;
+ yield firstPanel._toolbox.destroy();
+ yield removeTab(tab1);
+ ok((yield PMM_isProfilerActive()),
"The built-in profiler module should still be active.");
- yield teardown(secondPanel);
- ok(!nsIProfilerModule.IsActive(),
- "The built-in profiler module should have been automatically stoped.");
+ yield secondPanel._toolbox.destroy();
+ ok(!(yield PMM_isProfilerActive()),
+ "The built-in profiler module should no longer be active.");
+ yield removeTab(tab2);
+ tab1 = tab2 = null;
finish();
});
diff --git a/browser/devtools/performance/test/browser_perf-front-profiler-04.js b/browser/devtools/performance/test/browser_perf-front-profiler-04.js
index 470fb5a..2993e22 100644
--- a/browser/devtools/performance/test/browser_perf-front-profiler-04.js
+++ b/browser/devtools/performance/test/browser_perf-front-profiler-04.js
@@ -5,20 +5,21 @@
* Tests if the built-in profiler module is not reactivated if no other
* consumer was using it over the remote debugger protocol, and ensures
* that the actor will work properly even in such cases (e.g. the Gecko Profiler
* addon was installed and automatically activated the profiler module).
*/
let test = Task.async(function*() {
// Ensure the profiler is already running when the test starts.
+ loadFrameScripts();
let ENTRIES = 1000000;
let INTERVAL = 1;
let FEATURES = ["js"];
- nsIProfilerModule.StartProfiler(ENTRIES, INTERVAL, FEATURES, FEATURES.length);
+ yield sendProfilerCommand("StartProfiler", [ENTRIES, INTERVAL, FEATURES, FEATURES.length]);
let { panel: firstPanel } = yield initPerformance(SIMPLE_URL);
let firstFront = firstPanel.panelWin.gFront;
let firstAlreadyActive = firstFront.once("profiler-already-active");
let recording = yield firstFront.startRecording();
yield firstAlreadyActive;
ok(recording._profilerStartTime > 0, "The profiler was not restarted.");
@@ -27,17 +28,17 @@ let test = Task.async(function*() {
let secondFront = secondPanel.panelWin.gFront;
let secondAlreadyActive = secondFront.once("profiler-already-active");
let secondRecording = yield secondFront.startRecording();
yield secondAlreadyActive;
ok(secondRecording._profilerStartTime > 0, "The profiler was not restarted.");
yield teardown(firstPanel);
- ok(nsIProfilerModule.IsActive(),
+ ok((yield PMM_isProfilerActive()),
"The built-in profiler module should still be active.");
yield teardown(secondPanel);
- ok(!nsIProfilerModule.IsActive(),
+ ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should have been automatically stoped.");
finish();
});
diff --git a/browser/devtools/performance/test/browser_perf-recording-notices-04.js b/browser/devtools/performance/test/browser_perf-recording-notices-04.js
index 6a3cd64..0b9ba30 100644
--- a/browser/devtools/performance/test/browser_perf-recording-notices-04.js
+++ b/browser/devtools/performance/test/browser_perf-recording-notices-04.js
@@ -1,23 +1,24 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests that when a recording overlaps the circular buffer, that
* a class is assigned to the recording notices.
*/
function spawnTest () {
- // Make sure the profiler module is stopped so we can set a new buffer limit
- nsIProfilerModule.StopProfiler();
- Services.prefs.setIntPref(PROFILER_BUFFER_SIZE_PREF, 1000);
-
let { panel } = yield initPerformance(SIMPLE_URL, void 0, { TEST_MOCK_PROFILER_CHECK_TIMER: 10 });
let { EVENTS, $, PerformanceController, PerformanceView } = panel.panelWin;
+ // Make sure the profiler module is stopped so we can set a new buffer limit
+ loadFrameScripts();
+ yield PMM_stopProfiler();
+ Services.prefs.setIntPref(PROFILER_BUFFER_SIZE_PREF, 1000);
+
yield startRecording(panel);
let percent = 0;
while (percent < 100) {
[,percent] = yield onceSpread(PerformanceView, EVENTS.UI_BUFFER_UPDATED);
}
let bufferUsage = PerformanceController.getCurrentRecording().getBufferUsage();
diff --git a/browser/devtools/performance/test/browser_perf-shared-connection-03.js b/browser/devtools/performance/test/browser_perf-shared-connection-03.js
index 4db576b..e0d0dde 100644
--- a/browser/devtools/performance/test/browser_perf-shared-connection-03.js
+++ b/browser/devtools/performance/test/browser_perf-shared-connection-03.js
@@ -4,26 +4,28 @@
/**
* Tests if the shared PerformanceActorsConnection can properly send requests.
*/
function spawnTest () {
let { panel } = yield initPerformance(SIMPLE_URL);
let front = panel.panelWin.gFront;
- ok(!nsIProfilerModule.IsActive(),
+ loadFrameScripts();
+
+ ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should not have been automatically started.");
let result = yield front._request("profiler", "startProfiler");
is(result.started, true,
"The request finished successfully and the profiler should've been started.");
- ok(nsIProfilerModule.IsActive(),
+ ok((yield PMM_isProfilerActive()),
"The built-in profiler module should now be active.");
result = yield front._request("profiler", "stopProfiler");
is(result.started, false,
"The request finished successfully and the profiler should've been stopped.");
- ok(!nsIProfilerModule.IsActive(),
+ ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should now be inactive.");
yield teardown(panel);
finish();
}
diff --git a/browser/devtools/performance/test/browser_perf-ui-recording.js b/browser/devtools/performance/test/browser_perf-ui-recording.js
index e876d94..4513cd6 100644
--- a/browser/devtools/performance/test/browser_perf-ui-recording.js
+++ b/browser/devtools/performance/test/browser_perf-ui-recording.js
@@ -6,26 +6,27 @@
* in the UI.
*/
let WAIT_TIME = 10;
function spawnTest () {
let { panel } = yield initPerformance(SIMPLE_URL);
let { EVENTS, PerformanceController } = panel.panelWin;
let front = panel.panelWin.gFront;
+ loadFrameScripts();
- ok(!nsIProfilerModule.IsActive(),
+ ok(!(yield PMM_isProfilerActive()),
"The built-in profiler module should not have been automatically started.");
yield startRecording(panel);
busyWait(WAIT_TIME); // allow the profiler module to sample some cpu activity
- ok(nsIProfilerModule.IsActive(),
+ ok((yield PMM_isProfilerActive()),
"The built-in profiler module should now be active.");
yield stopRecording(panel);
- ok(nsIProfilerModule.IsActive(),
+ ok((yield PMM_isProfilerActive()),
"The built-in profiler module should still be active.");
yield teardown(panel);
finish();
}
diff --git a/browser/devtools/performance/test/head.js b/browser/devtools/performance/test/head.js
index 4dd4e9a..88cce8f 100644
--- a/browser/devtools/performance/test/head.js
+++ b/browser/devtools/performance/test/head.js
@@ -8,20 +8,20 @@ let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
let { Preferences } = Cu.import("resource://gre/modules/Preferences.jsm", {});
let { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
let { Promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
let { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let { DevToolsUtils } = Cu.import("resource://gre/modules/devtools/DevToolsUtils.jsm", {});
let { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
let { merge } = devtools.require("sdk/util/object");
+let { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
let { getPerformanceActorsConnection, PerformanceFront } = devtools.require("devtools/performance/front");
-
-let nsIProfilerModule = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
let TargetFactory = devtools.TargetFactory;
+
let mm = null;
const FRAME_SCRIPT_UTILS_URL = "chrome://browser/content/devtools/frame-script-utils.js"
const EXAMPLE_URL = "http://example.com/browser/browser/devtools/performance/test/";
const SIMPLE_URL = EXAMPLE_URL + "doc_simple-test.html";
const MEMORY_SAMPLE_PROB_PREF = "devtools.performance.memory.sample-probability";
const MEMORY_MAX_LOG_LEN_PREF = "devtools.performance.memory.max-log-length";
@@ -66,37 +66,32 @@ let DEFAULT_PREFS = [
// Enable the new performance panel for all tests.
Services.prefs.setBoolPref("devtools.performance.enabled", true);
// Enable logging for all the tests. Both the debugger server and frontend will
// be affected by this pref.
Services.prefs.setBoolPref("devtools.debugger.log", false);
/**
* Call manually in tests that use frame script utils after initializing
- * the tool. Must be called after initializing so we can detect
- * whether or not `content` is a CPOW or not. Call after init but before navigating
- * to different pages.
+ * the tool. Must be called after initializing (once we have a tab).
*/
function loadFrameScripts () {
mm = gBrowser.selectedBrowser.messageManager;
mm.loadFrameScript(FRAME_SCRIPT_UTILS_URL, false);
}
registerCleanupFunction(() => {
gDevTools.testing = false;
info("finish() was called, cleaning up...");
// Rollback any pref changes
Object.keys(DEFAULT_PREFS).forEach(pref => {
Preferences.set(pref, DEFAULT_PREFS[pref]);
});
- // Make sure the profiler module is stopped when the test finishes.
- nsIProfilerModule.StopProfiler();
-
Cu.forceGC();
});
function addTab(aUrl, aWindow) {
info("Adding tab: " + aUrl);
let deferred = Promise.defer();
let targetWindow = aWindow || window;
@@ -572,8 +567,44 @@ function synthesizeProfileForTest(samples) {
});
let uniqueStacks = new RecordingUtils.UniqueStacks();
return RecordingUtils.deflateThread({
samples: samples,
markers: []
}, uniqueStacks);
}
+
+function PMM_isProfilerActive () {
+ return sendProfilerCommand("IsActive");
+}
+
+function PMM_stopProfiler () {
+ return Task.spawn(function*() {
+ let isActive = (yield sendProfilerCommand("IsActive")).isActive;
+ if (isActive) {
+ return sendProfilerCommand("StopProfiler");
+ }
+ });
+}
+
+function sendProfilerCommand (method, args=[]) {
+ let deferred = Promise.defer();
+
+ if (!mm) {
+ throw new Error("`loadFrameScripts()` must be called when using MessageManager.");
+ }
+
+ let id = generateUUID().toString();
+ mm.addMessageListener("devtools:test:profiler:response", handler);
+ mm.sendAsyncMessage("devtools:test:profiler", { method, args, id });
+
+ function handler ({ data }) {
+ if (id !== data.id) {
+ return;
+ }
+
+ mm.removeMessageListener("devtools:test:profiler:response", handler);
+ deferred.resolve(data.data);
+ }
+
+ return deferred.promise;
+}
diff --git a/browser/devtools/shared/frame-script-utils.js b/browser/devtools/shared/frame-script-utils.js
index aeee2a6..65dbd9b 100644
--- a/browser/devtools/shared/frame-script-utils.js
+++ b/browser/devtools/shared/frame-script-utils.js
@@ -6,16 +6,19 @@
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
devtools.lazyImporter(this, "promise", "resource://gre/modules/Promise.jsm", "Promise");
devtools.lazyImporter(this, "Task", "resource://gre/modules/Task.jsm", "Task");
const loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader);
let EventUtils = {};
loader.loadSubScript("chrome://marionette/content/EventUtils.js", EventUtils);
+devtools.lazyGetter(this, "nsIProfilerModule", () => {
+ return Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
+});
addMessageListener("devtools:test:history", function ({ data }) {
content.history[data.direction]();
});
addMessageListener("devtools:test:navigate", function ({ data }) {
content.location = data.location;
});
@@ -98,16 +101,25 @@ addMessageListener("devtools:test:xhr", Task.async(function* ({ data }) {
for (let request of requests) {
let response = yield promiseXHR(request);
responses.push(response);
}
sendAsyncMessage("devtools:test:xhr", responses);
}));
+addMessageListener("devtools:test:profiler", function ({ data: { method, args, id }}) {
+ let result = nsIProfilerModule[method](...args);
+ sendAsyncMessage("devtools:test:profiler:response", {
+ data: result,
+ id: id
+ });
+});
+
+
// To eval in content, look at `evalInDebuggee` in the head.js of canvasdebugger
// for an example.
addMessageListener("devtools:test:eval", function ({ data }) {
sendAsyncMessage("devtools:test:eval:response", {
value: content.eval(data.script),
id: data.id
});
});
--
2.2.1