| <!DOCTYPE html> |
| <script src="../../../resources/js-test-pre.js"></script> |
| <body> |
| <video src="../../content/test.mp4" style="position: absolute; top: 0; left: 0; width: 320px; height: 240px;" controls autoplay></video> |
| <div id="shadow"></div> |
| <script type="text/javascript"> |
| |
| window.jsTestIsAsync = true; |
| |
| description("Testing that entering fullscreen, then going into picture-in-picture and then going back to inline presents inline controls."); |
| |
| if (window.internals) { |
| internals.settings.setAllowsPictureInPictureMediaPlayback(true); |
| internals.setMockVideoPresentationModeEnabled(true); |
| } |
| |
| const media = document.querySelector("video"); |
| const shadowRoot = window.internals.shadowRoot(media); |
| |
| media.addEventListener("play", () => { |
| debug(""); |
| shouldBeTrue("shadowRoot.querySelector('.media-controls').classList.contains('inline')"); |
| debug("Media started playing, we pause it and enter fullscreen by clicking on the matching button."); |
| |
| media.pause(); |
| window.requestAnimationFrame(() => clickOnElement(shadowRoot.querySelector("button.fullscreen"))); |
| }); |
| |
| media.addEventListener("webkitpresentationmodechanged", async () => { |
| debug(""); |
| debug(`Media received a webkitpresentationmodechanged event, media.webkitPresentationMode = ${media.webkitPresentationMode}.`); |
| |
| if (window.internals) { |
| await new Promise((resolve, reject) => { |
| setTimeout(reject, 2000); |
| shouldBecomeEqual("internals.isChangingPresentationMode(media)", "false", resolve); |
| }); |
| } |
| |
| switch (media.webkitPresentationMode) { |
| case "fullscreen": |
| window.requestAnimationFrame(() => { |
| shouldBeTrue("shadowRoot.querySelector('.media-controls').classList.contains('fullscreen')"); |
| |
| debug(""); |
| debug("We enter picture-in-picture by clicking on the matching button."); |
| clickOnElement(shadowRoot.querySelector("button.pip")); |
| }); |
| break; |
| case "picture-in-picture": |
| debug(""); |
| debug("We exit picture-in-picture."); |
| window.setTimeout(() => media.webkitSetPresentationMode("inline")); |
| break; |
| case "inline": |
| window.requestAnimationFrame(() => { |
| shouldBeTrue("shadowRoot.querySelector('.media-controls').classList.contains('inline')"); |
| |
| debug(""); |
| media.remove(); |
| finishJSTest(); |
| }); |
| break; |
| } |
| }); |
| |
| function clickOnElement(element) |
| { |
| const bounds = element.getBoundingClientRect(); |
| eventSender.mouseMoveTo(bounds.left + 1, bounds.top + 1); |
| eventSender.mouseDown(); |
| eventSender.mouseUp(); |
| } |
| |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |