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