From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../mochitest/browser_dbg_pause-exceptions-02.js | 204 +++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 devtools/client/debugger/test/mochitest/browser_dbg_pause-exceptions-02.js (limited to 'devtools/client/debugger/test/mochitest/browser_dbg_pause-exceptions-02.js') diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_pause-exceptions-02.js b/devtools/client/debugger/test/mochitest/browser_dbg_pause-exceptions-02.js new file mode 100644 index 000000000..21b28ce26 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg_pause-exceptions-02.js @@ -0,0 +1,204 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* 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"; + +var gTab, gPanel, gDebugger; +var gFrames, gVariables, gPrefs, gOptions; + +function test() { + let options = { + source: TAB_URL, + line: 1 + }; + initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => { + gTab = aTab; + 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(() => { + generateMouseClickInTab(gTab, "content.document.querySelector('button')"); + }) + .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, 4, + "Should have four 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, 4, + "Should have four scopes."); + + is(innerNodes[0].querySelector(".name").getAttribute("value"), "this", + "Should have the right property name for 'this'."); + is(innerNodes[0].querySelector(".value").getAttribute("value"), "