Commit ed8c12d4 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Reland "Fix orientation change test full-screen-orientation-change.html"

This is a reland of a4cdec69
I checked it does not change the FullscreenControllerTests tests.

Original change's description:
> Fix orientation change test full-screen-orientation-change.html
>
> There are two ways to trigger fullscreen, either by user activation or by
> a user generated orientation change. When we enter the fullscreen mode,
> we should not consume the user activation in the browser side when the
> fullscreen is triggered by a user generated orientation change, so we
> need to set the orientation change flag in the browser side when we are
> calling the mock function setMockScreenOrientation through a mojo
> message.
>
> The CL that consumes the user activation on both the browser and
> renderer sides when entering fullscreen:
> https://chromium-review.googlesource.com/c/chromium/src/+/1903675
>
>
> Bug: 1046933
> Change-Id: I1eb86205bc82ac237bc12d63bbdb0c8985c06090
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2026170
> Reviewed-by: Ken Buchanan <kenrb@chromium.org>
> Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
> Commit-Queue: Lan Wei <lanwei@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#740812}

TBR=kenrb@chromium.org,alexmos@chromium.org,lanwei@chromium.org

Bug: 1046933
Change-Id: Ieaa57d457edbfe8b432b02df65eed409f40e63dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2054844
Commit-Queue: Lan Wei <lanwei@chromium.org>
Reviewed-by: default avatarLan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741126}
parent 67a641bc
...@@ -4093,9 +4093,17 @@ void RenderFrameHostImpl::EnterFullscreen( ...@@ -4093,9 +4093,17 @@ void RenderFrameHostImpl::EnterFullscreen(
// by a user generated orientation change, because the fullscreen can be // by a user generated orientation change, because the fullscreen can be
// triggered by either a user activation or a user generated orientation // triggered by either a user activation or a user generated orientation
// change. // change.
// CanEnterFullscreenWithoutUserActivation is always false by default, so it
// keeps the current logic that we can enter fullscreen mode either by the
// orientation change or successfully consuming the user activation. This
// function is used for layout tests to allow fullscreen when mocking screen
// screen orientation changes.
// TODO(lanwei): Investigate whether we can terminate the renderer when the // TODO(lanwei): Investigate whether we can terminate the renderer when the
// user activation has already been consumed. // user activation has already been consumed.
if (!delegate_->HasSeenRecentScreenOrientationChange()) { if (!delegate_->HasSeenRecentScreenOrientationChange() &&
!GetContentClient()
->browser()
->CanEnterFullscreenWithoutUserActivation()) {
bool is_consumed = frame_tree_node_->UpdateUserActivationState( bool is_consumed = frame_tree_node_->UpdateUserActivationState(
blink::mojom::UserActivationUpdateType::kConsumeTransientActivation); blink::mojom::UserActivationUpdateType::kConsumeTransientActivation);
if (!is_consumed) { if (!is_consumed) {
......
...@@ -1050,6 +1050,10 @@ void ContentBrowserClient::IsClipboardPasteAllowed( ...@@ -1050,6 +1050,10 @@ void ContentBrowserClient::IsClipboardPasteAllowed(
std::move(callback).Run(ClipboardPasteAllowed(true)); std::move(callback).Run(ClipboardPasteAllowed(true));
} }
bool ContentBrowserClient::CanEnterFullscreenWithoutUserActivation() {
return false;
}
#if BUILDFLAG(ENABLE_PLUGINS) #if BUILDFLAG(ENABLE_PLUGINS)
bool ContentBrowserClient::ShouldAllowPluginCreation( bool ContentBrowserClient::ShouldAllowPluginCreation(
const url::Origin& embedder_origin, const url::Origin& embedder_origin,
......
...@@ -1795,6 +1795,11 @@ class CONTENT_EXPORT ContentBrowserClient { ...@@ -1795,6 +1795,11 @@ class CONTENT_EXPORT ContentBrowserClient {
const std::string& data, const std::string& data,
IsClipboardPasteAllowedCallback callback); IsClipboardPasteAllowedCallback callback);
// Allows the embedder to override normal user activation checks done when
// entering fullscreen. For example, it is used in layout tests to allow
// fullscreen when mock screen orientation changes.
virtual bool CanEnterFullscreenWithoutUserActivation();
#if BUILDFLAG(ENABLE_PLUGINS) #if BUILDFLAG(ENABLE_PLUGINS)
// Returns true if |embedder_origin| is allowed to embed a plugin described by // Returns true if |embedder_origin| is allowed to embed a plugin described by
// |plugin_info|. This method allows restricting some internal plugins (like // |plugin_info|. This method allows restricting some internal plugins (like
......
...@@ -78,4 +78,8 @@ void BlinkTestClientImpl::NavigateSecondaryWindow(const GURL& url) { ...@@ -78,4 +78,8 @@ void BlinkTestClientImpl::NavigateSecondaryWindow(const GURL& url) {
BlinkTestController::Get()->OnNavigateSecondaryWindow(url); BlinkTestController::Get()->OnNavigateSecondaryWindow(url);
} }
void BlinkTestClientImpl::SetScreenOrientationChanged() {
BlinkTestController::Get()->OnSetScreenOrientationChanged();
}
} // namespace content } // namespace content
...@@ -37,6 +37,7 @@ class BlinkTestClientImpl : public mojom::BlinkTestClient { ...@@ -37,6 +37,7 @@ class BlinkTestClientImpl : public mojom::BlinkTestClient {
void SetPopupBlockingEnabled(bool block_popups) override; void SetPopupBlockingEnabled(bool block_popups) override;
void LoadURLForFrame(const GURL& url, const std::string& frame_name) override; void LoadURLForFrame(const GURL& url, const std::string& frame_name) override;
void NavigateSecondaryWindow(const GURL& url) override; void NavigateSecondaryWindow(const GURL& url) override;
void SetScreenOrientationChanged() override;
DISALLOW_COPY_AND_ASSIGN(BlinkTestClientImpl); DISALLOW_COPY_AND_ASSIGN(BlinkTestClientImpl);
}; };
......
...@@ -547,6 +547,7 @@ bool BlinkTestController::ResetAfterWebTest() { ...@@ -547,6 +547,7 @@ bool BlinkTestController::ResetAfterWebTest() {
should_override_prefs_ = false; should_override_prefs_ = false;
WebTestContentBrowserClient::Get()->SetPopupBlockingEnabled(false); WebTestContentBrowserClient::Get()->SetPopupBlockingEnabled(false);
WebTestContentBrowserClient::Get()->ResetMockClipboardHost(); WebTestContentBrowserClient::Get()->ResetMockClipboardHost();
WebTestContentBrowserClient::Get()->SetScreenOrientationChanged(false);
navigation_history_dump_ = ""; navigation_history_dump_ = "";
pixel_dump_.reset(); pixel_dump_.reset();
actual_pixel_hash_ = ""; actual_pixel_hash_ = "";
...@@ -1272,6 +1273,10 @@ void BlinkTestController::OnInspectSecondaryWindow() { ...@@ -1272,6 +1273,10 @@ void BlinkTestController::OnInspectSecondaryWindow() {
devtools_bindings_->Attach(); devtools_bindings_->Attach();
} }
void BlinkTestController::OnSetScreenOrientationChanged() {
WebTestContentBrowserClient::Get()->SetScreenOrientationChanged(true);
}
base::FilePath BlinkTestController::GetWritableDirectoryForTests() { base::FilePath BlinkTestController::GetWritableDirectoryForTests() {
base::ScopedAllowBlockingForTesting allow_blocking; base::ScopedAllowBlockingForTesting allow_blocking;
if (writable_directory_for_tests_.IsValid()) { if (writable_directory_for_tests_.IsValid()) {
......
...@@ -202,6 +202,7 @@ class BlinkTestController : public WebContentsObserver, ...@@ -202,6 +202,7 @@ class BlinkTestController : public WebContentsObserver,
void OnLoadURLForFrame(const GURL& url, const std::string& frame_name); void OnLoadURLForFrame(const GURL& url, const std::string& frame_name);
void OnNavigateSecondaryWindow(const GURL& url); void OnNavigateSecondaryWindow(const GURL& url);
void OnBlockThirdPartyCookies(bool block); void OnBlockThirdPartyCookies(bool block);
void OnSetScreenOrientationChanged();
private: private:
enum TestPhase { BETWEEN_TESTS, DURING_TEST, CLEAN_UP }; enum TestPhase { BETWEEN_TESTS, DURING_TEST, CLEAN_UP };
......
...@@ -130,6 +130,11 @@ void WebTestContentBrowserClient::ResetMockClipboardHost() { ...@@ -130,6 +130,11 @@ void WebTestContentBrowserClient::ResetMockClipboardHost() {
mock_clipboard_host_->Reset(); mock_clipboard_host_->Reset();
} }
void WebTestContentBrowserClient::SetScreenOrientationChanged(
bool screen_orientation_changed) {
screen_orientation_changed_ = screen_orientation_changed;
}
std::unique_ptr<FakeBluetoothChooser> std::unique_ptr<FakeBluetoothChooser>
WebTestContentBrowserClient::GetNextFakeBluetoothChooser() { WebTestContentBrowserClient::GetNextFakeBluetoothChooser() {
if (!fake_bluetooth_chooser_factory_) if (!fake_bluetooth_chooser_factory_)
...@@ -363,6 +368,10 @@ content::TtsPlatform* WebTestContentBrowserClient::GetTtsPlatform() { ...@@ -363,6 +368,10 @@ content::TtsPlatform* WebTestContentBrowserClient::GetTtsPlatform() {
return WebTestTtsPlatform::GetInstance(); return WebTestTtsPlatform::GetInstance();
} }
bool WebTestContentBrowserClient::CanEnterFullscreenWithoutUserActivation() {
return screen_orientation_changed_;
}
void WebTestContentBrowserClient::BindClipboardHost( void WebTestContentBrowserClient::BindClipboardHost(
RenderFrameHost* render_frame_host, RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::ClipboardHost> receiver) { mojo::PendingReceiver<blink::mojom::ClipboardHost> receiver) {
......
...@@ -35,6 +35,7 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient { ...@@ -35,6 +35,7 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
WebTestBrowserContext* GetWebTestBrowserContext(); WebTestBrowserContext* GetWebTestBrowserContext();
void SetPopupBlockingEnabled(bool block_popups_); void SetPopupBlockingEnabled(bool block_popups_);
void ResetMockClipboardHost(); void ResetMockClipboardHost();
void SetScreenOrientationChanged(bool screen_orientation_changed);
// Retrieves the last created FakeBluetoothChooser instance. // Retrieves the last created FakeBluetoothChooser instance.
std::unique_ptr<FakeBluetoothChooser> GetNextFakeBluetoothChooser(); std::unique_ptr<FakeBluetoothChooser> GetNextFakeBluetoothChooser();
...@@ -77,6 +78,7 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient { ...@@ -77,6 +78,7 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
content::TtsControllerDelegate* GetTtsControllerDelegate() override; content::TtsControllerDelegate* GetTtsControllerDelegate() override;
content::TtsPlatform* GetTtsPlatform() override; content::TtsPlatform* GetTtsPlatform() override;
bool CanEnterFullscreenWithoutUserActivation() override;
// ShellContentBrowserClient overrides. // ShellContentBrowserClient overrides.
std::unique_ptr<LoginDelegate> CreateLoginDelegate( std::unique_ptr<LoginDelegate> CreateLoginDelegate(
...@@ -106,6 +108,7 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient { ...@@ -106,6 +108,7 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
std::unique_ptr<MockPlatformNotificationService> std::unique_ptr<MockPlatformNotificationService>
mock_platform_notification_service_; mock_platform_notification_service_;
bool block_popups_ = false; bool block_popups_ = false;
bool screen_orientation_changed_ = false;
// Stores the FakeBluetoothChooserFactory that produces FakeBluetoothChoosers. // Stores the FakeBluetoothChooserFactory that produces FakeBluetoothChoosers.
std::unique_ptr<FakeBluetoothChooserFactory> fake_bluetooth_chooser_factory_; std::unique_ptr<FakeBluetoothChooserFactory> fake_bluetooth_chooser_factory_;
......
...@@ -138,4 +138,8 @@ interface BlinkTestClient { ...@@ -138,4 +138,8 @@ interface BlinkTestClient {
// Naivgate a URL on the secondary window. // Naivgate a URL on the secondary window.
NavigateSecondaryWindow(url.mojom.Url url); NavigateSecondaryWindow(url.mojom.Url url);
// Mark the orientation changed in the browser process for the layout tests
// that request fullscreen on screen orientation change.
SetScreenOrientationChanged();
}; };
...@@ -654,6 +654,10 @@ void BlinkTestRunner::ForceTextInputStateUpdate(WebLocalFrame* frame) { ...@@ -654,6 +654,10 @@ void BlinkTestRunner::ForceTextInputStateUpdate(WebLocalFrame* frame) {
ForceTextInputStateUpdateForRenderFrame(RenderFrame::FromWebFrame(frame)); ForceTextInputStateUpdateForRenderFrame(RenderFrame::FromWebFrame(frame));
} }
void BlinkTestRunner::SetScreenOrientationChanged() {
GetBlinkTestClientRemote().SetScreenOrientationChanged();
}
// RenderViewObserver -------------------------------------------------------- // RenderViewObserver --------------------------------------------------------
void BlinkTestRunner::DidClearWindowObject(WebLocalFrame* frame) { void BlinkTestRunner::DidClearWindowObject(WebLocalFrame* frame) {
......
...@@ -139,6 +139,7 @@ class BlinkTestRunner : public RenderViewObserver, ...@@ -139,6 +139,7 @@ class BlinkTestRunner : public RenderViewObserver,
const blink::WebPluginParams& params) override; const blink::WebPluginParams& params) override;
void RunIdleTasks(base::OnceClosure callback) override; void RunIdleTasks(base::OnceClosure callback) override;
void ForceTextInputStateUpdate(blink::WebLocalFrame* frame) override; void ForceTextInputStateUpdate(blink::WebLocalFrame* frame) override;
void SetScreenOrientationChanged() override;
// Resets a RenderView to a known state for web tests. It is used both when // Resets a RenderView to a known state for web tests. It is used both when
// a RenderView is created and when reusing an existing RenderView for the // a RenderView is created and when reusing an existing RenderView for the
......
...@@ -35,26 +35,29 @@ void MockScreenOrientationClient::ResetData() { ...@@ -35,26 +35,29 @@ void MockScreenOrientationClient::ResetData() {
receivers_.Clear(); receivers_.Clear();
} }
void MockScreenOrientationClient::UpdateDeviceOrientation( bool MockScreenOrientationClient::UpdateDeviceOrientation(
blink::WebLocalFrame* main_frame, blink::WebLocalFrame* main_frame,
blink::WebScreenOrientationType orientation) { blink::WebScreenOrientationType orientation) {
main_frame_ = main_frame; main_frame_ = main_frame;
if (device_orientation_ == orientation) if (device_orientation_ == orientation)
return; return false;
device_orientation_ = orientation; device_orientation_ = orientation;
if (!IsOrientationAllowedByCurrentLock(orientation)) if (!IsOrientationAllowedByCurrentLock(orientation))
return; return false;
UpdateScreenOrientation(orientation); return UpdateScreenOrientation(orientation);
} }
void MockScreenOrientationClient::UpdateScreenOrientation( bool MockScreenOrientationClient::UpdateScreenOrientation(
blink::WebScreenOrientationType orientation) { blink::WebScreenOrientationType orientation) {
if (current_orientation_ == orientation) if (current_orientation_ == orientation)
return; return false;
current_orientation_ = orientation; current_orientation_ = orientation;
if (main_frame_) if (main_frame_) {
main_frame_->SendOrientationChangeEvent(); main_frame_->SendOrientationChangeEvent();
return true;
}
return false;
} }
blink::WebScreenOrientationType blink::WebScreenOrientationType
......
...@@ -29,7 +29,7 @@ class TEST_RUNNER_EXPORT MockScreenOrientationClient ...@@ -29,7 +29,7 @@ class TEST_RUNNER_EXPORT MockScreenOrientationClient
~MockScreenOrientationClient() override; ~MockScreenOrientationClient() override;
void ResetData(); void ResetData();
void UpdateDeviceOrientation(blink::WebLocalFrame* main_frame, bool UpdateDeviceOrientation(blink::WebLocalFrame* main_frame,
blink::WebScreenOrientationType orientation); blink::WebScreenOrientationType orientation);
blink::WebScreenOrientationType CurrentOrientationType() const; blink::WebScreenOrientationType CurrentOrientationType() const;
...@@ -50,7 +50,7 @@ class TEST_RUNNER_EXPORT MockScreenOrientationClient ...@@ -50,7 +50,7 @@ class TEST_RUNNER_EXPORT MockScreenOrientationClient
LockOrientationCallback callback); LockOrientationCallback callback);
void ResetLockSync(); void ResetLockSync();
void UpdateScreenOrientation(blink::WebScreenOrientationType); bool UpdateScreenOrientation(blink::WebScreenOrientationType);
bool IsOrientationAllowedByCurrentLock(blink::WebScreenOrientationType); bool IsOrientationAllowedByCurrentLock(blink::WebScreenOrientationType);
blink::WebScreenOrientationType SuitableOrientationForCurrentLock(); blink::WebScreenOrientationType SuitableOrientationForCurrentLock();
static unsigned OrientationTypeToAngle(blink::WebScreenOrientationType); static unsigned OrientationTypeToAngle(blink::WebScreenOrientationType);
......
...@@ -2170,8 +2170,11 @@ void TestRunner::SetMockScreenOrientation(const std::string& orientation_str) { ...@@ -2170,8 +2170,11 @@ void TestRunner::SetMockScreenOrientation(const std::string& orientation_str) {
blink::WebFrame* main_frame = window->webview()->MainFrame(); blink::WebFrame* main_frame = window->webview()->MainFrame();
// TODO(lukasza): Need to make this work for remote frames. // TODO(lukasza): Need to make this work for remote frames.
if (main_frame->IsWebLocalFrame()) { if (main_frame->IsWebLocalFrame()) {
mock_screen_orientation_client_.UpdateDeviceOrientation( bool screen_orientation_changed =
main_frame->ToWebLocalFrame(), orientation); mock_screen_orientation_client_.UpdateDeviceOrientation(
main_frame->ToWebLocalFrame(), orientation);
if (screen_orientation_changed)
delegate_->SetScreenOrientationChanged();
} }
} }
} }
......
...@@ -260,6 +260,9 @@ class WebTestDelegate { ...@@ -260,6 +260,9 @@ class WebTestDelegate {
// Forces a text input state update for the client of WebFrameWidget // Forces a text input state update for the client of WebFrameWidget
// associated with |frame|. // associated with |frame|.
virtual void ForceTextInputStateUpdate(blink::WebLocalFrame* frame) = 0; virtual void ForceTextInputStateUpdate(blink::WebLocalFrame* frame) = 0;
// Mark the orientation changed for fullscreen layout tests.
virtual void SetScreenOrientationChanged() = 0;
}; };
} // namespace test_runner } // namespace test_runner
......
...@@ -4556,10 +4556,6 @@ crbug.com/852645 external/wpt/fullscreen/api/element-request-fullscreen-twice-ma ...@@ -4556,10 +4556,6 @@ crbug.com/852645 external/wpt/fullscreen/api/element-request-fullscreen-twice-ma
crbug.com/852645 external/wpt/fullscreen/api/element-request-fullscreen-two-elements-manual.html [ Failure ] crbug.com/852645 external/wpt/fullscreen/api/element-request-fullscreen-two-elements-manual.html [ Failure ]
crbug.com/852645 external/wpt/fullscreen/api/element-request-fullscreen-two-iframes-manual.html [ Failure Timeout ] crbug.com/852645 external/wpt/fullscreen/api/element-request-fullscreen-two-iframes-manual.html [ Failure Timeout ]
# These tests are disabled temporarily until we plumb the orientation change information to the browser process in the SetMockScreenOrientation function.
crbug.com/1046933 fullscreen/full-screen-orientation-change.html [ Failure Timeout ]
crbug.com/1046933 virtual/android/fullscreen/full-screen-orientation-change.html [ Failure Timeout ]
# snav tests fail because of a DCHECK # snav tests fail because of a DCHECK
crbug.com/985520 virtual/focusless-spat-nav/fast/spatial-navigation/focusless/snav-focusless-enter-from-interest-a11y.html [ Crash ] crbug.com/985520 virtual/focusless-spat-nav/fast/spatial-navigation/focusless/snav-focusless-enter-from-interest-a11y.html [ Crash ]
crbug.com/985520 virtual/focusless-spat-nav/fast/spatial-navigation/focusless/snav-focusless-enter-from-interest.html [ Crash ] crbug.com/985520 virtual/focusless-spat-nav/fast/spatial-navigation/focusless/snav-focusless-enter-from-interest.html [ Crash ]
......
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