|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if functions calls are recorded and stored for a canvas context, |
|
6 * and that their stack is successfully retrieved. |
|
7 */ |
|
8 |
|
9 function ifTestingSupported() { |
|
10 let [target, debuggee, front] = yield initCallWatcherBackend(SIMPLE_CANVAS_URL); |
|
11 |
|
12 let navigated = once(target, "navigate"); |
|
13 |
|
14 yield front.setup({ |
|
15 tracedGlobals: ["CanvasRenderingContext2D", "WebGLRenderingContext"], |
|
16 startRecording: true, |
|
17 performReload: true |
|
18 }); |
|
19 ok(true, "The front was setup up successfully."); |
|
20 |
|
21 yield navigated; |
|
22 ok(true, "Target automatically navigated when the front was set up."); |
|
23 |
|
24 // Allow the content to execute some functions. |
|
25 yield waitForTick(); |
|
26 |
|
27 let functionCalls = yield front.pauseRecording(); |
|
28 ok(functionCalls, |
|
29 "An array of function call actors was sent after reloading."); |
|
30 ok(functionCalls.length > 0, |
|
31 "There's at least one function call actor available."); |
|
32 |
|
33 is(functionCalls[0].type, CallWatcherFront.METHOD_FUNCTION, |
|
34 "The called function is correctly identified as a method."); |
|
35 is(functionCalls[0].name, "clearRect", |
|
36 "The called function's name is correct."); |
|
37 is(functionCalls[0].file, SIMPLE_CANVAS_URL, |
|
38 "The called function's file is correct."); |
|
39 is(functionCalls[0].line, 25, |
|
40 "The called function's line is correct."); |
|
41 |
|
42 is(functionCalls[0].callerPreview, "ctx", |
|
43 "The called function's caller preview is correct."); |
|
44 is(functionCalls[0].argsPreview, "0, 0, 128, 128", |
|
45 "The called function's args preview is correct."); |
|
46 |
|
47 let details = yield functionCalls[1].getDetails(); |
|
48 ok(details, |
|
49 "The first called function has some details available.") |
|
50 |
|
51 is(details.stack.length, 3, |
|
52 "The called function's stack depth is correct."); |
|
53 |
|
54 is(details.stack[0].name, "fillStyle", |
|
55 "The called function's stack is correct (1.1)."); |
|
56 is(details.stack[0].file, SIMPLE_CANVAS_URL, |
|
57 "The called function's stack is correct (1.2)."); |
|
58 is(details.stack[0].line, 20, |
|
59 "The called function's stack is correct (1.3)."); |
|
60 |
|
61 is(details.stack[1].name, "drawRect", |
|
62 "The called function's stack is correct (2.1)."); |
|
63 is(details.stack[1].file, SIMPLE_CANVAS_URL, |
|
64 "The called function's stack is correct (2.2)."); |
|
65 is(details.stack[1].line, 26, |
|
66 "The called function's stack is correct (2.3)."); |
|
67 |
|
68 is(details.stack[2].name, "drawScene", |
|
69 "The called function's stack is correct (3.1)."); |
|
70 is(details.stack[2].file, SIMPLE_CANVAS_URL, |
|
71 "The called function's stack is correct (3.2)."); |
|
72 is(details.stack[2].line, 33, |
|
73 "The called function's stack is correct (3.3)."); |
|
74 |
|
75 yield removeTab(target.tab); |
|
76 finish(); |
|
77 } |