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