Commit 51c9217b authored by Mounir Lamouri's avatar Mounir Lamouri Committed by Commit Bot

Picture-in-Picture: handle state changes to/from fullscreen.

Bug: 850479
Change-Id: Id1e953e3416f1f971f981bc5e5247fa40233538e
Reviewed-on: https://chromium-review.googlesource.com/1114256Reviewed-by: default avatarapacible <apacible@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570273}
parent 87be1019
...@@ -709,3 +709,54 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -709,3 +709,54 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
EXPECT_FALSE(first_controller->GetWindowForTesting()->IsVisible()); EXPECT_FALSE(first_controller->GetWindowForTesting()->IsVisible());
EXPECT_TRUE(second_controller->GetWindowForTesting()->IsVisible()); EXPECT_TRUE(second_controller->GetWindowForTesting()->IsVisible());
} }
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
EnterPictureInPictureThenFullscreen) {
LoadTabAndEnterPictureInPicture(browser());
content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(content::ExecuteScript(active_web_contents, "enterFullscreen()"));
base::string16 expected_title = base::ASCIIToUTF16("fullscreen");
EXPECT_EQ(expected_title,
content::TitleWatcher(active_web_contents, expected_title)
.WaitAndGetTitle());
EXPECT_TRUE(active_web_contents->IsFullscreenForCurrentTab());
EXPECT_FALSE(window_controller()->GetWindowForTesting()->IsVisible());
}
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
EnterFullscreenThenPictureInPicture) {
GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath(
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(active_web_contents != nullptr);
SetUpWindowController(active_web_contents);
ASSERT_TRUE(content::ExecuteScript(active_web_contents, "enterFullscreen()"));
base::string16 expected_title = base::ASCIIToUTF16("fullscreen");
EXPECT_EQ(expected_title,
content::TitleWatcher(active_web_contents, expected_title)
.WaitAndGetTitle());
ASSERT_TRUE(
content::ExecuteScript(active_web_contents, "enterPictureInPicture();"));
// Wait for resize event from the page.
expected_title = base::ASCIIToUTF16("1");
EXPECT_EQ(expected_title,
content::TitleWatcher(active_web_contents, expected_title)
.WaitAndGetTitle());
EXPECT_FALSE(active_web_contents->IsFullscreenForCurrentTab());
EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible());
}
...@@ -66,5 +66,13 @@ ...@@ -66,5 +66,13 @@
function secondPictureInPicture() { function secondPictureInPicture() {
secondVideo.requestPictureInPicture(); secondVideo.requestPictureInPicture();
} }
function enterFullscreen() {
video.webkitRequestFullscreen();
video.addEventListener('webkitfullscreenchange', () => {
document.title = 'fullscreen';
}, { once: true });
}
</script> </script>
</html> </html>
...@@ -2652,6 +2652,9 @@ void HTMLMediaElement::setMuted(bool muted) { ...@@ -2652,6 +2652,9 @@ void HTMLMediaElement::setMuted(bool muted) {
void HTMLMediaElement::enterPictureInPicture( void HTMLMediaElement::enterPictureInPicture(
WebMediaPlayer::PipWindowOpenedCallback callback) { WebMediaPlayer::PipWindowOpenedCallback callback) {
if (DisplayType() == WebMediaPlayer::DisplayType::kFullscreen)
Fullscreen::ExitFullscreen(GetDocument());
if (GetWebMediaPlayer()) if (GetWebMediaPlayer())
GetWebMediaPlayer()->EnterPictureInPicture(std::move(callback)); GetWebMediaPlayer()->EnterPictureInPicture(std::move(callback));
} }
...@@ -3645,6 +3648,9 @@ bool HTMLMediaElement::IsFullscreen() const { ...@@ -3645,6 +3648,9 @@ bool HTMLMediaElement::IsFullscreen() const {
void HTMLMediaElement::DidEnterFullscreen() { void HTMLMediaElement::DidEnterFullscreen() {
UpdateControlsVisibility(); UpdateControlsVisibility();
if (DisplayType() == WebMediaPlayer::DisplayType::kPictureInPicture)
exitPictureInPicture(base::DoNothing());
if (web_media_player_) { if (web_media_player_) {
// FIXME: There is no embedder-side handling in layout test mode. // FIXME: There is no embedder-side handling in layout test mode.
if (!LayoutTestSupport::IsRunningLayoutTest()) if (!LayoutTestSupport::IsRunningLayoutTest())
......
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