2019-08-27 15:23:46 +00:00
<!DOCTYPE html>
< html >
< head >
< script src = "video-test.js" > < / script >
< script src = "media-file.js" > < / script >
< script >
var eventCount = 0;
function go()
{
2020-06-02 22:26:02 +00:00
if (window.internals) {
internals.settings.setAllowsPictureInPictureMediaPlayback(true);
internals.setMockVideoPresentationModeEnabled(true);
}
2019-08-27 15:23:46 +00:00
findMediaElement();
run('video.src = findMediaFile("video", "content/test")');
waitForEventOnce('canplaythrough', canPlayThrough);
}
function canPlayThrough()
{
runWithKeyDown('video.play()');
runWithKeyDown('video.webkitSetPresentationMode("picture-in-picture")');
waitForEventOnce("webkitpresentationmodechanged", presentationModeChanged1);
}
2020-06-02 22:26:02 +00:00
async function presentationModeChanged1()
2019-08-27 15:23:46 +00:00
{
2020-10-22 15:22:39 +00:00
await testExpectedEventually("internals.isChangingPresentationMode(video)", false);
2019-08-27 15:23:46 +00:00
testExpected("video.webkitPresentationMode", "picture-in-picture");
runWithKeyDown('video.webkitSetPresentationMode("inline")');
waitForEvent("webkitpresentationmodechanged", presentationModeChanged2);
}
function presentationModeChanged2()
{
switch (++eventCount)
{
case 1:
testExpected("video.webkitPresentationMode", "inline");
setTimeout(endTest, 200);
break;
default:
failTest("'webkitpresentationmodechanged' event fired again");
break;
}
}
< / script >
< / head >
< body onload = "go()" >
< div > This tests that the "webkitpresentationmodechanged" event is fired only once when the browser switches back to inline from the picture-in-picture mode.< / div >
< video controls > < / video >
< / body >
< / html >