Skip to content

Commit

Permalink
[Picture-in-Picture] Resolve with current window if video is pipElement.
Browse files Browse the repository at this point in the history
This make sures requestPictureInPicture is resolved with existing
Picture-in-Picture window when video is already pictureInPictureElement.

Bug: 806249
Change-Id: I16e3fc2e8e19c2b623e8d2518fe4672a2a16b756
Reviewed-on: https://chromium-review.googlesource.com/1101686
Commit-Queue: François Beaufort <[email protected]>
Reviewed-by: Mounir Lamouri <[email protected]>
Cr-Commit-Position: refs/heads/master@{#567934}
  • Loading branch information
beaufortfrancois authored and chromium-wpt-export-bot committed Jun 18, 2018
1 parent f055233 commit d42d45d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions picture-in-picture/picture-in-picture-window.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,34 @@

promise_test(async t => {
const video = await loadVideo();

video.addEventListener('leavepictureinpicture', t.step_func_done(event => {
assert_unreached('leavepictureinpicture event should not fire.')
}));

let enterCounts = 0;
video.addEventListener('enterpictureinpicture', event => {
enterCounts++;
});

return requestPictureInPictureWithTrustedClick(video)
.then(pipWindow1 => {
pipWindow1.onresize = function foo() {};
return requestPictureInPictureWithTrustedClick(video)
.then(pipWindow2 => {
assert_equals(pipWindow1, pipWindow2);
assert_equals(pipWindow1.width, pipWindow2.width);
assert_equals(pipWindow1.height, pipWindow2.height);
assert_equals(pipWindow1.onresize, pipWindow2.onresize);
assert_equals(enterCounts, 1);
});
});
}, 'Picture-in-Picture window is unchanged after entering ' +
'Picture-in-Picture for video already in Picture-in-Picture');

promise_test(async t => {
const video = await loadVideo();

return requestPictureInPictureWithTrustedClick(video)
.then(pipWindow => {
return document.exitPictureInPicture()
Expand Down

0 comments on commit d42d45d

Please sign in to comment.