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