Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit ddfe77b

Browse files
Web Inspector: console command line API should be exposed to breakpoint conditions/actions
https://bugs.webkit.org/show_bug.cgi?id=218141 <rdar://problem/70636727> Reviewed by Brian Burg. Source/JavaScriptCore: * debugger/Debugger.h: (JSC::Debugger::Client::scopeExtensionObject): Added. * debugger/Debugger.cpp: (JSC::Debugger::setClient): Added. (JSC::Debugger::evaluateBreakpointCondition): (JSC::Debugger::evaluateBreakpointActions): Introduce an optional `Debugger::Client` virtual class that can be used to adjust behavior in various situations. Right now it is used when evaluating breakpoint conditions/actions to get a scope extension object. * inspector/agents/InspectorDebuggerAgent.h: * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::internalEnable): (Inspector::InspectorDebuggerAgent::internalDisable): (Inspector::InspectorDebuggerAgent::scopeExtensionObject): Added. Implement `Debugger::Client` and provide a newly created `CommandLineAPI` instance. * inspector/InjectedScript.h: * inspector/InjectedScript.cpp: (Inspector::InjectedScript::createCommandLineAPIObject const): Added. * inspector/InjectedScriptSource.js: (let.InjectedScript.prototype.createCommandLineAPIObject): Added. (let.InjectedScript.prototype._evaluateOn): Expose a way for the C++ to create `CommandLineAPI` instances. Source/WebInspectorUI: * UserInterface/Controllers/CodeMirrorCompletionController.js: (WI.CodeMirrorCompletionController): (WI.CodeMirrorCompletionController.prototype.get mode): Added. (WI.CodeMirrorCompletionController.prototype.get delegate): Deleted. * UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js: (WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded): (WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded.shouldExposeEvent): Added. (WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded.shouldExposeException): Added. (WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded.receivedPropertyNames): Introduce a `Mode` enum that can be fetched by completion providers to adjust functionality. * UserInterface/Views/BreakpointPopover.js: (WI.BreakpointPopover.appendContextMenuItems): (WI.BreakpointPopover.prototype.show): (WI.BreakpointPopover.prototype.breakpointActionViewCodeMirrorCompletionControllerMode): Added. (WI.BreakpointPopover.prototype.get codeMirrorCompletionControllerMode): Added. * UserInterface/Views/EventBreakpointPopover.js: (WI.EventBreakpointPopover.prototype.get codeMirrorCompletionControllerMode): Added. * UserInterface/Views/BreakpointActionView.js: (WI.BreakpointActionView.prototype._updateBody): Use a `Mode` that always exposes `$event`/`$exception` depending on the breakpoint type. * UserInterface/Views/ConsolePrompt.js: (WI.ConsolePrompt): Use a `Mode` that only exposes `$event`/`$exception` when paused for an event/exeption. * UserInterface/Views/ScopeChainDetailsSidebarPanel.js: (WI.ScopeChainDetailsSidebarPanel.prototype._addWatchExpressionButtonClicked): Use a `Mode` that always exposes `$event`/`$exception` since watch expressions track values over time, and may therefore not always have an `$event`/`$exception` set. * UserInterface/Views/TextEditor.js: (WI.TextEditor): Use the default `Mode` that never exposes `$event`/`$exception`. LayoutTests: * inspector/debugger/resources/breakpoint-options-utilities.js: * inspector/debugger/break-on-exception-expected.txt: * inspector/debugger/break-on-uncaught-exception-expected.txt: * inspector/debugger/setPauseOnAssertions-expected.txt: * inspector/debugger/setPauseOnDebuggerStatements-expected.txt: * inspector/debugger/setPauseOnMicrotasks-expected.txt: * inspector/dom-debugger/attribute-modified-style-expected.txt: * inspector/dom-debugger/dom-breakpoint-attribute-modified-expected.txt: * inspector/dom-debugger/dom-breakpoint-node-removed-ancestor-expected.txt: * inspector/dom-debugger/dom-breakpoint-node-removed-direct-expected.txt: * inspector/dom-debugger/dom-breakpoint-subtree-modified-add-expected.txt: * inspector/dom-debugger/dom-breakpoint-subtree-modified-remove-expected.txt: * inspector/dom-debugger/event-animation-frame-breakpoints-expected.txt: * inspector/dom-debugger/event-interval-breakpoints-expected.txt: * inspector/dom-debugger/event-listener-breakpoints-expected.txt: * inspector/dom-debugger/event-timeout-breakpoints-expected.txt: * inspector/dom-debugger/url-breakpoints-all-requests-expected.txt: * inspector/dom-debugger/url-breakpoints-containing-expected.txt: * inspector/dom-debugger/url-breakpoints-matching-expected.txt: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@269023 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent ae8dc6a commit ddfe77b

