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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests if the profiler can correctly handle sequential console recordings,
* finished in reverse order, and the second call to `console.profileEnd`
* contains the same label as the first call.
*/
let test = Task.async(function*() {
let [target, debuggee, panel] = yield initFrontend(SIMPLE_URL);
let { $, EVENTS, gFront, RecordingsListView, ProfileView } = panel.panelWin;
yield consoleProfile(gFront, "1");
yield consoleProfile(gFront, "2");
let firstRecordingDisplayed = panel.panelWin.once(EVENTS.RECORDING_DISPLAYED);
yield consoleProfileEnd(gFront, "1");
yield firstRecordingDisplayed;
ok(true, "The newly finished console recording was automatically displayed.");
is(RecordingsListView.itemCount, 2,
"There should be two recordings visible.");
is(RecordingsListView.items[0], RecordingsListView.selectedItem,
"The first recording item should be selected.");
is(RecordingsListView.items[0].attachment.profilerData.profileLabel, "1",
"The profile label for the first recording is correct.");
ok(!RecordingsListView.items[0].isRecording,
"The 'isRecording' flag for the first recording is correct.");
is(RecordingsListView.items[1].attachment.profilerData.profileLabel, "2",
"The profile label for the second recording is correct.");
ok(RecordingsListView.items[1].isRecording,
"The 'isRecording' flag for the second recording is correct.");
gFront.once("profileEnd", () => {
ok(false, "The second console recording shouldn't have ended.")
});
panel.panelWin.once(EVENTS.RECORDING_DISPLAYED, () => {
ok(false, "The second console recording shouldn't have been displayed.");
});
console.profileEnd("1");
yield DevToolsUtils.waitForTime(1000);
yield teardown(panel);
finish();
});
function* consoleProfile(front, label) {
let notified = front.once("profile");
console.profile(label);
yield notified;
}
function* consoleProfileEnd(front, label) {
let notified = front.once("profileEnd");
console.profileEnd(label);
yield notified;
}
|