Commit 7a166c31 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

Headless: fix virtual time unpausing when loading a document

This is a follow up to https://chromium-review.googlesource.com/c/1401238 that
fixes unpausing of virtual time.

Change-Id: Iec1d96000e7468b0dd45d3e7db43d80e902515b0
Reviewed-on: https://chromium-review.googlesource.com/c/1441646
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Auto-Submit: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626874}
parent dffd42ff
Tests that virtual time pausing during loading of main resource works correctly when dialog is shown while page loads.
// 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.
const server = new Map([
['http://test.com/index.html',
'<html><body><script>alert("No pasarán!");</script></body></html>']]);
(async function(testRunner) {
var {page, session, dp} = await testRunner.startBlank(
'Tests that virtual time pausing during loading of main resource ' +
'works correctly when dialog is shown while page loads.');
await dp.Network.enable();
await dp.Network.setRequestInterception({ patterns: [{ urlPattern: '*' }] });
dp.Network.onRequestIntercepted(event => {
let body = server.get(event.params.request.url);
dp.Network.continueInterceptedRequest({
interceptionId: event.params.interceptionId,
rawResponse: btoa(body)
});
});
dp.Page.onJavascriptDialogOpening(event => {
dp.Page.handleJavaScritpDialog({accept: true});
});
dp.Emulation.onVirtualTimeBudgetExpired(async data => {
testRunner.log(await session.evaluate('document.title'));
testRunner.completeTest();
});
await dp.Emulation.setVirtualTimePolicy({policy: 'pause'});
await dp.Emulation.setVirtualTimePolicy({
policy: 'pauseIfNetworkFetchesPending', budget: 5000,
waitForNavigation: true});
await dp.Page.navigate({url: 'http://test.com/index.html'});
})
......@@ -231,6 +231,8 @@ HEADLESS_PROTOCOL_TEST(VirtualTimeErrorLoop,
"emulation/virtual-time-error-loop.js");
HEADLESS_PROTOCOL_TEST(VirtualTimeFetchStream,
"emulation/virtual-time-fetch-stream.js");
HEADLESS_PROTOCOL_TEST(VirtualTimeDialogWhileLoading,
"emulation/virtual-time-dialog-while-loading.js");
// Flaky Test crbug.com/859382
HEADLESS_PROTOCOL_TEST(DISABLED_VirtualTimeHistoryNavigation,
......
......@@ -937,12 +937,13 @@ void DocumentLoader::StopLoading() {
void DocumentLoader::SetDefersLoading(bool defers) {
defers_loading_ = defers;
Fetcher()->SetDefersLoading(defers);
if (body_loader_)
if (body_loader_) {
body_loader_->SetDefersLoading(defers);
if (defers_loading_)
virtual_time_pauser_.UnpauseVirtualTime();
else
virtual_time_pauser_.PauseVirtualTime();
if (defers_loading_)
virtual_time_pauser_.UnpauseVirtualTime();
else
virtual_time_pauser_.PauseVirtualTime();
}
}
void DocumentLoader::DetachFromFrame(bool flush_microtask_queue) {
......
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