browser/devtools/canvasdebugger/test/browser_canvas-frontend-call-list.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-frontend-call-list.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,70 @@
     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 all the function calls associated with an animation frame snapshot
     1.9 + * are properly displayed in the UI.
    1.10 + */
    1.11 +
    1.12 +function ifTestingSupported() {
    1.13 +  let [target, debuggee, panel] = yield initCanavsDebuggerFrontend(SIMPLE_CANVAS_URL);
    1.14 +  let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
    1.15 +
    1.16 +  yield reload(target);
    1.17 +
    1.18 +  let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
    1.19 +  let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
    1.20 +  SnapshotsListView._onRecordButtonClick();
    1.21 +  yield promise.all([recordingFinished, callListPopulated]);
    1.22 +
    1.23 +  is(CallsListView.itemCount, 8,
    1.24 +    "All the function calls should now be displayed in the UI.");
    1.25 +
    1.26 +  testItem(CallsListView.getItemAtIndex(0),
    1.27 +    "1", "ctx", "clearRect", "(0, 0, 128, 128)", "doc_simple-canvas.html:25");
    1.28 +
    1.29 +  testItem(CallsListView.getItemAtIndex(1),
    1.30 +    "2", "ctx", "fillStyle", " = rgb(192, 192, 192)", "doc_simple-canvas.html:20");
    1.31 +  testItem(CallsListView.getItemAtIndex(2),
    1.32 +    "3", "ctx", "fillRect", "(0, 0, 128, 128)", "doc_simple-canvas.html:21");
    1.33 +
    1.34 +  testItem(CallsListView.getItemAtIndex(3),
    1.35 +    "4", "ctx", "fillStyle", " = rgba(0, 0, 192, 0.5)", "doc_simple-canvas.html:20");
    1.36 +  testItem(CallsListView.getItemAtIndex(4),
    1.37 +    "5", "ctx", "fillRect", "(30, 30, 55, 50)", "doc_simple-canvas.html:21");
    1.38 +
    1.39 +  testItem(CallsListView.getItemAtIndex(5),
    1.40 +    "6", "ctx", "fillStyle", " = rgba(192, 0, 0, 0.5)", "doc_simple-canvas.html:20");
    1.41 +  testItem(CallsListView.getItemAtIndex(6),
    1.42 +    "7", "ctx", "fillRect", "(10, 10, 55, 50)", "doc_simple-canvas.html:21");
    1.43 +
    1.44 +  testItem(CallsListView.getItemAtIndex(7),
    1.45 +    "8", "", "requestAnimationFrame", "(Function)", "doc_simple-canvas.html:30");
    1.46 +
    1.47 +  function testItem(item, index, context, name, args, location) {
    1.48 +    let i = CallsListView.indexOfItem(item);
    1.49 +    is(i, index - 1,
    1.50 +      "The item at index " + index + " is correctly displayed in the UI.");
    1.51 +
    1.52 +    is($(".call-item-index", item.target).getAttribute("value"), index,
    1.53 +      "The item's gutter label has the correct text.");
    1.54 +
    1.55 +    if (context) {
    1.56 +      is($(".call-item-context", item.target).getAttribute("value"), context,
    1.57 +        "The item's context label has the correct text.");
    1.58 +    } else {
    1.59 +      is($(".call-item-context", item.target), null,
    1.60 +        "The item's context label should not be available.");
    1.61 +    }
    1.62 +
    1.63 +    is($(".call-item-name", item.target).getAttribute("value"), name,
    1.64 +      "The item's name label has the correct text.");
    1.65 +    is($(".call-item-args", item.target).getAttribute("value"), args,
    1.66 +      "The item's args label has the correct text.");
    1.67 +    is($(".call-item-location", item.target).getAttribute("value"), location,
    1.68 +      "The item's location label has the correct text.");
    1.69 +  }
    1.70 +
    1.71 +  yield teardown(panel);
    1.72 +  finish();
    1.73 +}

mercurial