37 files changed

+1548
-29
lines changed

LayoutTests/ChangeLog

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
2020-10-26 Devin Rousso <[email protected]>
2+
3+
Web Inspector: console command line API should be exposed to breakpoint conditions/actions
4+
https://bugs.webkit.org/show_bug.cgi?id=218141
5+
<rdar://problem/70636727>
6+
7+
Reviewed by Brian Burg.
8+
9+
* inspector/debugger/resources/breakpoint-options-utilities.js:
10+
* inspector/debugger/break-on-exception-expected.txt:
11+
* inspector/debugger/break-on-uncaught-exception-expected.txt:
12+
* inspector/debugger/setPauseOnAssertions-expected.txt:
13+
* inspector/debugger/setPauseOnDebuggerStatements-expected.txt:
14+
* inspector/debugger/setPauseOnMicrotasks-expected.txt:
15+
* inspector/dom-debugger/attribute-modified-style-expected.txt:
16+
* inspector/dom-debugger/dom-breakpoint-attribute-modified-expected.txt:
17+
* inspector/dom-debugger/dom-breakpoint-node-removed-ancestor-expected.txt:
18+
* inspector/dom-debugger/dom-breakpoint-node-removed-direct-expected.txt:
19+
* inspector/dom-debugger/dom-breakpoint-subtree-modified-add-expected.txt:
20+
* inspector/dom-debugger/dom-breakpoint-subtree-modified-remove-expected.txt:
21+
* inspector/dom-debugger/event-animation-frame-breakpoints-expected.txt:
22+
* inspector/dom-debugger/event-interval-breakpoints-expected.txt:
23+
* inspector/dom-debugger/event-listener-breakpoints-expected.txt:
24+
* inspector/dom-debugger/event-timeout-breakpoints-expected.txt:
25+
* inspector/dom-debugger/url-breakpoints-all-requests-expected.txt:
26+
* inspector/dom-debugger/url-breakpoints-containing-expected.txt:
27+
* inspector/dom-debugger/url-breakpoints-matching-expected.txt:
28+
129
2020-10-26 Carlos Alberto Lopez Perez <[email protected]>
230

331
[GTK][WPE] Gardening of layout test failures.

LayoutTests/inspector/debugger/break-on-exception-expected.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@ PASS: Should pause.
5656
Triggering breakpoint...
5757
PASS: Should pause.
5858

59+
-- Running test case: BreakOnAnyException.Options.Condition.ConsoleCommandLineAPI
60+
Adding saved console value 'false'...
61+
62+
Setting condition to saved console value...
63+
64+
Triggering breakpoint...
65+
PASS: Should not pause.
66+
67+
Triggering breakpoint...
68+
PASS: Should not pause.
69+
70+
Adding saved console value 'true'...
71+
Setting condition to saved console value...
72+
73+
Triggering breakpoint...
74+
PASS: Should pause.
75+
76+
Triggering breakpoint...
77+
PASS: Should pause.
78+
5979
-- Running test case: BreakOnAnyException.Options.IgnoreCount
6080

6181
Setting ignoreCount to '2'...
@@ -126,3 +146,34 @@ Triggering breakpoint...
126146
PASS: Should execute breakpoint action.
127147
PASS: Should not pause.
128148

