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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/canvasdebugger/test/browser_canvas-actor-test-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,77 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Tests if functions calls are recorded and stored for a canvas context,
     1.9 + * and that their stack is successfully retrieved.
    1.10 + */
    1.11 +
    1.12 +function ifTestingSupported() {
    1.13 +  let [target, debuggee, front] = yield initCallWatcherBackend(SIMPLE_CANVAS_URL);
    1.14 +
    1.15 +  let navigated = once(target, "navigate");
    1.16 +
    1.17 +  yield front.setup({
    1.18 +    tracedGlobals: ["CanvasRenderingContext2D", "WebGLRenderingContext"],
    1.19 +    startRecording: true,
    1.20 +    performReload: true
    1.21 +  });
    1.22 +  ok(true, "The front was setup up successfully.");
    1.23 +
    1.24 +  yield navigated;
    1.25 +  ok(true, "Target automatically navigated when the front was set up.");
    1.26 +
    1.27 +  // Allow the content to execute some functions.
    1.28 +  yield waitForTick();
    1.29 +
    1.30 +  let functionCalls = yield front.pauseRecording();
    1.31 +  ok(functionCalls,
    1.32 +    "An array of function call actors was sent after reloading.");
    1.33 +  ok(functionCalls.length > 0,
    1.34 +    "There's at least one function call actor available.");
    1.35 +
    1.36 +  is(functionCalls[0].type, CallWatcherFront.METHOD_FUNCTION,
    1.37 +    "The called function is correctly identified as a method.");
    1.38 +  is(functionCalls[0].name, "clearRect",
    1.39 +    "The called function's name is correct.");
    1.40 +  is(functionCalls[0].file, SIMPLE_CANVAS_URL,
    1.41 +    "The called function's file is correct.");
    1.42 +  is(functionCalls[0].line, 25,
    1.43 +    "The called function's line is correct.");
    1.44 +
    1.45 +  is(functionCalls[0].callerPreview, "ctx",
    1.46 +    "The called function's caller preview is correct.");
    1.47 +  is(functionCalls[0].argsPreview, "0, 0, 128, 128",
    1.48 +    "The called function's args preview is correct.");
    1.49 +
    1.50 +  let details = yield functionCalls[1].getDetails();
    1.51 +  ok(details,
    1.52 +    "The first called function has some details available.")
    1.53 +
    1.54 +  is(details.stack.length, 3,
    1.55 +    "The called function's stack depth is correct.");
    1.56 +
    1.57 +  is(details.stack[0].name, "fillStyle",
    1.58 +    "The called function's stack is correct (1.1).");
    1.59 +  is(details.stack[0].file, SIMPLE_CANVAS_URL,
    1.60 +    "The called function's stack is correct (1.2).");
    1.61 +  is(details.stack[0].line, 20,
    1.62 +    "The called function's stack is correct (1.3).");
    1.63 +
    1.64 +  is(details.stack[1].name, "drawRect",
    1.65 +    "The called function's stack is correct (2.1).");
    1.66 +  is(details.stack[1].file, SIMPLE_CANVAS_URL,
    1.67 +    "The called function's stack is correct (2.2).");
    1.68 +  is(details.stack[1].line, 26,
    1.69 +    "The called function's stack is correct (2.3).");
    1.70 +
    1.71 +  is(details.stack[2].name, "drawScene",
    1.72 +    "The called function's stack is correct (3.1).");
    1.73 +  is(details.stack[2].file, SIMPLE_CANVAS_URL,
    1.74 +    "The called function's stack is correct (3.2).");
    1.75 +  is(details.stack[2].line, 33,
    1.76 +    "The called function's stack is correct (3.3).");
    1.77 +
    1.78 +  yield removeTab(target.tab);
    1.79 +  finish();
    1.80 +}

mercurial