1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_function-display-name.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 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 that anonymous functions appear in the stack frame list with either 1.9 + * their displayName property or a SpiderMonkey-inferred name. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_function-display-name.html"; 1.13 + 1.14 +let gTab, gDebuggee, gPanel, gDebugger; 1.15 + 1.16 +function test() { 1.17 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.18 + gTab = aTab; 1.19 + gDebuggee = aDebuggee; 1.20 + gPanel = aPanel; 1.21 + gDebugger = gPanel.panelWin; 1.22 + 1.23 + testAnonCall(); 1.24 + }); 1.25 +} 1.26 + 1.27 +function testAnonCall() { 1.28 + waitForSourceAndCaretAndScopes(gPanel, ".html", 15).then(() => { 1.29 + ok(isCaretPos(gPanel, 15), 1.30 + "The source editor caret position was incorrect."); 1.31 + is(gDebugger.gThreadClient.state, "paused", 1.32 + "Should only be getting stack frames while paused."); 1.33 + is(gDebugger.document.querySelectorAll(".dbg-stackframe").length, 3, 1.34 + "Should have three frames."); 1.35 + is(gDebugger.document.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"), 1.36 + "anonFunc", "Frame name should be 'anonFunc'."); 1.37 + 1.38 + testInferredName(); 1.39 + }); 1.40 + 1.41 + gDebuggee.evalCall(); 1.42 +} 1.43 + 1.44 +function testInferredName() { 1.45 + waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => { 1.46 + ok(isCaretPos(gPanel, 15), 1.47 + "The source editor caret position was incorrect."); 1.48 + is(gDebugger.gThreadClient.state, "paused", 1.49 + "Should only be getting stack frames while paused."); 1.50 + is(gDebugger.document.querySelectorAll(".dbg-stackframe").length, 3, 1.51 + "Should have three frames."); 1.52 + is(gDebugger.document.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"), 1.53 + "a/<", "Frame name should be 'a/<'."); 1.54 + 1.55 + resumeDebuggerThenCloseAndFinish(gPanel); 1.56 + }); 1.57 + 1.58 + gDebugger.gThreadClient.resume(); 1.59 +} 1.60 + 1.61 +registerCleanupFunction(function() { 1.62 + gTab = null; 1.63 + gDebuggee = null; 1.64 + gPanel = null; 1.65 + gDebugger = null; 1.66 +});