1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_source-maps-04.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,167 @@ 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 + * Test that bogus source maps don't break debugging. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_minified_bogus_map.html"; 1.12 +const JS_URL = EXAMPLE_URL + "code_math_bogus_map.min.js"; 1.13 + 1.14 +// This test causes an error to be logged in the console, which appears in TBPL 1.15 +// logs, so we are disabling that here. 1.16 +let { DevToolsUtils } = Cu.import("resource://gre/modules/devtools/DevToolsUtils.jsm", {}); 1.17 +DevToolsUtils.reportingDisabled = true; 1.18 + 1.19 +let gPanel, gDebugger, gFrames, gSources, gPrefs, gOptions; 1.20 + 1.21 +function test() { 1.22 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.23 + gPanel = aPanel; 1.24 + gDebugger = gPanel.panelWin; 1.25 + gFrames = gDebugger.DebuggerView.StackFrames; 1.26 + gSources = gDebugger.DebuggerView.Sources; 1.27 + gPrefs = gDebugger.Prefs; 1.28 + gOptions = gDebugger.DebuggerView.Options; 1.29 + 1.30 + is(gPrefs.pauseOnExceptions, false, 1.31 + "The pause-on-exceptions pref should be disabled by default."); 1.32 + isnot(gOptions._pauseOnExceptionsItem.getAttribute("checked"), "true", 1.33 + "The pause-on-exceptions menu item should not be checked."); 1.34 + 1.35 + waitForSourceShown(gPanel, JS_URL) 1.36 + .then(checkInitialSource) 1.37 + .then(enablePauseOnExceptions) 1.38 + .then(disableIgnoreCaughtExceptions) 1.39 + .then(testSetBreakpoint) 1.40 + .then(reloadPage) 1.41 + .then(testHitBreakpoint) 1.42 + .then(enableIgnoreCaughtExceptions) 1.43 + .then(disablePauseOnExceptions) 1.44 + .then(() => closeDebuggerAndFinish(gPanel)) 1.45 + .then(null, aError => { 1.46 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.47 + }); 1.48 + }); 1.49 +} 1.50 + 1.51 +function checkInitialSource() { 1.52 + isnot(gSources.selectedValue.indexOf(".min.js"), -1, 1.53 + "The debugger should show the minified js file."); 1.54 +} 1.55 + 1.56 +function enablePauseOnExceptions() { 1.57 + let deferred = promise.defer(); 1.58 + 1.59 + gDebugger.gThreadClient.addOneTimeListener("resumed", () => { 1.60 + is(gPrefs.pauseOnExceptions, true, 1.61 + "The pause-on-exceptions pref should now be enabled."); 1.62 + 1.63 + ok(true, "Pausing on exceptions was enabled."); 1.64 + deferred.resolve(); 1.65 + }); 1.66 + 1.67 + gOptions._pauseOnExceptionsItem.setAttribute("checked", "true"); 1.68 + gOptions._togglePauseOnExceptions(); 1.69 + 1.70 + return deferred.promise; 1.71 +} 1.72 + 1.73 +function disableIgnoreCaughtExceptions() { 1.74 + let deferred = promise.defer(); 1.75 + 1.76 + gDebugger.gThreadClient.addOneTimeListener("resumed", () => { 1.77 + is(gPrefs.ignoreCaughtExceptions, false, 1.78 + "The ignore-caught-exceptions pref should now be disabled."); 1.79 + 1.80 + ok(true, "Ignore caught exceptions was disabled."); 1.81 + deferred.resolve(); 1.82 + }); 1.83 + 1.84 + gOptions._ignoreCaughtExceptionsItem.setAttribute("checked", "false"); 1.85 + gOptions._toggleIgnoreCaughtExceptions(); 1.86 + 1.87 + return deferred.promise; 1.88 +} 1.89 + 1.90 +function testSetBreakpoint() { 1.91 + let deferred = promise.defer(); 1.92 + 1.93 + gDebugger.gThreadClient.setBreakpoint({ url: JS_URL, line: 3, column: 61 }, aResponse => { 1.94 + ok(!aResponse.error, 1.95 + "Should be able to set a breakpoint in a js file."); 1.96 + ok(!aResponse.actualLocation, 1.97 + "Should be able to set a breakpoint on line 3 and column 61."); 1.98 + 1.99 + deferred.resolve(); 1.100 + }); 1.101 + 1.102 + return deferred.promise; 1.103 +} 1.104 + 1.105 +function reloadPage() { 1.106 + let loaded = waitForSourceAndCaret(gPanel, ".js", 3); 1.107 + gDebugger.DebuggerController._target.activeTab.reload(); 1.108 + return loaded.then(() => ok(true, "Page was reloaded and execution resumed.")); 1.109 +} 1.110 + 1.111 +function testHitBreakpoint() { 1.112 + let deferred = promise.defer(); 1.113 + 1.114 + gDebugger.gThreadClient.resume(aResponse => { 1.115 + ok(!aResponse.error, "Shouldn't get an error resuming."); 1.116 + is(aResponse.type, "resumed", "Type should be 'resumed'."); 1.117 + 1.118 + waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => { 1.119 + is(gFrames.itemCount, 1, "Should have one frame."); 1.120 + 1.121 + gDebugger.gThreadClient.resume(deferred.resolve); 1.122 + }); 1.123 + }); 1.124 + 1.125 + return deferred.promise; 1.126 +} 1.127 + 1.128 +function enableIgnoreCaughtExceptions() { 1.129 + let deferred = promise.defer(); 1.130 + 1.131 + gDebugger.gThreadClient.addOneTimeListener("resumed", () => { 1.132 + is(gPrefs.ignoreCaughtExceptions, true, 1.133 + "The ignore-caught-exceptions pref should now be enabled."); 1.134 + 1.135 + ok(true, "Ignore caught exceptions was enabled."); 1.136 + deferred.resolve(); 1.137 + }); 1.138 + 1.139 + gOptions._ignoreCaughtExceptionsItem.setAttribute("checked", "true"); 1.140 + gOptions._toggleIgnoreCaughtExceptions(); 1.141 + 1.142 + return deferred.promise; 1.143 +} 1.144 + 1.145 +function disablePauseOnExceptions() { 1.146 + let deferred = promise.defer(); 1.147 + 1.148 + gDebugger.gThreadClient.addOneTimeListener("resumed", () => { 1.149 + is(gPrefs.pauseOnExceptions, false, 1.150 + "The pause-on-exceptions pref should now be disabled."); 1.151 + 1.152 + ok(true, "Pausing on exceptions was disabled."); 1.153 + deferred.resolve(); 1.154 + }); 1.155 + 1.156 + gOptions._pauseOnExceptionsItem.setAttribute("checked", "false"); 1.157 + gOptions._togglePauseOnExceptions(); 1.158 + 1.159 + return deferred.promise; 1.160 +} 1.161 + 1.162 +registerCleanupFunction(function() { 1.163 + gPanel = null; 1.164 + gDebugger = null; 1.165 + gFrames = null; 1.166 + gSources = null; 1.167 + gPrefs = null; 1.168 + gOptions = null; 1.169 + DevToolsUtils.reportingDisabled = false; 1.170 +});