browser/devtools/canvasdebugger/test/browser_canvas-frontend-call-stack-01.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-stack-01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,74 @@
     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 the a function call's stack is properly displayed in the UI.
     1.9 + */
    1.10 +
    1.11 +function ifTestingSupported() {
    1.12 +  let [target, debuggee, panel] = yield initCanavsDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL);
    1.13 +  let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
    1.14 +
    1.15 +  yield reload(target);
    1.16 +
    1.17 +  let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
    1.18 +  let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
    1.19 +  SnapshotsListView._onRecordButtonClick();
    1.20 +  yield promise.all([recordingFinished, callListPopulated]);
    1.21 +
    1.22 +  let callItem = CallsListView.getItemAtIndex(2);
    1.23 +  let locationLink = $(".call-item-location", callItem.target);
    1.24 +
    1.25 +  is($(".call-item-stack", callItem.target), null,
    1.26 +    "There should be no stack container available yet for the draw call.");
    1.27 +
    1.28 +  let callStackDisplayed = once(window, EVENTS.CALL_STACK_DISPLAYED);
    1.29 +  EventUtils.sendMouseEvent({ type: "mousedown" }, locationLink, window);
    1.30 +  yield callStackDisplayed;
    1.31 +
    1.32 +  isnot($(".call-item-stack", callItem.target), null,
    1.33 +    "There should be a stack container available now for the draw call.");
    1.34 +  is($all(".call-item-stack-fn", callItem.target).length, 4,
    1.35 +    "There should be 4 functions on the stack for the draw call.");
    1.36 +
    1.37 +  ok($all(".call-item-stack-fn-name", callItem.target)[0].getAttribute("value")
    1.38 +    .contains("C()"),
    1.39 +    "The first function on the stack has the correct name.");
    1.40 +  ok($all(".call-item-stack-fn-name", callItem.target)[1].getAttribute("value")
    1.41 +    .contains("B()"),
    1.42 +    "The second function on the stack has the correct name.");
    1.43 +  ok($all(".call-item-stack-fn-name", callItem.target)[2].getAttribute("value")
    1.44 +    .contains("A()"),
    1.45 +    "The third function on the stack has the correct name.");
    1.46 +  ok($all(".call-item-stack-fn-name", callItem.target)[3].getAttribute("value")
    1.47 +    .contains("drawRect()"),
    1.48 +    "The fourth function on the stack has the correct name.");
    1.49 +
    1.50 +  is($all(".call-item-stack-fn-location", callItem.target)[0].getAttribute("value"),
    1.51 +    "doc_simple-canvas-deep-stack.html:26",
    1.52 +    "The first function on the stack has the correct location.");
    1.53 +  is($all(".call-item-stack-fn-location", callItem.target)[1].getAttribute("value"),
    1.54 +    "doc_simple-canvas-deep-stack.html:28",
    1.55 +    "The second function on the stack has the correct location.");
    1.56 +  is($all(".call-item-stack-fn-location", callItem.target)[2].getAttribute("value"),
    1.57 +    "doc_simple-canvas-deep-stack.html:30",
    1.58 +    "The third function on the stack has the correct location.");
    1.59 +  is($all(".call-item-stack-fn-location", callItem.target)[3].getAttribute("value"),
    1.60 +    "doc_simple-canvas-deep-stack.html:35",
    1.61 +    "The fourth function on the stack has the correct location.");
    1.62 +
    1.63 +  let jumpedToSource = once(window, EVENTS.SOURCE_SHOWN_IN_JS_DEBUGGER);
    1.64 +  EventUtils.sendMouseEvent({ type: "mousedown" }, $(".call-item-stack-fn-location", callItem.target));
    1.65 +  yield jumpedToSource;
    1.66 +
    1.67 +  let toolbox = yield gDevTools.getToolbox(target);
    1.68 +  let { panelWin: { DebuggerView: view } } = toolbox.getPanel("jsdebugger");
    1.69 +
    1.70 +  is(view.Sources.selectedValue, SIMPLE_CANVAS_DEEP_STACK_URL,
    1.71 +    "The expected source was shown in the debugger.");
    1.72 +  is(view.editor.getCursor().line, 25,
    1.73 +    "The expected source line is highlighted in the debugger.");
    1.74 +
    1.75 +  yield teardown(panel);
    1.76 +  finish();
    1.77 +}

mercurial