Commit 6eedda67 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

DevTools: skip all pauses during provisional load

On browser side we suspend message dispatching during provisional load,
so it is not possible to resume if pause happens.

R=dgozman@chromium.org

Bug: chromium:812091
Change-Id: Id9f7015febfb5ec868af2266aa8e3ca76eb7dd3d
Reviewed-on: https://chromium-review.googlesource.com/c/1252802Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596346}
parent d51a4ea9
<html>
<body onunload="debugger">
</body>
</html>
\ No newline at end of file
<script>console.log('ready')</script>
<body onunload="debugger"></body>
\ No newline at end of file
Tests that we skip all pauses during navigation
Navigate page..
Wait for ready message..
done!
Script execution paused.
Script execution resumed.
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(
`Tests that we skip all pauses during navigation`);
await TestRunner.loadModule('sources_test_runner');
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('sources');
await SourcesTestRunner.startDebuggerTestPromise();
await TestRunner.navigatePromise('resources/page-with-unload.html');
TestRunner.addResult('Navigate page..');
TestRunner.evaluateInPagePromise('window.location.href = window.location.href');
TestRunner.addResult('Wait for ready message..');
await ConsoleTestRunner.waitUntilMessageReceivedPromise();
TestRunner.addResult('done!');
await TestRunner.addIframe('http://127.0.0.1:8000/devtools/sources/debugger/resources/onunload.html', {
name: 'myIFrame'
});
ConsoleTestRunner.changeExecutionContext('myIFrame');
ConsoleTestRunner.evaluateInConsolePromise('window.location.href = window.location.href', true);
await SourcesTestRunner.waitUntilPausedPromise();
SourcesTestRunner.resumeExecution();
SourcesTestRunner.completeDebuggerTest();
})();
......@@ -496,6 +496,8 @@ void LocalFrameClientImpl::DispatchDidFailProvisionalLoad(
const ResourceError& error,
WebHistoryCommitType commit_type) {
web_frame_->DidFail(error, true, commit_type);
if (WebDevToolsAgentImpl* dev_tools = DevToolsAgent())
dev_tools->DidFailProvisionalLoad(web_frame_->GetFrame());
virtual_time_pauser_.UnpauseVirtualTime();
}
......
......@@ -412,12 +412,25 @@ void WebDevToolsAgentImpl::DidCommitLoadForLocalFrame(LocalFrame* frame) {
resource_content_loader_->DidCommitLoadForLocalFrame(frame);
for (auto& session : sessions_)
session->DidCommitLoadForLocalFrame(frame);
if (inspected_frames_->Root() == frame) {
for (auto& session : sessions_)
session->V8Session()->setSkipAllPauses(false);
}
}
void WebDevToolsAgentImpl::DidStartProvisionalLoad(LocalFrame* frame) {
void WebDevToolsAgentImpl::DidFailProvisionalLoad(LocalFrame* frame) {
if (inspected_frames_->Root() == frame) {
for (auto& session : sessions_)
session->V8Session()->setSkipAllPauses(false);
}
}
void WebDevToolsAgentImpl::DidStartProvisionalLoad(LocalFrame* frame) {
if (inspected_frames_->Root() == frame) {
for (auto& session : sessions_) {
session->V8Session()->setSkipAllPauses(true);
session->V8Session()->resume();
}
}
}
......
......@@ -83,6 +83,7 @@ class CORE_EXPORT WebDevToolsAgentImpl final
// Instrumentation from web/ layer.
void DidCommitLoadForLocalFrame(LocalFrame*);
void DidFailProvisionalLoad(LocalFrame*);
void DidStartProvisionalLoad(LocalFrame*);
bool ScreencastEnabled();
String NavigationInitiatorInfo(LocalFrame*);
......
......@@ -453,7 +453,6 @@ InspectorPageAgent::InspectorPageAgent(
: inspected_frames_(inspected_frames),
v8_session_(v8_session),
client_(client),
reloading_(false),
inspector_resource_content_loader_(resource_content_loader),
resource_content_loader_client_id_(
resource_content_loader->CreateClientId()),
......@@ -546,7 +545,6 @@ Response InspectorPageAgent::disable() {
stopScreencast();
FinishReload();
return Response::OK();
}
......@@ -647,7 +645,6 @@ Response InspectorPageAgent::reload(
pending_script_to_evaluate_on_load_once_ =
optional_script_to_evaluate_on_load.fromMaybe("");
v8_session_->setSkipAllPauses(true);
reloading_ = true;
return Response::OK();
}
......@@ -717,13 +714,6 @@ Response InspectorPageAgent::getFrameTree(
return Response::OK();
}
void InspectorPageAgent::FinishReload() {
if (!reloading_)
return;
reloading_ = false;
v8_session_->setSkipAllPauses(false);
}
void InspectorPageAgent::GetResourceContentAfterResourcesContentLoaded(
const String& frame_id,
const String& url,
......@@ -910,7 +900,6 @@ void InspectorPageAgent::LoadEventFired(LocalFrame* frame) {
void InspectorPageAgent::WillCommitLoad(LocalFrame*, DocumentLoader* loader) {
if (loader->GetFrame() == inspected_frames_->Root()) {
FinishReload();
script_to_evaluate_on_load_once_ = pending_script_to_evaluate_on_load_once_;
pending_script_to_evaluate_on_load_once_ = String();
}
......
......@@ -214,7 +214,6 @@ class CORE_EXPORT InspectorPageAgent final
InspectorResourceContentLoader*,
v8_inspector::V8InspectorSession*);
void FinishReload();
void GetResourceContentAfterResourcesContentLoaded(
const String& frame_id,
const String& url,
......@@ -242,7 +241,6 @@ class CORE_EXPORT InspectorPageAgent final
Client* client_;
String pending_script_to_evaluate_on_load_once_;
String script_to_evaluate_on_load_once_;
bool reloading_;
Member<InspectorResourceContentLoader> inspector_resource_content_loader_;
int resource_content_loader_client_id_;
InspectorAgentState::Boolean enabled_;
......
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