149+
-- Running test case: BreakOnAnyException.Options.Actions.Evaluate.ConsoleCommandLineAPI
150+
Adding saved console value '1'...
151+
152+
Adding evaluate action using saved console value...
153+
154+
Triggering breakpoint...
155+
PASS: Should execute breakpoint action.
156+
PASS: Should pause.
157+
158+
Adding saved console value '2'...
159+
Editing evaluate action using saved console value...
160+
161+
Triggering breakpoint...
162+
PASS: Should execute breakpoint action.
163+
PASS: Should pause.
164+
165+
Adding saved console value '3'...
166+
Editing evaluate action using saved console value...
167+
Enabling auto-continue...
168+
169+
Triggering breakpoint...
170+
PASS: Should execute breakpoint action.
171+
PASS: Should not pause.
172+
173+
Adding saved console value '4'...
174+
Editing evaluate action using saved console value...
175+
176+
Triggering breakpoint...
177+
PASS: Should execute breakpoint action.
178+
PASS: Should not pause.
179+

LayoutTests/inspector/debugger/break-on-uncaught-exception-expected.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@ PASS: Should pause.
5555
Triggering breakpoint...
5656
PASS: Should pause.
5757

58+
-- Running test case: BreakOnUncaughtException.Options.Condition.ConsoleCommandLineAPI
59+
Adding saved console value 'false'...
60+
61+
Setting condition to saved console value...
62+
63+
Triggering breakpoint...
64+
PASS: Should not pause.
65+
66+
Triggering breakpoint...
67+
PASS: Should not pause.
68+
69+
Adding saved console value 'true'...
70+
Setting condition to saved console value...
71+
72+
Triggering breakpoint...
73+
PASS: Should pause.
74+
75+
Triggering breakpoint...
76+
PASS: Should pause.
77+
5878
-- Running test case: BreakOnUncaughtException.Options.IgnoreCount
5979

6080
Setting ignoreCount to '2'...
@@ -125,3 +145,34 @@ Triggering breakpoint...
125145
PASS: Should execute breakpoint action.
126146
PASS: Should not pause.
127147

148+
-- Running test case: BreakOnUncaughtException.Options.Actions.Evaluate.ConsoleCommandLineAPI
149+
Adding saved console value '1'...
150+
151+
Adding evaluate action using saved console value...
152+
153+
Triggering breakpoint...
154+
PASS: Should execute breakpoint action.
155+
PASS: Should pause.
156+
157+
Adding saved console value '2'...
158+
Editing evaluate action using saved console value...
159+
160+
Triggering breakpoint...
161+
PASS: Should execute breakpoint action.
162+
PASS: Should pause.
163+
164+
Adding saved console value '3'...
165+
Editing evaluate action using saved console value...
166+
Enabling auto-continue...
167+
168+
Triggering breakpoint...
169+
PASS: Should execute breakpoint action.
170+
PASS: Should not pause.
171+
172+
Adding saved console value '4'...
173+
Editing evaluate action using saved console value...
174+
175+
Triggering breakpoint...
176+
PASS: Should execute breakpoint action.
177+
PASS: Should not pause.
178+

LayoutTests/inspector/debugger/resources/breakpoint-options-utilities.js

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,71 @@ TestPage.registerInitializer(() => {
5656
},
5757
});
5858

59+
suite.addTestCase({
60+
name: suite.name + "." + testCaseNamePrefix + "Options.Condition.ConsoleCommandLineAPI",
61+
description: "Check the console command line API is exposed to the breakpoint condition.",
62+
async test() {
63+
let pauseCount = 0;
64+
65+
let pausedListener = WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, (event) => {
66+
++pauseCount;
67+
WI.debuggerManager.resume();
68+
});
69+
70+
InspectorTest.log("Adding saved console value 'false'...");
71+
let firstEvaluateResult = await RuntimeAgent.evaluate.invoke({
72+
expression: "false",
73+
objectGroup: "test",
74+
includeCommandLineAPI: true,
75+
doNotPauseOnExceptionsAndMuteConsole: true,
76+
saveResult: true,
77+
});
78+
InspectorTest.assert(!firstEvaluateResult.wasThrown, "Should not throw.");
79+
InspectorTest.assert(firstEvaluateResult.savedResultIndex, "Should have saved result index.");
80+
81+
let breakpoint = await createBreakpoint();
82+
83+
InspectorTest.newline();
84+
85+
InspectorTest.log("Setting condition to saved console value...");
86+
breakpoint.condition = "$" + firstEvaluateResult.savedResultIndex;
87+
88+
for (let i = 1; i <= 4; ++i) {
89+
if (i === 3) {
90+
InspectorTest.newline();
91+
92+
InspectorTest.log("Adding saved console value 'true'...");
93+
let secondEvaluateResult = await RuntimeAgent.evaluate.invoke({
94+
expression: "true",
95+
objectGroup: "test",
96+
includeCommandLineAPI: true,
97+
doNotPauseOnExceptionsAndMuteConsole: true,
98+
saveResult: true,
99+
});
100+
InspectorTest.assert(!secondEvaluateResult.wasThrown, "Should not throw.");
101+
InspectorTest.assert(secondEvaluateResult.savedResultIndex, "Should have saved result index.");
102+
103+
InspectorTest.log("Setting condition to saved console value...");
104+
breakpoint.condition = "$" + secondEvaluateResult.savedResultIndex;
105+
}
106+
107+
InspectorTest.newline();
108+
109+
InspectorTest.log("Triggering breakpoint...");
110+
await triggerBreakpoint(breakpoint);
111+
112+
if (i <= 2)
113+
InspectorTest.expectEqual(pauseCount, 0, "Should not pause.");
114+
else
115+
InspectorTest.expectEqual(pauseCount, i - 2, "Should pause.");
116+
}
117+
118+
removeBreakpoint(breakpoint);
119+
120+
WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, pausedListener);
121+
},
122+
});
123+
59124
if (!skip?.ignoreCount) {
60125
suite.addTestCase({
61126
name: suite.name + "." + testCaseNamePrefix + "Options.IgnoreCount",
@@ -204,5 +269,79 @@ TestPage.registerInitializer(() => {
204269
WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, pausedListener);
205270
},
206271
});
272+
273+
suite.addTestCase({
274+
name: suite.name + "." + testCaseNamePrefix + "Options.Actions.Evaluate.ConsoleCommandLineAPI",
275+
description: "Check the console command line API is exposed to breakpoint actions.",
276+
async test() {
277+
let pauseCount = 0;
278+
279+
let pausedListener = WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, (event) => {
280+
++pauseCount;
281+
WI.debuggerManager.resume();
282+
});
283+
284+
InspectorTest.log("Adding saved console value '1'...");
285+
let firstEvaluateResult = await RuntimeAgent.evaluate.invoke({
286+
expression: "1",
287+
objectGroup: "test",
288+
includeCommandLineAPI: true,
289+
doNotPauseOnExceptionsAndMuteConsole: true,
290+
saveResult: true,
291+
});
292+
InspectorTest.assert(!firstEvaluateResult.wasThrown, "Should not throw.");
293+
InspectorTest.assert(firstEvaluateResult.savedResultIndex, "Should have saved result index.");
294+
295+
let breakpoint = await createBreakpoint();
296+
297+
InspectorTest.newline();
298+
299+
InspectorTest.log("Adding evaluate action using saved console value...");
300+
let action = new WI.BreakpointAction(WI.BreakpointAction.Type.Evaluate, {data: `window.BREAKPOINT_ACTION_EVALUATE = $${firstEvaluateResult.savedResultIndex};`});
301+
breakpoint.addAction(action);
302+
303+
for (let i = 1; i <= 4; ++i) {
304+
if (i > 1) {
305+
InspectorTest.newline();
306+
307+
InspectorTest.log(`Adding saved console value '${i}'...`);
308+
let secondEvaluateResult = await RuntimeAgent.evaluate.invoke({
309+
expression: String(i),
310+
objectGroup: "test",
311+
includeCommandLineAPI: true,
312+
doNotPauseOnExceptionsAndMuteConsole: true,
313+
saveResult: true,
314+
});
315+
InspectorTest.assert(!secondEvaluateResult.wasThrown, "Should not throw.");
316+
InspectorTest.assert(secondEvaluateResult.savedResultIndex, "Should have saved result index.");
317+
318+
InspectorTest.log("Editing evaluate action using saved console value...");
319+
action.data = `window.BREAKPOINT_ACTION_EVALUATE = $${secondEvaluateResult.savedResultIndex};`;
320+
321+
if (i === 3) {
322+
InspectorTest.log("Enabling auto-continue...");
323+
breakpoint.autoContinue = true;
324+
}
325+
}
326+
327+
InspectorTest.newline();
328+
329+
InspectorTest.log("Triggering breakpoint...");
330+
await triggerBreakpoint(breakpoint);
331+
332+
let breakpointActionEvaluateResult = await InspectorTest.evaluateInPage(`window.BREAKPOINT_ACTION_EVALUATE`);
333+
InspectorTest.expectEqual(breakpointActionEvaluateResult, i, "Should execute breakpoint action.");
334+
335+
if (i <= 2)
336+
InspectorTest.expectEqual(pauseCount, i, "Should pause.");
337+
else
338+
InspectorTest.expectEqual(pauseCount, 2, "Should not pause.");
339+
}
340+
341+
removeBreakpoint(breakpoint);
342+
343+
WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, pausedListener);
344+
},
345+
});
207346
};
208347
});

