| <!DOCTYPE html> |
| <script src="../../../resources/js-test-pre.js"></script> |
| <script src="../resources/media-controls-utils.js" type="text/javascript"></script> |
| <body> |
| <video src="../../content/test.mp4" style="width: 320px; height: 240px;" controls autoplay></video> |
| <script type="text/javascript"> |
| |
| window.jsTestIsAsync = true; |
| |
| description("Testing media is paused and resumed when pressing the space bar in fullscreen."); |
| |
| const media = document.querySelector("video"); |
| const button = document.body.appendChild(document.createElement("button")); |
| button.textContent = "Enter Fullscreen"; |
| |
| media.addEventListener("webkitfullscreenchange", () => { |
| debug(""); |
| debug("Obtained a 'webkitfullscreenchange' event."); |
| |
| if (playCount == 1) { |
| shouldBecomeEqual('media.webkitDisplayingFullscreen', 'true', () => { |
| shouldBeFalse("media.paused"); |
| pressSpace(); |
| }); |
| } else |
| endTest(); |
| }); |
| |
| let playCount = 0; |
| media.addEventListener("play", () => { |
| playCount++; |
| |
| debug(""); |
| debug("Obtained a 'play' event."); |
| |
| if (playCount == 1) |
| startTest(); |
| else |
| media.webkitExitFullscreen(); |
| }); |
| |
| media.addEventListener("pause", () => { |
| debug(""); |
| debug("Obtained a 'pause' event."); |
| |
| // Test pressing the space bar while the media is paused. |
| pressSpace(); |
| }); |
| |
| function enterFullscreen() { |
| debug(""); |
| debug("Entering fullscreen."); |
| button.addEventListener("click", () => { |
| try { |
| media.webkitEnterFullscreen(); |
| } catch(e) { |
| debug("Toggling fullscreen failed."); |
| finishJSTest(); |
| } |
| }); |
| |
| pressOnElement(button); |
| } |
| |
| function pressSpace() |
| { |
| debug(""); |
| debug("Pressing the space bar."); |
| eventSender.keyDown(" "); |
| } |
| |
| function startTest() |
| { |
| enterFullscreen(); |
| } |
| |
| function endTest() |
| { |
| debug(""); |
| button.remove(); |
| media.remove(); |
| finishJSTest(); |
| } |
| |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |