Commit 51470c5a authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Fix screen.orientation.lock() rejection and an integration test.

Unfortunately, we can't do more than a smoke test because Chromium
doesn't support fullscreen on Android. See http://crbug.com/401114

BUG=162827

Review URL: https://codereview.chromium.org/444033002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288048 0039d316-1c4b-4281-b951-d872f2087c98
parent 96faef9c
......@@ -144,6 +144,9 @@ IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, WindowOrientationChange) {
TestNavigationObserver navigation_observer(shell()->web_contents(), 1);
shell()->LoadURL(test_url);
navigation_observer.Wait();
#if USE_AURA
WaitForResizeComplete(shell()->web_contents());
#endif // USE_AURA
if (!WindowOrientationSupported())
return;
......@@ -160,4 +163,26 @@ IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, WindowOrientationChange) {
}
}
// Chromium Android does not support fullscreen
IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, LockSmoke) {
GURL test_url = GetTestUrl("screen_orientation",
"screen_orientation_lock_smoke.html");
TestNavigationObserver navigation_observer(shell()->web_contents(), 2);
shell()->LoadURL(test_url);
navigation_observer.Wait();
#if USE_AURA
WaitForResizeComplete(shell()->web_contents());
#endif // USE_AURA
std::string expected =
#if defined(OS_ANDROID)
"SecurityError"; // WebContents need to be fullscreen.
#else
"NotSupportedError"; // Locking isn't supported.
#endif
EXPECT_EQ(expected, shell()->web_contents()->GetLastCommittedURL().ref());
}
} // namespace content
......@@ -83,6 +83,13 @@ void ScreenOrientationDispatcherHost::NotifyLockError(
if (!render_frame_host)
return;
NotifyLockError(request_id, render_frame_host, error);
}
void ScreenOrientationDispatcherHost::NotifyLockError(
int request_id,
RenderFrameHost* render_frame_host,
blink::WebLockOrientationError error) {
render_frame_host->Send(new ScreenOrientationMsg_LockError(
render_frame_host->GetRoutingID(), request_id, error));
ResetCurrentLock();
......@@ -98,12 +105,12 @@ void ScreenOrientationDispatcherHost::OnLockRequest(
blink::WebScreenOrientationLockType orientation,
int request_id) {
if (current_lock_) {
NotifyLockError(current_lock_->request_id,
NotifyLockError(current_lock_->request_id, render_frame_host,
blink::WebLockOrientationErrorCanceled);
}
if (!provider_) {
NotifyLockError(request_id,
NotifyLockError(request_id, render_frame_host,
blink::WebLockOrientationErrorNotAvailable);
return;
}
......@@ -118,7 +125,7 @@ void ScreenOrientationDispatcherHost::OnLockRequest(
void ScreenOrientationDispatcherHost::OnUnlockRequest(
RenderFrameHost* render_frame_host) {
if (current_lock_) {
NotifyLockError(current_lock_->request_id,
NotifyLockError(current_lock_->request_id, render_frame_host,
blink::WebLockOrientationErrorCanceled);
}
......
......@@ -31,7 +31,14 @@ class CONTENT_EXPORT ScreenOrientationDispatcherHost
virtual bool OnMessageReceived(const IPC::Message&,
RenderFrameHost* render_frame_host) OVERRIDE;
// Notifies that the lock with the given |request_id| has succeeded.
// The renderer process will be notified that the lock succeeded only if
// |request_id| matches the |current_lock_|.
void NotifyLockSuccess(int request_id);
// Notifies that the lock with the given |request_id| has failed.
// The renderer process will be notified that the lock succeeded only if
// |request_id| matches the |current_lock_|.
void NotifyLockError(int request_id, blink::WebLockOrientationError error);
void OnOrientationChange();
......@@ -47,6 +54,9 @@ class CONTENT_EXPORT ScreenOrientationDispatcherHost
RenderFrameHost* GetRenderFrameHostForRequestID(int request_id);
void ResetCurrentLock();
void NotifyLockError(int request_id,
RenderFrameHost* render_frame_host,
blink::WebLockOrientationError error);
scoped_ptr<ScreenOrientationProvider> provider_;
......
<!DOCTYPE HTML>
<html>
<head>
</head>
<script>
screen.orientation.lock('landscape').then(function() {
document.location.hash =
screen.orientation.search("landscape") == 0 ? "#Pass" : "#Fail";
}, function(e) {
document.location.hash = "#" + e.name;
});
</script>
<body>
<div>Starting...</div>
</body>
</html>
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