browser/devtools/debugger/test/browser_dbg_function-display-name.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 that anonymous functions appear in the stack frame list with either
michael@0 6 * their displayName property or a SpiderMonkey-inferred name.
michael@0 7 */
michael@0 8
michael@0 9 const TAB_URL = EXAMPLE_URL + "doc_function-display-name.html";
michael@0 10
michael@0 11 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 12
michael@0 13 function test() {
michael@0 14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 15 gTab = aTab;
michael@0 16 gDebuggee = aDebuggee;
michael@0 17 gPanel = aPanel;
michael@0 18 gDebugger = gPanel.panelWin;
michael@0 19
michael@0 20 testAnonCall();
michael@0 21 });
michael@0 22 }
michael@0 23
michael@0 24 function testAnonCall() {
michael@0 25 waitForSourceAndCaretAndScopes(gPanel, ".html", 15).then(() => {
michael@0 26 ok(isCaretPos(gPanel, 15),
michael@0 27 "The source editor caret position was incorrect.");
michael@0 28 is(gDebugger.gThreadClient.state, "paused",
michael@0 29 "Should only be getting stack frames while paused.");
michael@0 30 is(gDebugger.document.querySelectorAll(".dbg-stackframe").length, 3,
michael@0 31 "Should have three frames.");
michael@0 32 is(gDebugger.document.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"),
michael@0 33 "anonFunc", "Frame name should be 'anonFunc'.");
michael@0 34
michael@0 35 testInferredName();
michael@0 36 });
michael@0 37
michael@0 38 gDebuggee.evalCall();
michael@0 39 }
michael@0 40
michael@0 41 function testInferredName() {
michael@0 42 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
michael@0 43 ok(isCaretPos(gPanel, 15),
michael@0 44 "The source editor caret position was incorrect.");
michael@0 45 is(gDebugger.gThreadClient.state, "paused",
michael@0 46 "Should only be getting stack frames while paused.");
michael@0 47 is(gDebugger.document.querySelectorAll(".dbg-stackframe").length, 3,
michael@0 48 "Should have three frames.");
michael@0 49 is(gDebugger.document.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"),
michael@0 50 "a/<", "Frame name should be 'a/<'.");
michael@0 51
michael@0 52 resumeDebuggerThenCloseAndFinish(gPanel);
michael@0 53 });
michael@0 54
michael@0 55 gDebugger.gThreadClient.resume();
michael@0 56 }
michael@0 57
michael@0 58 registerCleanupFunction(function() {
michael@0 59 gTab = null;
michael@0 60 gDebuggee = null;
michael@0 61 gPanel = null;
michael@0 62 gDebugger = null;
michael@0 63 });

mercurial