Commit 4276111d authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[devtools] Don't continue execution after reload on breakpoint

This CL fixes an issue where JavaScript execution would continue
after reloading on a breakpoint. See design doc:
https://docs.google.com/document/d/1aO9v0YhoKNqKleqfACGUpwrBUayLFGqktz9ltdgKHMk

The CL depens on V8 change in crrev.com/c/1924366 and tests should fail until
that change is landed+rolled to chromium.

Fixed: 1004038
Fixed: 1014415
Change-Id: I182393ebd4c68588163dda7c607be8bb09a3eda3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1926502Reviewed-by: default avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738522}
parent 0371c2ff
...@@ -237,7 +237,7 @@ void DevToolsSession::DispatchProtocolCommandImpl( ...@@ -237,7 +237,7 @@ void DevToolsSession::DispatchProtocolCommandImpl(
void DevToolsSession::DidStartProvisionalLoad(LocalFrame* frame) { void DevToolsSession::DidStartProvisionalLoad(LocalFrame* frame) {
if (v8_session_ && agent_->inspected_frames_->Root() == frame) { if (v8_session_ && agent_->inspected_frames_->Root() == frame) {
v8_session_->setSkipAllPauses(true); v8_session_->setSkipAllPauses(true);
v8_session_->resume(); v8_session_->resume(true /* terminate on resume */);
} }
} }
......
Tests that reloading while paused at a breakpoint doesn't execute code after the breakpoint.
Setting a breakpoint.
Call stack:
0) divergingFunction (diverge-without-breakpoint.html:5)
1) (:1)
Reloading page...
Page reloaded.
(async function() {
TestRunner.addResult(
`Tests that reloading while paused at a breakpoint doesn't execute code after the breakpoint.\n`);
await TestRunner.loadModule('sources_test_runner');
await SourcesTestRunner.startDebuggerTestPromise(true);
await TestRunner.navigatePromise(
'../../sources/debugger-breakpoints/resources/diverge-without-breakpoint.html');
const sourceFrame = await SourcesTestRunner.showScriptSourcePromise(
'diverge-without-breakpoint.html');
TestRunner.addResult('Setting a breakpoint.');
await SourcesTestRunner.createNewBreakpoint(sourceFrame, 4, '', true)
SourcesTestRunner.waitUntilPaused(step1);
TestRunner.evaluateInPageWithTimeout(`divergingFunction()`);
async function step1(callFrames) {
SourcesTestRunner.captureStackTrace(callFrames);
TestRunner.addResult('Reloading page...');
TestRunner.reloadPage(onPageReloaded);
}
function onPageReloaded() {
TestRunner.completeTest();
}
})();
Tests that reloading while paused at a breakpoint doesn't execute code after the breakpoint.
Setting break on all exceptions.
Call stack:
0) divergingFunctionWithThrow (diverge-without-breakpoint-throw-on-load.html:6)
1) (:1)
Reloading page...
Page reloaded.
(async function() {
TestRunner.addResult(
`Tests that reloading while paused at a breakpoint doesn't execute code after the breakpoint.\n`);
await TestRunner.loadModule('sources_test_runner');
await SourcesTestRunner.startDebuggerTestPromise(true);
TestRunner.addResult('Setting break on all exceptions.');
TestRunner.DebuggerAgent.setPauseOnExceptions(
SDK.DebuggerModel.PauseOnExceptionsState.PauseOnAllExceptions);
SourcesTestRunner.waitUntilPaused(step1);
await TestRunner.navigatePromise(
'../../sources/debugger-breakpoints/resources/diverge-without-breakpoint-throw-on-load.html');
TestRunner.evaluateInPageWithTimeout(`divergingFunctionWithThrow()`);
async function step1(callFrames) {
SourcesTestRunner.captureStackTrace(callFrames);
TestRunner.addResult('Reloading page...');
TestRunner.reloadPage(onPageReloaded);
}
function onPageReloaded() {
TestRunner.completeTest();
}
})();
Tests that reloading while paused at a breakpoint doesn't execute code after the breakpoint.
Running: testFetchBreakpoint
Waiting for breakpoint.
Script execution paused.
Call stack:
0) divergingFunction (reload-on-breakpoint.js:7)
1) (:1)
Reloading page...
Script execution resumed.
Page reloaded.
(async function() {
TestRunner.addResult(
`Tests that reloading while paused at a breakpoint doesn't execute code after the breakpoint.\n`);
await TestRunner.loadModule('sources_test_runner');
await TestRunner.evaluateInPagePromise(`
function divergingFunction() {
debugger;
while(true) {};
}
`);
SourcesTestRunner.runDebuggerTestSuite([function testFetchBreakpoint(next) {
SourcesTestRunner.waitUntilPaused(step1);
TestRunner.addResult('Waiting for breakpoint.');
TestRunner.evaluateInPageWithTimeout('divergingFunction()');
function step1(callFrames) {
SourcesTestRunner.captureStackTrace(callFrames);
TestRunner.addResult('Reloading page...');
TestRunner.reloadPage(onPageReloaded);
}
function onPageReloaded() {
next();
}
}]);
})();
<html>
<head>
<script>
function divergingFunctionWithThrow() {
try {
throw new Error();
} catch (e) {}
while (true) {};
}
</script>
</head>
</html>
<html>
<head>
<script>
function divergingFunction() {
var a = 2;
while (true) {};
}
</script>
</head>
</html>
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