Commit 61f91381 authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

Remove event races in two breakpoint decoration tests

This CL changes two layout tests to follow the pattern of:
  1. Install an instrumentation promise
  2. Run and await an async action
  3. Await that the instrumentation is called
  4. Dump breakpoint information

This CL is also in preparation for asyncification of source mapping,
hence making the "action" async.

Drive-by: Re-baseline one of the layout tests that seems to be fixed
now.

Bug: chromium:1032016
Change-Id: Ibad4160fe9ab32aa3f818cdd4937112c3f4e6f08
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2000023
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: default avatarSigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731171}
parent 129a7d15
...@@ -25,11 +25,13 @@ breakpoint at 2 ...@@ -25,11 +25,13 @@ breakpoint at 2
inline breakpoint at (2, 4) inline breakpoint at (2, 4)
inline breakpoint at (2, 13) disabled inline breakpoint at (2, 13) disabled
Adding conditional enabled breakpoint Adding conditional enabled breakpoint
breakpoint at 2 breakpoint at 2 conditional
inline breakpoint at (2, 4) inline breakpoint at (2, 4)
inline breakpoint at (2, 13) disabled inline breakpoint at (2, 13) disabled
Disable breakpoints Disable breakpoints
breakpoint at 2 disabled breakpoint at 2 disabled conditional
inline breakpoint at (2, 4) disabled
inline breakpoint at (2, 13) disabled
Enable breakpoints Enable breakpoints
breakpoint at 2 conditional breakpoint at 2 conditional
inline breakpoint at (2, 4) inline breakpoint at (2, 4)
......
...@@ -8,9 +8,11 @@ ...@@ -8,9 +8,11 @@
await TestRunner.showPanel('sources'); await TestRunner.showPanel('sources');
await TestRunner.addScriptTag('resources/edit-me-breakpoints.js'); await TestRunner.addScriptTag('resources/edit-me-breakpoints.js');
function waitAndDumpDecorations(sourceFrame) { async function runAsyncBreakpointActionAndDumpDecorations(sourceFrame, action) {
return SourcesTestRunner.waitDebuggerPluginBreakpoints(sourceFrame).then( const waitPromise = SourcesTestRunner.waitDebuggerPluginBreakpoints(sourceFrame);
() => SourcesTestRunner.dumpDebuggerPluginBreakpoints(sourceFrame)); await action();
await waitPromise;
SourcesTestRunner.dumpDebuggerPluginBreakpoints(sourceFrame);
} }
Bindings.breakpointManager._storage._breakpoints = new Map(); Bindings.breakpointManager._storage._breakpoints = new Map();
...@@ -22,15 +24,16 @@ ...@@ -22,15 +24,16 @@
function addBreakpoint(sourceFrame) { function addBreakpoint(sourceFrame) {
javaScriptSourceFrame = sourceFrame; javaScriptSourceFrame = sourceFrame;
TestRunner.addResult('Setting breakpoint'); TestRunner.addResult('Setting breakpoint');
SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, '', true) runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
.then(() => waitAndDumpDecorations(javaScriptSourceFrame)) SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, '', true)
.then(removeBreakpoint); ).then(removeBreakpoint);
} }
function removeBreakpoint() { function removeBreakpoint() {
TestRunner.addResult('Toggle breakpoint'); TestRunner.addResult('Toggle breakpoint');
SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 2); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
waitAndDumpDecorations(javaScriptSourceFrame).then(() => next()); SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 2)
).then(next);
} }
}, },
...@@ -43,15 +46,16 @@ ...@@ -43,15 +46,16 @@
TestRunner.addResult('Setting breakpoint'); TestRunner.addResult('Setting breakpoint');
SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, '', true) SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, '', true)
.then(() => SourcesTestRunner.waitBreakpointSidebarPane(true)) .then(() => SourcesTestRunner.waitBreakpointSidebarPane(true))
.then(() => SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, 'true', true)) .then(() => runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
.then(() => waitAndDumpDecorations(javaScriptSourceFrame)) SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, 'true', true)
.then(removeBreakpoint); )).then(removeBreakpoint);
} }
function removeBreakpoint() { function removeBreakpoint() {
TestRunner.addResult('Toggle breakpoint'); TestRunner.addResult('Toggle breakpoint');
SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 2); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
waitAndDumpDecorations(javaScriptSourceFrame).then(() => next()); SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 2)
).then(next);
} }
}, },
...@@ -62,44 +66,51 @@ ...@@ -62,44 +66,51 @@
function addRegularDisabled(sourceFrame) { function addRegularDisabled(sourceFrame) {
javaScriptSourceFrame = sourceFrame; javaScriptSourceFrame = sourceFrame;
TestRunner.addResult('Adding regular disabled breakpoint'); TestRunner.addResult('Adding regular disabled breakpoint');
waitAndDumpDecorations(javaScriptSourceFrame).then(addConditionalDisabled); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, '', false); SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, '', false)
).then(addConditionalDisabled);
} }
function addConditionalDisabled() { function addConditionalDisabled() {
TestRunner.addResult('Adding conditional disabled breakpoint'); TestRunner.addResult('Adding conditional disabled breakpoint');
waitAndDumpDecorations(javaScriptSourceFrame).then(addRegularEnabled); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, 'true', false); SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, 'true', false)
).then(addRegularEnabled);
} }
function addRegularEnabled() { async function addRegularEnabled() {
TestRunner.addResult('Adding regular enabled breakpoint'); TestRunner.addResult('Adding regular enabled breakpoint');
waitAndDumpDecorations(javaScriptSourceFrame).then(addConditionalEnabled); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, '', true); SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, '', true)
).then(addConditionalEnabled);
} }
function addConditionalEnabled() { function addConditionalEnabled() {
TestRunner.addResult('Adding conditional enabled breakpoint'); TestRunner.addResult('Adding conditional enabled breakpoint');
waitAndDumpDecorations(javaScriptSourceFrame).then(disableAll); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, 'true', true); SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 2, 'true', true)
).then(disableAll);
} }
function disableAll() { function disableAll() {
TestRunner.addResult('Disable breakpoints'); TestRunner.addResult('Disable breakpoints');
waitAndDumpDecorations(javaScriptSourceFrame).then(enabledAll); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 2, true); SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 2, true)
).then(enabledAll);
} }
function enabledAll() { function enabledAll() {
TestRunner.addResult('Enable breakpoints'); TestRunner.addResult('Enable breakpoints');
waitAndDumpDecorations(javaScriptSourceFrame).then(removeAll); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 2, true); SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 2, true)
).then(removeAll);
} }
function removeAll() { function removeAll() {
TestRunner.addResult('Remove breakpoints'); TestRunner.addResult('Remove breakpoints');
waitAndDumpDecorations(javaScriptSourceFrame).then(next); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 2, false); SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 2, false)
).then(next);
} }
} }
]); ]);
......
...@@ -30,10 +30,11 @@ ...@@ -30,10 +30,11 @@
//# sourceURL=foo.js //# sourceURL=foo.js
`); `);
function waitAndDumpDecorations(sourceFrame) { async function runAsyncBreakpointActionAndDumpDecorations(sourceFrame, action) {
return SourcesTestRunner.waitDebuggerPluginBreakpoints(sourceFrame) const waitPromise = SourcesTestRunner.waitDebuggerPluginBreakpoints(sourceFrame);
.then( await action();
() => SourcesTestRunner.dumpDebuggerPluginBreakpoints(sourceFrame)); await waitPromise;
SourcesTestRunner.dumpDebuggerPluginBreakpoints(sourceFrame);
} }
Bindings.breakpointManager._storage._breakpoints = new Map(); Bindings.breakpointManager._storage._breakpoints = new Map();
...@@ -45,14 +46,16 @@ ...@@ -45,14 +46,16 @@
function addBreakpoint(sourceFrame) { function addBreakpoint(sourceFrame) {
javaScriptSourceFrame = sourceFrame; javaScriptSourceFrame = sourceFrame;
TestRunner.addResult('Setting breakpoint'); TestRunner.addResult('Setting breakpoint');
SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 11, '', true) runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
.then(() => waitAndDumpDecorations(javaScriptSourceFrame).then(removeBreakpoint)); SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 11, '', true)
).then(removeBreakpoint);
} }
function removeBreakpoint() { function removeBreakpoint() {
TestRunner.addResult('Toggle breakpoint'); TestRunner.addResult('Toggle breakpoint');
waitAndDumpDecorations(javaScriptSourceFrame).then(() => next()); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 11); SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 11)
).then(next);
} }
}, },
...@@ -63,14 +66,16 @@ ...@@ -63,14 +66,16 @@
function addBreakpoint(sourceFrame) { function addBreakpoint(sourceFrame) {
javaScriptSourceFrame = sourceFrame; javaScriptSourceFrame = sourceFrame;
TestRunner.addResult('Setting breakpoint'); TestRunner.addResult('Setting breakpoint');
SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 13, '', true) runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
.then(() => waitAndDumpDecorations(javaScriptSourceFrame).then(removeBreakpoint)); SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 13, '', true)
).then(removeBreakpoint);
} }
function removeBreakpoint() { function removeBreakpoint() {
TestRunner.addResult('Toggle breakpoint'); TestRunner.addResult('Toggle breakpoint');
SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 13); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
waitAndDumpDecorations(javaScriptSourceFrame).then(() => next()); SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 13)
).then(next);
} }
}, },
...@@ -81,29 +86,33 @@ ...@@ -81,29 +86,33 @@
function addBreakpoint(sourceFrame) { function addBreakpoint(sourceFrame) {
javaScriptSourceFrame = sourceFrame; javaScriptSourceFrame = sourceFrame;
TestRunner.addResult('Setting breakpoint'); TestRunner.addResult('Setting breakpoint');
SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 11, '', true) runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
.then(() => waitAndDumpDecorations(javaScriptSourceFrame).then(clickBySecondLocation)); SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 11, '', true)
).then(clickBySecondLocation);
} }
function clickBySecondLocation() { function clickBySecondLocation() {
TestRunner.addResult('Click by second breakpoint'); TestRunner.addResult('Click by second breakpoint');
waitAndDumpDecorations(javaScriptSourceFrame).then(clickByFirstLocation); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.clickDebuggerPluginBreakpoint( SourcesTestRunner.clickDebuggerPluginBreakpoint(
javaScriptSourceFrame, 11, 1, next); javaScriptSourceFrame, 11, 1, next)
).then(clickByFirstLocation);
} }
function clickByFirstLocation() { function clickByFirstLocation() {
TestRunner.addResult('Click by first breakpoint'); TestRunner.addResult('Click by first breakpoint');
waitAndDumpDecorations(javaScriptSourceFrame).then(clickBySecondLocationAgain); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.clickDebuggerPluginBreakpoint( SourcesTestRunner.clickDebuggerPluginBreakpoint(
javaScriptSourceFrame, 11, 0, next); javaScriptSourceFrame, 11, 0, next)
).then(clickBySecondLocationAgain);
} }
function clickBySecondLocationAgain() { function clickBySecondLocationAgain() {
TestRunner.addResult('Click by second breakpoint'); TestRunner.addResult('Click by second breakpoint');
waitAndDumpDecorations(javaScriptSourceFrame).then(() => next()); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.clickDebuggerPluginBreakpoint( SourcesTestRunner.clickDebuggerPluginBreakpoint(
javaScriptSourceFrame, 11, 1, next); javaScriptSourceFrame, 11, 1, next)
).then(next);
} }
}, },
...@@ -114,23 +123,26 @@ ...@@ -114,23 +123,26 @@
function addBreakpoint(sourceFrame) { function addBreakpoint(sourceFrame) {
javaScriptSourceFrame = sourceFrame; javaScriptSourceFrame = sourceFrame;
TestRunner.addResult('Setting breakpoint in line 4'); TestRunner.addResult('Setting breakpoint in line 4');
SourcesTestRunner.toggleBreakpoint(sourceFrame, 12, false); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
waitAndDumpDecorations(javaScriptSourceFrame).then(toggleBreakpointInAnotherLine); SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 12, false)
).then(toggleBreakpointInAnotherLine);
} }
function toggleBreakpointInAnotherLine() { function toggleBreakpointInAnotherLine() {
TestRunner.addResult('Setting breakpoint in line 3'); TestRunner.addResult('Setting breakpoint in line 3');
waitAndDumpDecorations(javaScriptSourceFrame).then(removeBreakpoints); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 11, false); SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 11, false)
).then(removeBreakpoints);
} }
function removeBreakpoints() { function removeBreakpoints() {
TestRunner.addResult('Click by first inline breakpoints'); TestRunner.addResult('Click by first inline breakpoints');
waitAndDumpDecorations(javaScriptSourceFrame).then(() => next()); runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () => {
SourcesTestRunner.clickDebuggerPluginBreakpoint( SourcesTestRunner.clickDebuggerPluginBreakpoint(
javaScriptSourceFrame, 11, 0, next); javaScriptSourceFrame, 11, 0, next);
SourcesTestRunner.clickDebuggerPluginBreakpoint( SourcesTestRunner.clickDebuggerPluginBreakpoint(
javaScriptSourceFrame, 12, 0, next); javaScriptSourceFrame, 12, 0, next);
}).then(next);
} }
}, },
...@@ -138,13 +150,14 @@ ...@@ -138,13 +150,14 @@
let javaScriptSourceFrame = await SourcesTestRunner.showScriptSourcePromise('foo.js'); let javaScriptSourceFrame = await SourcesTestRunner.showScriptSourcePromise('foo.js');
TestRunner.addResult('Setting breakpoint'); TestRunner.addResult('Setting breakpoint');
await SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 16, '', true) await runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
await waitAndDumpDecorations(javaScriptSourceFrame); SourcesTestRunner.createNewBreakpoint(javaScriptSourceFrame, 16, '', true)
);
TestRunner.addResult('Toggle breakpoint'); TestRunner.addResult('Toggle breakpoint');
let decorationsPromise = waitAndDumpDecorations(javaScriptSourceFrame); await runAsyncBreakpointActionAndDumpDecorations(javaScriptSourceFrame, () =>
SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 28); SourcesTestRunner.toggleBreakpoint(javaScriptSourceFrame, 28)
await decorationsPromise; );
next(); next();
} }
]); ]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment