diff -r 000000000000 -r 6474c204b198 browser/devtools/debugger/test/browser_dbg_pause-exceptions-02.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browser/devtools/debugger/test/browser_dbg_pause-exceptions-02.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,204 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Make sure that pausing on exceptions works after reload. + */ + +const TAB_URL = EXAMPLE_URL + "doc_pause-exceptions.html"; + +let gTab, gDebuggee, gPanel, gDebugger; +let gFrames, gVariables, gPrefs, gOptions; + +function test() { + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { + gTab = aTab; + gDebuggee = aDebuggee; + gPanel = aPanel; + gDebugger = gPanel.panelWin; + gFrames = gDebugger.DebuggerView.StackFrames; + gVariables = gDebugger.DebuggerView.Variables; + gPrefs = gDebugger.Prefs; + gOptions = gDebugger.DebuggerView.Options; + + is(gPrefs.pauseOnExceptions, false, + "The pause-on-exceptions pref should be disabled by default."); + isnot(gOptions._pauseOnExceptionsItem.getAttribute("checked"), "true", + "The pause-on-exceptions menu item should not be checked."); + + enablePauseOnExceptions() + .then(disableIgnoreCaughtExceptions) + .then(() => reloadActiveTab(gPanel, gDebugger.EVENTS.SOURCE_SHOWN)) + .then(testPauseOnExceptionsAfterReload) + .then(disablePauseOnExceptions) + .then(enableIgnoreCaughtExceptions) + .then(() => closeDebuggerAndFinish(gPanel)) + .then(null, aError => { + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); + }); + }); +} + +function testPauseOnExceptionsAfterReload() { + let finished = waitForCaretAndScopes(gPanel, 19).then(() => { + info("Testing enabled pause-on-exceptions."); + + is(gDebugger.gThreadClient.state, "paused", + "Should only be getting stack frames while paused."); + ok(isCaretPos(gPanel, 19), + "Should be paused on the debugger statement."); + + let innerScope = gVariables.getScopeAtIndex(0); + let innerNodes = innerScope.target.querySelector(".variables-view-element-details").childNodes; + + is(gFrames.itemCount, 1, + "Should have one frame."); + is(gVariables._store.length, 3, + "Should have three scopes."); + + is(innerNodes[0].querySelector(".name").getAttribute("value"), "", + "Should have the right property name for ."); + is(innerNodes[0].querySelector(".value").getAttribute("value"), "Error", + "Should have the right property value for ."); + + let finished = waitForCaretAndScopes(gPanel, 26).then(() => { + info("Testing enabled pause-on-exceptions and resumed after pause."); + + is(gDebugger.gThreadClient.state, "paused", + "Should only be getting stack frames while paused."); + ok(isCaretPos(gPanel, 26), + "Should be paused on the debugger statement."); + + let innerScope = gVariables.getScopeAtIndex(0); + let innerNodes = innerScope.target.querySelector(".variables-view-element-details").childNodes; + + is(gFrames.itemCount, 1, + "Should have one frame."); + is(gVariables._store.length, 3, + "Should have three scopes."); + + is(innerNodes[0].querySelector(".name").getAttribute("value"), "this", + "Should have the right property name for 'this'."); + is(innerNodes[0].querySelector(".value").getAttribute("value"), "