LayoutTests/inspector/debugger/setPauseOnAssertions-expected.txt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ CONSOLE MESSAGE: Failing assertion
88
CONSOLE MESSAGE: Failing assertion
99
CONSOLE MESSAGE: Failing assertion
1010
CONSOLE MESSAGE: Failing assertion
11+
CONSOLE MESSAGE: Failing assertion
12+
CONSOLE MESSAGE: Failing assertion
13+
CONSOLE MESSAGE: Failing assertion
14+
CONSOLE MESSAGE: Failing assertion
1115
CONSOLE MESSAGE: BREAKPOINT ACTION LOG 1
1216
CONSOLE MESSAGE: Failing assertion
1317
CONSOLE MESSAGE: BREAKPOINT ACTION LOG 2
@@ -20,6 +24,10 @@ CONSOLE MESSAGE: Failing assertion
2024
CONSOLE MESSAGE: Failing assertion
2125
CONSOLE MESSAGE: Failing assertion
2226
CONSOLE MESSAGE: Failing assertion
27+
CONSOLE MESSAGE: Failing assertion
28+
CONSOLE MESSAGE: Failing assertion
29+
CONSOLE MESSAGE: Failing assertion
30+
CONSOLE MESSAGE: Failing assertion
2331
Debugger.setPauseOnAssertions
2432

2533

@@ -48,6 +56,26 @@ PASS: Should pause.
4856
Triggering breakpoint...
4957
PASS: Should pause.
5058

59+
-- Running test case: Debugger.setPauseOnAssertions.Options.Condition.ConsoleCommandLineAPI
60+
Adding saved console value 'false'...
61+
62+
Setting condition to saved console value...
63+
64+
Triggering breakpoint...
65+
PASS: Should not pause.
66+
67+
Triggering breakpoint...
68+
PASS: Should not pause.
69+
70+
Adding saved console value 'true'...
71+
Setting condition to saved console value...
72+
73+
Triggering breakpoint...
74+
PASS: Should pause.
75+
76+
Triggering breakpoint...
77+
PASS: Should pause.
78+
5179
-- Running test case: Debugger.setPauseOnAssertions.Options.IgnoreCount
5280

5381
Setting ignoreCount to '2'...
@@ -118,3 +146,34 @@ Triggering breakpoint...
118146
PASS: Should execute breakpoint action.
119147
PASS: Should not pause.
120148

149+
-- Running test case: Debugger.setPauseOnAssertions.Options.Actions.Evaluate.ConsoleCommandLineAPI
150+
Adding saved console value '1'...
151+
152+
Adding evaluate action using saved console value...
153+
154+
Triggering breakpoint...
155+
PASS: Should execute breakpoint action.
156+
PASS: Should pause.
157+
158+
Adding saved console value '2'...
159+
Editing evaluate action using saved console value...
160+
161+
Triggering breakpoint...
162+
PASS: Should execute breakpoint action.
163+
PASS: Should pause.
164+
165+
Adding saved console value '3'...
166+
Editing evaluate action using saved console value...
167+
Enabling auto-continue...
168+
169+
Triggering breakpoint...
170+
PASS: Should execute breakpoint action.
171+
PASS: Should not pause.
172+
173+
Adding saved console value '4'...
174+
Editing evaluate action using saved console value...
175+
176+
Triggering breakpoint...
177+
PASS: Should execute breakpoint action.
178+
PASS: Should not pause.
179+

0 commit comments

Comments
 (0)