diff --git a/picture-in-picture/picture-in-picture-window.html b/picture-in-picture/picture-in-picture-window.html index 82d64577294b8d..693a13717e2e28 100644 --- a/picture-in-picture/picture-in-picture-window.html +++ b/picture-in-picture/picture-in-picture-window.html @@ -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()