Title: [225209] trunk
- Revision
- 225209
- Author
- [email protected]
- Date
- 2017-11-28 04:31:21 -0800 (Tue, 28 Nov 2017)
Log Message
Pressing the space bar while watching a fullscreen video doesn't play or pause
https://bugs.webkit.org/show_bug.cgi?id=180033
<rdar://problem/33610443>
Reviewed by Eric Carlson.
Source/WebCore:
We register a "keydown" event to track when the space bar is pressed, and if the media is playing
in fullscreen, we toggle playback. This does not interfere with full keyboard access since activating
one of the media controls using the keyboard will not let the events we register for be dispatched
this far along the event dispatch phase.
Test: media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback.html
* Modules/modern-media-controls/media/media-controller.js:
(MediaController):
(MediaController.prototype.togglePlayback): Add a catch() statement since calling play() could sometime
lead to some extraneous unhandled promise console logging that pollutes test output.
(MediaController.prototype.handleEvent):
LayoutTests:
Adding a new macOS-only test that checks that pressing the space bar while playing fullscreen
pauses the media and resumes it when pressing the space bar again.
* media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback-expected.txt: Added.
* media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback.html: Added.
* platform/ios-simulator/TestExpectations:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (225208 => 225209)
--- trunk/LayoutTests/ChangeLog 2017-11-28 07:55:36 UTC (rev 225208)
+++ trunk/LayoutTests/ChangeLog 2017-11-28 12:31:21 UTC (rev 225209)
@@ -1,3 +1,18 @@
+2017-11-28 Antoine Quint <[email protected]>
+
+ Pressing the space bar while watching a fullscreen video doesn't play or pause
+ https://bugs.webkit.org/show_bug.cgi?id=180033
+ <rdar://problem/33610443>
+
+ Reviewed by Eric Carlson.
+
+ Adding a new macOS-only test that checks that pressing the space bar while playing fullscreen
+ pauses the media and resumes it when pressing the space bar again.
+
+ * media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback-expected.txt: Added.
+ * media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback.html: Added.
+ * platform/ios-simulator/TestExpectations:
+
2017-11-27 Matt Lewis <[email protected]>
Unreviewed, rolling out r225201.
Added: trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback-expected.txt (0 => 225209)
--- trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback-expected.txt (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback-expected.txt 2017-11-28 12:31:21 UTC (rev 225209)
@@ -0,0 +1,29 @@
+Testing media is paused and resumed when pressing the space bar in fullscreen.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Obtained a 'play' event.
+
+Entering fullscreen.
+
+Obtained a 'webkitfullscreenchange' event.
+media.webkitDisplayingFullscreen = true.
+PASS media.paused is false
+
+Pressing the space bar.
+
+Obtained a 'pause' event.
+
+Pressing the space bar.
+
+Obtained a 'play' event.
+
+Obtained a 'webkitfullscreenchange' event.
+media.webkitDisplayingFullscreen = false.
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback.html (0 => 225209)
--- trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback.html (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback.html 2017-11-28 12:31:21 UTC (rev 225209)
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<script src=""
+<script src="" type="text/_javascript_"></script>
+<body>
+<video src="" 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.");
+ debug(`media.webkitDisplayingFullscreen = ${media.webkitDisplayingFullscreen}.`);
+
+ if (media.webkitDisplayingFullscreen) {
+ 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=""
+</body>
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (225208 => 225209)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2017-11-28 07:55:36 UTC (rev 225208)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2017-11-28 12:31:21 UTC (rev 225209)
@@ -127,6 +127,7 @@
media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause-fullscreen.html [ Skip ]
media/modern-media-controls/media-controller/media-controller-click-on-video-background-should-pause.html [ Skip ]
media/modern-media-controls/media-controller/media-controller-click-on-video-background-to-dismiss-tracks-panel-should-not-toggle-playback.html [ Skip ]
+media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback.html [ Skip ]
media/modern-media-controls/media-documents/media-document-audio-mac-sizing.html [ Skip ]
media/modern-media-controls/media-documents/media-document-video-mac-sizing.html [ Skip ]
media/modern-media-controls/playback-support/playback-support-button-click.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (225208 => 225209)
--- trunk/Source/WebCore/ChangeLog 2017-11-28 07:55:36 UTC (rev 225208)
+++ trunk/Source/WebCore/ChangeLog 2017-11-28 12:31:21 UTC (rev 225209)
@@ -1,3 +1,24 @@
+2017-11-28 Antoine Quint <[email protected]>
+
+ Pressing the space bar while watching a fullscreen video doesn't play or pause
+ https://bugs.webkit.org/show_bug.cgi?id=180033
+ <rdar://problem/33610443>
+
+ Reviewed by Eric Carlson.
+
+ We register a "keydown" event to track when the space bar is pressed, and if the media is playing
+ in fullscreen, we toggle playback. This does not interfere with full keyboard access since activating
+ one of the media controls using the keyboard will not let the events we register for be dispatched
+ this far along the event dispatch phase.
+
+ Test: media/modern-media-controls/media-controller/media-controller-space-bar-toggle-playback.html
+
+ * Modules/modern-media-controls/media/media-controller.js:
+ (MediaController):
+ (MediaController.prototype.togglePlayback): Add a catch() statement since calling play() could sometime
+ lead to some extraneous unhandled promise console logging that pollutes test output.
+ (MediaController.prototype.handleEvent):
+
2017-11-27 Tim Horton <[email protected]>
Web Content process crashes when dragging a link in recovery mode
Modified: trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js (225208 => 225209)
--- trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js 2017-11-28 07:55:36 UTC (rev 225208)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js 2017-11-28 12:31:21 UTC (rev 225209)
@@ -57,6 +57,8 @@
media.videoTracks.addEventListener("removetrack", this);
media.addEventListener(this.fullscreenChangeEventType, this);
+
+ window.addEventListener("keydown", this);
}
// Public
@@ -100,7 +102,7 @@
togglePlayback()
{
if (this.media.paused)
- this.media.play();
+ this.media.play().catch(e => {});
else
this.media.pause();
}
@@ -158,6 +160,9 @@
this._updateControlsIfNeeded();
if (event.type === "webkitpresentationmodechanged")
this._returnMediaLayerToInlineIfNeeded();
+ } else if (event.type === "keydown" && this.isFullscreen && event.key === " ") {
+ this.togglePlayback();
+ event.preventDefault();
}
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes