browser/devtools/debugger/test/browser_dbg_source-maps-04.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:51be41a8df79
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Test that bogus source maps don't break debugging.
6 */
7
8 const TAB_URL = EXAMPLE_URL + "doc_minified_bogus_map.html";
9 const JS_URL = EXAMPLE_URL + "code_math_bogus_map.min.js";
10
11 // This test causes an error to be logged in the console, which appears in TBPL
12 // logs, so we are disabling that here.
13 let { DevToolsUtils } = Cu.import("resource://gre/modules/devtools/DevToolsUtils.jsm", {});
14 DevToolsUtils.reportingDisabled = true;
15
16 let gPanel, gDebugger, gFrames, gSources, gPrefs, gOptions;
17
18 function test() {
19 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
20 gPanel = aPanel;
21 gDebugger = gPanel.panelWin;
22 gFrames = gDebugger.DebuggerView.StackFrames;
23 gSources = gDebugger.DebuggerView.Sources;
24 gPrefs = gDebugger.Prefs;
25 gOptions = gDebugger.DebuggerView.Options;
26
27 is(gPrefs.pauseOnExceptions, false,
28 "The pause-on-exceptions pref should be disabled by default.");
29 isnot(gOptions._pauseOnExceptionsItem.getAttribute("checked"), "true",
30 "The pause-on-exceptions menu item should not be checked.");
31
32 waitForSourceShown(gPanel, JS_URL)
33 .then(checkInitialSource)
34 .then(enablePauseOnExceptions)
35 .then(disableIgnoreCaughtExceptions)
36 .then(testSetBreakpoint)
37 .then(reloadPage)
38 .then(testHitBreakpoint)
39 .then(enableIgnoreCaughtExceptions)
40 .then(disablePauseOnExceptions)
41 .then(() => closeDebuggerAndFinish(gPanel))
42 .then(null, aError => {
43 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
44 });
45 });
46 }
47
48 function checkInitialSource() {
49 isnot(gSources.selectedValue.indexOf(".min.js"), -1,
50 "The debugger should show the minified js file.");
51 }
52
53 function enablePauseOnExceptions() {
54 let deferred = promise.defer();
55
56 gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
57 is(gPrefs.pauseOnExceptions, true,
58 "The pause-on-exceptions pref should now be enabled.");
59
60 ok(true, "Pausing on exceptions was enabled.");
61 deferred.resolve();
62 });
63
64 gOptions._pauseOnExceptionsItem.setAttribute("checked", "true");
65 gOptions._togglePauseOnExceptions();
66
67 return deferred.promise;
68 }
69
70 function disableIgnoreCaughtExceptions() {
71 let deferred = promise.defer();
72
73 gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
74 is(gPrefs.ignoreCaughtExceptions, false,
75 "The ignore-caught-exceptions pref should now be disabled.");
76
77 ok(true, "Ignore caught exceptions was disabled.");
78 deferred.resolve();
79 });
80
81 gOptions._ignoreCaughtExceptionsItem.setAttribute("checked", "false");
82 gOptions._toggleIgnoreCaughtExceptions();
83
84 return deferred.promise;
85 }
86
87 function testSetBreakpoint() {
88 let deferred = promise.defer();
89
90 gDebugger.gThreadClient.setBreakpoint({ url: JS_URL, line: 3, column: 61 }, aResponse => {
91 ok(!aResponse.error,
92 "Should be able to set a breakpoint in a js file.");
93 ok(!aResponse.actualLocation,
94 "Should be able to set a breakpoint on line 3 and column 61.");
95
96 deferred.resolve();
97 });
98
99 return deferred.promise;
100 }
101
102 function reloadPage() {
103 let loaded = waitForSourceAndCaret(gPanel, ".js", 3);
104 gDebugger.DebuggerController._target.activeTab.reload();
105 return loaded.then(() => ok(true, "Page was reloaded and execution resumed."));
106 }
107
108 function testHitBreakpoint() {
109 let deferred = promise.defer();
110
111 gDebugger.gThreadClient.resume(aResponse => {
112 ok(!aResponse.error, "Shouldn't get an error resuming.");
113 is(aResponse.type, "resumed", "Type should be 'resumed'.");
114
115 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
116 is(gFrames.itemCount, 1, "Should have one frame.");
117
118 gDebugger.gThreadClient.resume(deferred.resolve);
119 });
120 });
121
122 return deferred.promise;
123 }
124
125 function enableIgnoreCaughtExceptions() {
126 let deferred = promise.defer();
127
128 gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
129 is(gPrefs.ignoreCaughtExceptions, true,
130 "The ignore-caught-exceptions pref should now be enabled.");
131
132 ok(true, "Ignore caught exceptions was enabled.");
133 deferred.resolve();
134 });
135
136 gOptions._ignoreCaughtExceptionsItem.setAttribute("checked", "true");
137 gOptions._toggleIgnoreCaughtExceptions();
138
139 return deferred.promise;
140 }
141
142 function disablePauseOnExceptions() {
143 let deferred = promise.defer();
144
145 gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
146 is(gPrefs.pauseOnExceptions, false,
147 "The pause-on-exceptions pref should now be disabled.");
148
149 ok(true, "Pausing on exceptions was disabled.");
150 deferred.resolve();
151 });
152
153 gOptions._pauseOnExceptionsItem.setAttribute("checked", "false");
154 gOptions._togglePauseOnExceptions();
155
156 return deferred.promise;
157 }
158
159 registerCleanupFunction(function() {
160 gPanel = null;
161 gDebugger = null;
162 gFrames = null;
163 gSources = null;
164 gPrefs = null;
165 gOptions = null;
166 DevToolsUtils.reportingDisabled = false;
167 });

mercurial