|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if all the function calls associated with an animation frame snapshot |
|
6 * are properly displayed in the UI. |
|
7 */ |
|
8 |
|
9 function ifTestingSupported() { |
|
10 let [target, debuggee, panel] = yield initCanavsDebuggerFrontend(SIMPLE_CANVAS_URL); |
|
11 let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin; |
|
12 |
|
13 yield reload(target); |
|
14 |
|
15 let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED); |
|
16 let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED); |
|
17 SnapshotsListView._onRecordButtonClick(); |
|
18 yield promise.all([recordingFinished, callListPopulated]); |
|
19 |
|
20 is(CallsListView.itemCount, 8, |
|
21 "All the function calls should now be displayed in the UI."); |
|
22 |
|
23 testItem(CallsListView.getItemAtIndex(0), |
|
24 "1", "ctx", "clearRect", "(0, 0, 128, 128)", "doc_simple-canvas.html:25"); |
|
25 |
|
26 testItem(CallsListView.getItemAtIndex(1), |
|
27 "2", "ctx", "fillStyle", " = rgb(192, 192, 192)", "doc_simple-canvas.html:20"); |
|
28 testItem(CallsListView.getItemAtIndex(2), |
|
29 "3", "ctx", "fillRect", "(0, 0, 128, 128)", "doc_simple-canvas.html:21"); |
|
30 |
|
31 testItem(CallsListView.getItemAtIndex(3), |
|
32 "4", "ctx", "fillStyle", " = rgba(0, 0, 192, 0.5)", "doc_simple-canvas.html:20"); |
|
33 testItem(CallsListView.getItemAtIndex(4), |
|
34 "5", "ctx", "fillRect", "(30, 30, 55, 50)", "doc_simple-canvas.html:21"); |
|
35 |
|
36 testItem(CallsListView.getItemAtIndex(5), |
|
37 "6", "ctx", "fillStyle", " = rgba(192, 0, 0, 0.5)", "doc_simple-canvas.html:20"); |
|
38 testItem(CallsListView.getItemAtIndex(6), |
|
39 "7", "ctx", "fillRect", "(10, 10, 55, 50)", "doc_simple-canvas.html:21"); |
|
40 |
|
41 testItem(CallsListView.getItemAtIndex(7), |
|
42 "8", "", "requestAnimationFrame", "(Function)", "doc_simple-canvas.html:30"); |
|
43 |
|
44 function testItem(item, index, context, name, args, location) { |
|
45 let i = CallsListView.indexOfItem(item); |
|
46 is(i, index - 1, |
|
47 "The item at index " + index + " is correctly displayed in the UI."); |
|
48 |
|
49 is($(".call-item-index", item.target).getAttribute("value"), index, |
|
50 "The item's gutter label has the correct text."); |
|
51 |
|
52 if (context) { |
|
53 is($(".call-item-context", item.target).getAttribute("value"), context, |
|
54 "The item's context label has the correct text."); |
|
55 } else { |
|
56 is($(".call-item-context", item.target), null, |
|
57 "The item's context label should not be available."); |
|
58 } |
|
59 |
|
60 is($(".call-item-name", item.target).getAttribute("value"), name, |
|
61 "The item's name label has the correct text."); |
|
62 is($(".call-item-args", item.target).getAttribute("value"), args, |
|
63 "The item's args label has the correct text."); |
|
64 is($(".call-item-location", item.target).getAttribute("value"), location, |
|
65 "The item's location label has the correct text."); |
|
66 } |
|
67 |
|
68 yield teardown(panel); |
|
69 finish(); |
|
70 } |