browser/devtools/canvasdebugger/test/browser_canvas-actor-test-07.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:980b5148bb6d
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Tests if screenshots for non-draw calls can still be retrieved properly,
6 * by deferring the the most recent previous draw-call.
7 */
8
9 function ifTestingSupported() {
10 let [target, debuggee, front] = yield initCanavsDebuggerBackend(SIMPLE_CANVAS_URL);
11
12 let navigated = once(target, "navigate");
13
14 yield front.setup({ reload: true });
15 ok(true, "The front was setup up successfully.");
16
17 yield navigated;
18 ok(true, "Target automatically navigated when the front was set up.");
19
20 let snapshotActor = yield front.recordAnimationFrame();
21 let animationOverview = yield snapshotActor.getOverview();
22
23 let functionCalls = animationOverview.calls;
24 ok(functionCalls,
25 "An array of function call actors was sent after recording.");
26 is(functionCalls.length, 8,
27 "The number of function call actors is correct.");
28
29 let firstNonDrawCall = yield functionCalls[1].getDetails();
30 let secondNonDrawCall = yield functionCalls[3].getDetails();
31 let lastNonDrawCall = yield functionCalls[7].getDetails();
32
33 is(firstNonDrawCall.name, "fillStyle",
34 "The first non-draw function's name is correct.");
35 is(secondNonDrawCall.name, "fillStyle",
36 "The second non-draw function's name is correct.");
37 is(lastNonDrawCall.name, "requestAnimationFrame",
38 "The last non-draw function's name is correct.");
39
40 let firstScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[1]);
41 let secondScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[3]);
42 let lastScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[7]);
43
44 ok(firstScreenshot,
45 "A screenshot was successfully retrieved for the first non-draw function.");
46 ok(secondScreenshot,
47 "A screenshot was successfully retrieved for the second non-draw function.");
48 ok(lastScreenshot,
49 "A screenshot was successfully retrieved for the last non-draw function.");
50
51 let firstActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[0]);
52 ok(sameArray(firstScreenshot.pixels, firstActualScreenshot.pixels),
53 "The screenshot for the first non-draw function is correct.");
54 is(firstScreenshot.width, 128,
55 "The screenshot for the first non-draw function has the correct width.");
56 is(firstScreenshot.height, 128,
57 "The screenshot for the first non-draw function has the correct height.");
58
59 let secondActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[2]);
60 ok(sameArray(secondScreenshot.pixels, secondActualScreenshot.pixels),
61 "The screenshot for the second non-draw function is correct.");
62 is(secondScreenshot.width, 128,
63 "The screenshot for the second non-draw function has the correct width.");
64 is(secondScreenshot.height, 128,
65 "The screenshot for the second non-draw function has the correct height.");
66
67 let lastActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[6]);
68 ok(sameArray(lastScreenshot.pixels, lastActualScreenshot.pixels),
69 "The screenshot for the last non-draw function is correct.");
70 is(lastScreenshot.width, 128,
71 "The screenshot for the last non-draw function has the correct width.");
72 is(lastScreenshot.height, 128,
73 "The screenshot for the last non-draw function has the correct height.");
74
75 ok(!sameArray(firstScreenshot.pixels, secondScreenshot.pixels),
76 "The screenshots taken on consecutive draw calls are different (1).");
77 ok(!sameArray(secondScreenshot.pixels, lastScreenshot.pixels),
78 "The screenshots taken on consecutive draw calls are different (2).");
79
80 yield removeTab(target.tab);
81 finish();
82 }
83
84 function sameArray(a, b) {
85 if (a.length != b.length) {
86 return false;
87 }
88 for (let i = 0; i < a.length; i++) {
89 if (a[i] !== b[i]) {
90 return false;
91 }
92 }
93 return true;
94 }

mercurial