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