Commit 987cb78d authored by blundell's avatar blundell Committed by Commit bot

PlzNavigate: Eliminate test_runner bailing out of layout tests too early

//components/test_runner signals that a test is finished if it receives a
notificationDone signal from Javascript at a time when (a) it is waiting for
such a signal, (b) it does not think it is in the midst of a load, and (c) it
has no work in its queue. However, the definition of (b) is flawed for
browser-side navigation. The current definition for being in the midst of a
load is the time between WebFrameClient::didStartProvisionalLoad() being called
and WebFrameClient::didStopLoading() being called. However, for browser-side
navigations there is a period of time when navigation is ongoing but the
renderer has not yet received the didStartProvisionalLoad() callback. If
//components/test_runner gets a notificationDone signal during this period, it
can erroneously think that the test is finished.

This CL fixes the problem by having WebFrameTestProxy implement
WebFrameClient::didStartLoading(), teaching //components/test_runner to be
aware of the time period where a navigation is occurring, and using that as
input to decide whether a test is finished when it receives a notificationDone
signal.

Review-Url: https://codereview.chromium.org/2147633003
Cr-Commit-Position: refs/heads/master@{#412572}
parent 98591f54
...@@ -1555,6 +1555,7 @@ TestRunner::TestRunner(TestInterfaces* interfaces) ...@@ -1555,6 +1555,7 @@ TestRunner::TestRunner(TestInterfaces* interfaces)
main_view_(nullptr), main_view_(nullptr),
mock_content_settings_client_( mock_content_settings_client_(
new MockContentSettingsClient(&layout_test_runtime_flags_)), new MockContentSettingsClient(&layout_test_runtime_flags_)),
will_navigate_(false),
credential_manager_client_(new MockCredentialManagerClient), credential_manager_client_(new MockCredentialManagerClient),
mock_screen_orientation_client_(new MockScreenOrientationClient), mock_screen_orientation_client_(new MockScreenOrientationClient),
spellcheck_(new SpellCheckClient(this)), spellcheck_(new SpellCheckClient(this)),
...@@ -1586,6 +1587,7 @@ void TestRunner::SetMainView(WebView* web_view) { ...@@ -1586,6 +1587,7 @@ void TestRunner::SetMainView(WebView* web_view) {
void TestRunner::Reset() { void TestRunner::Reset() {
is_web_platform_tests_mode_ = false; is_web_platform_tests_mode_ = false;
will_navigate_ = false;
top_loading_frame_ = nullptr; top_loading_frame_ = nullptr;
layout_test_runtime_flags_.Reset(); layout_test_runtime_flags_.Reset();
mock_screen_orientation_client_->ResetData(); mock_screen_orientation_client_->ResetData();
...@@ -1836,7 +1838,13 @@ bool TestRunner::IsFramePartOfMainTestWindow(blink::WebFrame* frame) const { ...@@ -1836,7 +1838,13 @@ bool TestRunner::IsFramePartOfMainTestWindow(blink::WebFrame* frame) const {
return test_is_running_ && frame->top()->view() == main_view_; return test_is_running_ && frame->top()->view() == main_view_;
} }
void TestRunner::OnNavigationBegin(WebFrame* frame) {
if (IsFramePartOfMainTestWindow(frame))
will_navigate_ = true;
}
bool TestRunner::tryToSetTopLoadingFrame(WebFrame* frame) { bool TestRunner::tryToSetTopLoadingFrame(WebFrame* frame) {
will_navigate_ = false;
if (!IsFramePartOfMainTestWindow(frame)) if (!IsFramePartOfMainTestWindow(frame))
return false; return false;
...@@ -1850,6 +1858,7 @@ bool TestRunner::tryToSetTopLoadingFrame(WebFrame* frame) { ...@@ -1850,6 +1858,7 @@ bool TestRunner::tryToSetTopLoadingFrame(WebFrame* frame) {
} }
bool TestRunner::tryToClearTopLoadingFrame(WebFrame* frame) { bool TestRunner::tryToClearTopLoadingFrame(WebFrame* frame) {
will_navigate_ = false;
if (!IsFramePartOfMainTestWindow(frame)) if (!IsFramePartOfMainTestWindow(frame))
return false; return false;
...@@ -2735,7 +2744,7 @@ void TestRunner::CheckResponseMimeType() { ...@@ -2735,7 +2744,7 @@ void TestRunner::CheckResponseMimeType() {
void TestRunner::NotifyDone() { void TestRunner::NotifyDone() {
if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() &&
work_queue_.is_empty()) !will_navigate_ && work_queue_.is_empty())
delegate_->TestFinished(); delegate_->TestFinished();
layout_test_runtime_flags_.set_wait_until_done(false); layout_test_runtime_flags_.set_wait_until_done(false);
OnLayoutTestRuntimeFlagsChanged(); OnLayoutTestRuntimeFlagsChanged();
......
...@@ -99,6 +99,8 @@ class TestRunner : public WebTestRunner { ...@@ -99,6 +99,8 @@ class TestRunner : public WebTestRunner {
void SetFocus(blink::WebView* web_view, bool focus) override; void SetFocus(blink::WebView* web_view, bool focus) override;
// Methods used by WebViewTestClient and WebFrameTestClient. // Methods used by WebViewTestClient and WebFrameTestClient.
void OnNavigationBegin(blink::WebFrame* frame);
void OnNavigationEnd() { will_navigate_ = false; }
void OnAnimationScheduled(blink::WebWidget* widget); void OnAnimationScheduled(blink::WebWidget* widget);
void OnAnimationBegun(blink::WebWidget* widget); void OnAnimationBegun(blink::WebWidget* widget);
std::string GetAcceptLanguages() const; std::string GetAcceptLanguages() const;
...@@ -614,6 +616,12 @@ class TestRunner : public WebTestRunner { ...@@ -614,6 +616,12 @@ class TestRunner : public WebTestRunner {
bool use_mock_theme_; bool use_mock_theme_;
// This is true in the period between the start of a navigation and when the
// provisional load for that navigation is started. Note that when
// browser-side navigation is enabled there is an arbitrary gap between these
// two events.
bool will_navigate_;
std::unique_ptr<MockCredentialManagerClient> credential_manager_client_; std::unique_ptr<MockCredentialManagerClient> credential_manager_client_;
std::unique_ptr<MockScreenOrientationClient> mock_screen_orientation_client_; std::unique_ptr<MockScreenOrientationClient> mock_screen_orientation_client_;
std::unique_ptr<MockWebSpeechRecognizer> speech_recognizer_; std::unique_ptr<MockWebSpeechRecognizer> speech_recognizer_;
......
...@@ -512,6 +512,18 @@ void WebFrameTestClient::didFinishLoad(blink::WebLocalFrame* frame) { ...@@ -512,6 +512,18 @@ void WebFrameTestClient::didFinishLoad(blink::WebLocalFrame* frame) {
} }
} }
void WebFrameTestClient::didNavigateWithinPage(
blink::WebLocalFrame* frame,
const blink::WebHistoryItem& history_item,
blink::WebHistoryCommitType commit_type,
bool contentInitiated) {
test_runner_->OnNavigationEnd();
}
void WebFrameTestClient::didStartLoading(bool to_different_document) {
test_runner_->OnNavigationBegin(web_frame_test_proxy_base_->web_frame());
}
void WebFrameTestClient::didStopLoading() { void WebFrameTestClient::didStopLoading() {
test_runner_->tryToClearTopLoadingFrame( test_runner_->tryToClearTopLoadingFrame(
web_frame_test_proxy_base_->web_frame()); web_frame_test_proxy_base_->web_frame());
......
...@@ -84,6 +84,11 @@ class WebFrameTestClient : public blink::WebFrameClient { ...@@ -84,6 +84,11 @@ class WebFrameTestClient : public blink::WebFrameClient {
const blink::WebURLError& error, const blink::WebURLError& error,
blink::WebHistoryCommitType commit_type) override; blink::WebHistoryCommitType commit_type) override;
void didFinishLoad(blink::WebLocalFrame* frame) override; void didFinishLoad(blink::WebLocalFrame* frame) override;
void didNavigateWithinPage(blink::WebLocalFrame* frame,
const blink::WebHistoryItem& history_item,
blink::WebHistoryCommitType commit_type,
bool contentInitiated) override;
void didStartLoading(bool to_different_document) override;
void didStopLoading() override; void didStopLoading() override;
void didDetectXSS(const blink::WebURL& insecure_url, void didDetectXSS(const blink::WebURL& insecure_url,
bool did_block_entire_page) override; bool did_block_entire_page) override;
......
...@@ -163,6 +163,16 @@ class WebFrameTestProxy : public Base, public WebFrameTestProxyBase { ...@@ -163,6 +163,16 @@ class WebFrameTestProxy : public Base, public WebFrameTestProxyBase {
test_client()->didFinishLoad(frame); test_client()->didFinishLoad(frame);
} }
void didNavigateWithinPage(blink::WebLocalFrame* frame,
const blink::WebHistoryItem& history_item,
blink::WebHistoryCommitType commit_type,
bool content_initiated) override {
Base::didNavigateWithinPage(frame, history_item, commit_type,
content_initiated);
test_client()->didNavigateWithinPage(frame, history_item, commit_type,
content_initiated);
}
void didStopLoading() override { void didStopLoading() override {
Base::didStopLoading(); Base::didStopLoading();
test_client()->didStopLoading(); test_client()->didStopLoading();
...@@ -263,6 +273,11 @@ class WebFrameTestProxy : public Base, public WebFrameTestProxyBase { ...@@ -263,6 +273,11 @@ class WebFrameTestProxy : public Base, public WebFrameTestProxyBase {
return Base::decidePolicyForNavigation(info); return Base::decidePolicyForNavigation(info);
} }
void didStartLoading(bool to_different_document) override {
Base::didStartLoading(to_different_document);
test_client()->didStartLoading(to_different_document);
}
void willStartUsingPeerConnectionHandler( void willStartUsingPeerConnectionHandler(
blink::WebRTCPeerConnectionHandler* handler) override { blink::WebRTCPeerConnectionHandler* handler) override {
// RenderFrameImpl::willStartUsingPeerConnectionHandler can not be mocked. // RenderFrameImpl::willStartUsingPeerConnectionHandler can not be mocked.
......
# These tests currently fail when run with --enable-browser-side-navigation # These tests currently fail when run with --enable-browser-side-navigation
# See https://crbug.com/576261 # See https://crbug.com/576261
# before-unload issues # before-unload issues
fast/loader/recursive-before-unload-crash.html [ Failure ]
virtual/pointerevent/fast/events/before-unload-forbidden-navigation.html [ Crash ] virtual/pointerevent/fast/events/before-unload-forbidden-navigation.html [ Crash ]
virtual/pointerevent/fast/events/before-unload-in-subframe.html [ Crash ] virtual/pointerevent/fast/events/before-unload-in-subframe.html [ Crash ]
...@@ -103,7 +102,6 @@ ...@@ -103,7 +102,6 @@
# https://crbug.com/576270: Move mixed-content checks that happen during # https://crbug.com/576270: Move mixed-content checks that happen during
# navigation to the browser # navigation to the browser
http/tests/security/mixedContent/insecure-prefetch-in-main-frame.html [ Failure ]
http/tests/security/mixedContent/nonwebby-scheme-in-iframe-allowed.https.html [ Timeout Failure ] http/tests/security/mixedContent/nonwebby-scheme-in-iframe-allowed.https.html [ Timeout Failure ]
http/tests/security/mixedContent/redirect-http-to-https-iframe-in-main-frame.html [ Failure ] http/tests/security/mixedContent/redirect-http-to-https-iframe-in-main-frame.html [ Failure ]
http/tests/security/mixedContent/redirect-https-to-http-iframe-in-main-frame.html [ Failure ] http/tests/security/mixedContent/redirect-https-to-http-iframe-in-main-frame.html [ Failure ]
...@@ -116,7 +114,6 @@ ...@@ -116,7 +114,6 @@
http/tests/security/w3c/cross-origin-objects.html [ Crash Timeout Failure ] http/tests/security/w3c/cross-origin-objects.html [ Crash Timeout Failure ]
# Untriaged navigation # Untriaged navigation
compositing/gestures/gesture-tapHighlight-simple-navigate.html [ Failure ]
fast/loader/document-destruction-within-unload.html [ Crash ] fast/loader/document-destruction-within-unload.html [ Crash ]
fast/loader/scroll-position-restored-on-reload-at-load-event.html [ Failure ] fast/loader/scroll-position-restored-on-reload-at-load-event.html [ Failure ]
fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html [ Crash Timeout ] fast/loader/stateobjects/pushstate-with-fragment-urls-and-hashchange.html [ Crash Timeout ]
...@@ -165,10 +162,6 @@ ...@@ -165,10 +162,6 @@
imported/wpt/html/semantics/embedded-content/the-object-element/object-attributes.html [ Failure ] imported/wpt/html/semantics/embedded-content/the-object-element/object-attributes.html [ Failure ]
plugins/object-onfocus-mutation-crash.html [ Timeout ] plugins/object-onfocus-mutation-crash.html [ Timeout ]
svg/custom/anchor-on-use.svg [ Failure ] svg/custom/anchor-on-use.svg [ Failure ]
svg/dynamic-updates/SVGAElement-dom-href-attr.html [ Failure ]
svg/dynamic-updates/SVGAElement-dom-target-attr.html [ Failure ]
svg/dynamic-updates/SVGAElement-svgdom-href-prop.html [ Failure ]
svg/dynamic-updates/SVGAElement-svgdom-target-prop.html [ Failure ]
virtual/pointerevent/fast/events/drag-file-crash.html [ Failure ] virtual/pointerevent/fast/events/drag-file-crash.html [ Failure ]
virtual/pointerevent/fast/events/iframe-object-onload.html [ Failure ] virtual/pointerevent/fast/events/iframe-object-onload.html [ Failure ]
virtual/spv2/fast/overflow/overflow-height-float-not-removed-crash.html [ Failure ] virtual/spv2/fast/overflow/overflow-height-float-not-removed-crash.html [ Failure ]
......
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