browser/devtools/canvasdebugger/test/browser_canvas-actor-test-03.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-03.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     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 inside a single animation frame are recorded and stored
     1.9 + * for a canvas context.
    1.10 + */
    1.11 +
    1.12 +function ifTestingSupported() {
    1.13 +  let [target, debuggee, front] = yield initCanavsDebuggerBackend(SIMPLE_CANVAS_URL);
    1.14 +
    1.15 +  let navigated = once(target, "navigate");
    1.16 +
    1.17 +  yield front.setup({ reload: true });
    1.18 +  ok(true, "The front was setup up successfully.");
    1.19 +
    1.20 +  yield navigated;
    1.21 +  ok(true, "Target automatically navigated when the front was set up.");
    1.22 +
    1.23 +  let snapshotActor = yield front.recordAnimationFrame();
    1.24 +  ok(snapshotActor,
    1.25 +    "A snapshot actor was sent after recording.");
    1.26 +
    1.27 +  let animationOverview = yield snapshotActor.getOverview();
    1.28 +  ok(snapshotActor,
    1.29 +    "An animation overview could be retrieved after recording.");
    1.30 +
    1.31 +  let functionCalls = animationOverview.calls;
    1.32 +  ok(functionCalls,
    1.33 +    "An array of function call actors was sent after recording.");
    1.34 +  is(functionCalls.length, 8,
    1.35 +    "The number of function call actors is correct.");
    1.36 +
    1.37 +  is(functionCalls[0].type, CallWatcherFront.METHOD_FUNCTION,
    1.38 +    "The first called function is correctly identified as a method.");
    1.39 +  is(functionCalls[0].name, "clearRect",
    1.40 +    "The first called function's name is correct.");
    1.41 +  is(functionCalls[0].file, SIMPLE_CANVAS_URL,
    1.42 +    "The first called function's file is correct.");
    1.43 +  is(functionCalls[0].line, 25,
    1.44 +    "The first called function's line is correct.");
    1.45 +  is(functionCalls[0].argsPreview, "0, 0, 128, 128",
    1.46 +    "The first called function's args preview is correct.");
    1.47 +  is(functionCalls[0].callerPreview, "ctx",
    1.48 +    "The first called function's caller preview is correct.");
    1.49 +
    1.50 +  is(functionCalls[6].type, CallWatcherFront.METHOD_FUNCTION,
    1.51 +    "The penultimate called function is correctly identified as a method.");
    1.52 +  is(functionCalls[6].name, "fillRect",
    1.53 +    "The penultimate called function's name is correct.");
    1.54 +  is(functionCalls[6].file, SIMPLE_CANVAS_URL,
    1.55 +    "The penultimate called function's file is correct.");
    1.56 +  is(functionCalls[6].line, 21,
    1.57 +    "The penultimate called function's line is correct.");
    1.58 +  is(functionCalls[6].argsPreview, "10, 10, 55, 50",
    1.59 +    "The penultimate called function's args preview is correct.");
    1.60 +  is(functionCalls[6].callerPreview, "ctx",
    1.61 +    "The penultimate called function's caller preview is correct.");
    1.62 +
    1.63 +  is(functionCalls[7].type, CallWatcherFront.METHOD_FUNCTION,
    1.64 +    "The last called function is correctly identified as a method.");
    1.65 +  is(functionCalls[7].name, "requestAnimationFrame",
    1.66 +    "The last called function's name is correct.");
    1.67 +  is(functionCalls[7].file, SIMPLE_CANVAS_URL,
    1.68 +    "The last called function's file is correct.");
    1.69 +  is(functionCalls[7].line, 30,
    1.70 +    "The last called function's line is correct.");
    1.71 +  ok(functionCalls[7].argsPreview.contains("Function"),
    1.72 +    "The last called function's args preview is correct.");
    1.73 +  is(functionCalls[7].callerPreview, "",
    1.74 +    "The last called function's caller preview is correct.");
    1.75 +
    1.76 +  yield removeTab(target.tab);
    1.77 +  finish();
    1.78 +}

mercurial