browser/devtools/canvasdebugger/test/browser_canvas-frontend-call-stack-01.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Tests if the a function call's stack is properly displayed in the UI.
michael@0 6 */
michael@0 7
michael@0 8 function ifTestingSupported() {
michael@0 9 let [target, debuggee, panel] = yield initCanavsDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL);
michael@0 10 let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
michael@0 11
michael@0 12 yield reload(target);
michael@0 13
michael@0 14 let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
michael@0 15 let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
michael@0 16 SnapshotsListView._onRecordButtonClick();
michael@0 17 yield promise.all([recordingFinished, callListPopulated]);
michael@0 18
michael@0 19 let callItem = CallsListView.getItemAtIndex(2);
michael@0 20 let locationLink = $(".call-item-location", callItem.target);
michael@0 21
michael@0 22 is($(".call-item-stack", callItem.target), null,
michael@0 23 "There should be no stack container available yet for the draw call.");
michael@0 24
michael@0 25 let callStackDisplayed = once(window, EVENTS.CALL_STACK_DISPLAYED);
michael@0 26 EventUtils.sendMouseEvent({ type: "mousedown" }, locationLink, window);
michael@0 27 yield callStackDisplayed;
michael@0 28
michael@0 29 isnot($(".call-item-stack", callItem.target), null,
michael@0 30 "There should be a stack container available now for the draw call.");
michael@0 31 is($all(".call-item-stack-fn", callItem.target).length, 4,
michael@0 32 "There should be 4 functions on the stack for the draw call.");
michael@0 33
michael@0 34 ok($all(".call-item-stack-fn-name", callItem.target)[0].getAttribute("value")
michael@0 35 .contains("C()"),
michael@0 36 "The first function on the stack has the correct name.");
michael@0 37 ok($all(".call-item-stack-fn-name", callItem.target)[1].getAttribute("value")
michael@0 38 .contains("B()"),
michael@0 39 "The second function on the stack has the correct name.");
michael@0 40 ok($all(".call-item-stack-fn-name", callItem.target)[2].getAttribute("value")
michael@0 41 .contains("A()"),
michael@0 42 "The third function on the stack has the correct name.");
michael@0 43 ok($all(".call-item-stack-fn-name", callItem.target)[3].getAttribute("value")
michael@0 44 .contains("drawRect()"),
michael@0 45 "The fourth function on the stack has the correct name.");
michael@0 46
michael@0 47 is($all(".call-item-stack-fn-location", callItem.target)[0].getAttribute("value"),
michael@0 48 "doc_simple-canvas-deep-stack.html:26",
michael@0 49 "The first function on the stack has the correct location.");
michael@0 50 is($all(".call-item-stack-fn-location", callItem.target)[1].getAttribute("value"),
michael@0 51 "doc_simple-canvas-deep-stack.html:28",
michael@0 52 "The second function on the stack has the correct location.");
michael@0 53 is($all(".call-item-stack-fn-location", callItem.target)[2].getAttribute("value"),
michael@0 54 "doc_simple-canvas-deep-stack.html:30",
michael@0 55 "The third function on the stack has the correct location.");
michael@0 56 is($all(".call-item-stack-fn-location", callItem.target)[3].getAttribute("value"),
michael@0 57 "doc_simple-canvas-deep-stack.html:35",
michael@0 58 "The fourth function on the stack has the correct location.");
michael@0 59
michael@0 60 let jumpedToSource = once(window, EVENTS.SOURCE_SHOWN_IN_JS_DEBUGGER);
michael@0 61 EventUtils.sendMouseEvent({ type: "mousedown" }, $(".call-item-stack-fn-location", callItem.target));
michael@0 62 yield jumpedToSource;
michael@0 63
michael@0 64 let toolbox = yield gDevTools.getToolbox(target);
michael@0 65 let { panelWin: { DebuggerView: view } } = toolbox.getPanel("jsdebugger");
michael@0 66
michael@0 67 is(view.Sources.selectedValue, SIMPLE_CANVAS_DEEP_STACK_URL,
michael@0 68 "The expected source was shown in the debugger.");
michael@0 69 is(view.editor.getCursor().line, 25,
michael@0 70 "The expected source line is highlighted in the debugger.");
michael@0 71
michael@0 72 yield teardown(panel);
michael@0 73 finish();
michael@0 74 }

mercurial