michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests if functions calls are recorded and stored for a canvas context, michael@0: * and that their stack is successfully retrieved. michael@0: */ michael@0: michael@0: function ifTestingSupported() { michael@0: let [target, debuggee, front] = yield initCallWatcherBackend(SIMPLE_CANVAS_URL); michael@0: michael@0: let navigated = once(target, "navigate"); michael@0: michael@0: yield front.setup({ michael@0: tracedGlobals: ["CanvasRenderingContext2D", "WebGLRenderingContext"], michael@0: startRecording: true, michael@0: performReload: true michael@0: }); michael@0: ok(true, "The front was setup up successfully."); michael@0: michael@0: yield navigated; michael@0: ok(true, "Target automatically navigated when the front was set up."); michael@0: michael@0: // Allow the content to execute some functions. michael@0: yield waitForTick(); michael@0: michael@0: let functionCalls = yield front.pauseRecording(); michael@0: ok(functionCalls, michael@0: "An array of function call actors was sent after reloading."); michael@0: ok(functionCalls.length > 0, michael@0: "There's at least one function call actor available."); michael@0: michael@0: is(functionCalls[0].type, CallWatcherFront.METHOD_FUNCTION, michael@0: "The called function is correctly identified as a method."); michael@0: is(functionCalls[0].name, "clearRect", michael@0: "The called function's name is correct."); michael@0: is(functionCalls[0].file, SIMPLE_CANVAS_URL, michael@0: "The called function's file is correct."); michael@0: is(functionCalls[0].line, 25, michael@0: "The called function's line is correct."); michael@0: michael@0: is(functionCalls[0].callerPreview, "ctx", michael@0: "The called function's caller preview is correct."); michael@0: is(functionCalls[0].argsPreview, "0, 0, 128, 128", michael@0: "The called function's args preview is correct."); michael@0: michael@0: let details = yield functionCalls[1].getDetails(); michael@0: ok(details, michael@0: "The first called function has some details available.") michael@0: michael@0: is(details.stack.length, 3, michael@0: "The called function's stack depth is correct."); michael@0: michael@0: is(details.stack[0].name, "fillStyle", michael@0: "The called function's stack is correct (1.1)."); michael@0: is(details.stack[0].file, SIMPLE_CANVAS_URL, michael@0: "The called function's stack is correct (1.2)."); michael@0: is(details.stack[0].line, 20, michael@0: "The called function's stack is correct (1.3)."); michael@0: michael@0: is(details.stack[1].name, "drawRect", michael@0: "The called function's stack is correct (2.1)."); michael@0: is(details.stack[1].file, SIMPLE_CANVAS_URL, michael@0: "The called function's stack is correct (2.2)."); michael@0: is(details.stack[1].line, 26, michael@0: "The called function's stack is correct (2.3)."); michael@0: michael@0: is(details.stack[2].name, "drawScene", michael@0: "The called function's stack is correct (3.1)."); michael@0: is(details.stack[2].file, SIMPLE_CANVAS_URL, michael@0: "The called function's stack is correct (3.2)."); michael@0: is(details.stack[2].line, 33, michael@0: "The called function's stack is correct (3.3)."); michael@0: michael@0: yield removeTab(target.tab); michael@0: finish(); michael@0: }