Commit 1f76cc49 authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

DevTools: flush navigation events synchronously.

This allows associating navigation events with the input, the way it was
supposed to be at the first place.

By default, inspector events are coalesced and only flushed upon either
protocol command ack or blink task end. It is essential to not
compromise runtime performance. It is also essential to push notify in-time
for selected navigations and we already did that for many events, just
not the navigation ones. Fixing this.

Change-Id: I0b765bd634b3c03b64249150734e1368327b5b0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083562
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746637}
parent bbffb1ac
......@@ -932,10 +932,12 @@ bool InspectorPageAgent::ScreencastEnabled() {
void InspectorPageAgent::FrameStartedLoading(LocalFrame* frame) {
GetFrontend()->frameStartedLoading(IdentifiersFactory::FrameId(frame));
GetFrontend()->flush();
}
void InspectorPageAgent::FrameStoppedLoading(LocalFrame* frame) {
GetFrontend()->frameStoppedLoading(IdentifiersFactory::FrameId(frame));
GetFrontend()->flush();
}
void InspectorPageAgent::FrameRequestedNavigation(
......@@ -945,6 +947,7 @@ void InspectorPageAgent::FrameRequestedNavigation(
GetFrontend()->frameRequestedNavigation(
IdentifiersFactory::FrameId(target_frame),
ClientNavigationReasonToProtocol(reason), url.GetString());
GetFrontend()->flush();
}
void InspectorPageAgent::FrameScheduledNavigation(
......@@ -955,11 +958,13 @@ void InspectorPageAgent::FrameScheduledNavigation(
GetFrontend()->frameScheduledNavigation(
IdentifiersFactory::FrameId(frame), delay.InSecondsF(),
ClientNavigationReasonToProtocol(reason), url.GetString());
GetFrontend()->flush();
}
void InspectorPageAgent::FrameClearedScheduledNavigation(LocalFrame* frame) {
GetFrontend()->frameClearedScheduledNavigation(
IdentifiersFactory::FrameId(frame));
GetFrontend()->flush();
}
void InspectorPageAgent::WillRunJavaScriptDialog() {
......@@ -992,6 +997,7 @@ void InspectorPageAgent::LifecycleEvent(LocalFrame* frame,
GetFrontend()->lifecycleEvent(IdentifiersFactory::FrameId(frame),
IdentifiersFactory::LoaderId(loader), name,
timestamp);
GetFrontend()->flush();
}
void InspectorPageAgent::PaintTiming(Document* document,
......@@ -1028,6 +1034,7 @@ void InspectorPageAgent::WindowOpen(Document* document,
GetFrontend()->windowOpen(completed_url.GetString(), window_name,
GetEnabledWindowFeatures(window_features),
user_gesture);
GetFrontend()->flush();
}
std::unique_ptr<protocol::Page::Frame> InspectorPageAgent::BuildObjectForFrame(
......
......@@ -2,9 +2,11 @@
const {page, session, dp} = await testRunner.startBlank(
`Tests that execution contexts are reported for frames that were blocked due to mixed content when runtime is enabled *before* navigation.`);
await dp.Runtime.enable();
let count = 0;
dp.Runtime.onExecutionContextCreated(event => {
testRunner.log(event);
if (++count === 2) // page context + frame context.
testRunner.completeTest();
});
await page.navigate('https://devtools.test:8443/inspector-protocol/resources/mixed-content.html');
testRunner.completeTest();
})
Tests that page events are associated with the input
Before release
{
method : Page.frameRequestedNavigation
params : {
frameId : <string>
reason : anchorClick
url : http://127.0.0.1:8000/inspector-protocol/resources/inspector-protocol-page.html
}
sessionId : <string>
}
After release
Tests that page events are associated with the input
Before release
{
method : Page.frameRequestedNavigation
params : {
frameId : <string>
reason : anchorClick
url : http://127.0.0.1:8000/inspector-protocol/resources/inspector-protocol-page.html
}
sessionId : <string>
}
After release
(async function(testRunner) {
var {page, session, dp} = await testRunner.startHTML(`
<a href="">
<div style="width:1000px; height: 1000px" href="http://127.0.0.1:8000/inspector-protocol/resources/blank.html">LINK</div>
</a>
`, 'Tests that page events are associated with the input');
await dp.Page.enable();
dp.Page.onFrameRequestedNavigation(event => testRunner.log(event));
// Click.
await dp.Input.dispatchMouseEvent({type: 'mouseMoved', button: 'left', buttons: 0, clickCount: 1, x: 150, y: 150 });
await dp.Input.dispatchMouseEvent({type: 'mousePressed', button: 'left', buttons: 0, clickCount: 1, x: 150, y: 150 });
testRunner.log('Before release');
await dp.Input.dispatchMouseEvent({type: 'mouseReleased', button: 'left', buttons: 1, clickCount: 1, x: 150, y: 150 });
testRunner.log('After release');
testRunner.completeTest();
})
(async function(testRunner) {
var {page, session, dp} = await testRunner.startHTML(`
<a href="">
<div style="width:1000px; height: 1000px" href="http://localhost:8000/inspector-protocol/resources/blank.html">LINK</div>
</a>
`, 'Tests that page events are associated with the input');
await dp.Page.enable();
dp.Page.onFrameRequestedNavigation(event => testRunner.log(event));
// Click.
await dp.Input.dispatchMouseEvent({type: 'mouseMoved', button: 'left', buttons: 0, clickCount: 1, x: 150, y: 150 });
await dp.Input.dispatchMouseEvent({type: 'mousePressed', button: 'left', buttons: 0, clickCount: 1, x: 150, y: 150 });
testRunner.log('Before release');
await dp.Input.dispatchMouseEvent({type: 'mouseReleased', button: 'left', buttons: 1, clickCount: 1, x: 150, y: 150 });
testRunner.log('After release');
testRunner.completeTest();
})
Tests frame lifetime events.
Attached
RequestWillBeSent .../inspector-protocol/resources/blank.html
Started loading
RequestWillBeSent .../inspector-protocol/resources/blank.html
Navigated
Started loading
Navigated
......
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