- Revision
- 169387
- Author
- [email protected]
- Date
- 2014-05-27 10:33:04 -0700 (Tue, 27 May 2014)
Log Message
[Mac] media controls should prevent 'click' events from reaching the page
https://bugs.webkit.org/show_bug.cgi?id=133268
Source/WebCore:
Reviewed by Jer Noble.
Test: media/media-controls-cancel-events.html
* Modules/mediacontrols/mediaControlsApple.js:
(Controller.prototype.handleEvent): Allow event handler to cancel event default action.
(Controller.prototype.handleRewindButtonClicked): Cancel event default.
(Controller.prototype.handlePlayButtonClicked): Ditto.
(Controller.prototype.handleMuteButtonClicked): Ditto.
(Controller.prototype.handleMinButtonClicked): Ditto.
(Controller.prototype.handleCaptionButtonClicked): Ditto.
(Controller.prototype.handleFullscreenButtonClicked): Ditto.
* Modules/mediacontrols/mediaControlsiOS.js:
(ControllerIOS.prototype.handlePlayButtonTouchEnd): Ditto.
(ControllerIOS.prototype.handlePlayButtonTouchCancel): Ditto.
(ControllerIOS.prototype.handleFullscreenTouchEnd): Ditto.
(ControllerIOS.prototype.handleFullscreenTouchCancel): Ditto.
(ControllerIOS.prototype.handleStartPlaybackButtonTouchEnd): Ditto.
(ControllerIOS.prototype.handleStartPlaybackButtonTouchCancel): Ditto.
(ControllerIOS.prototype.handleWirelessPickerButtonClicked): Ditto.
LayoutTests:
Reviewed by by Jer Noble.
* media/media-controls-cancel-events-expected.txt: Added.
* media/media-controls-cancel-events.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (169386 => 169387)
--- trunk/LayoutTests/ChangeLog 2014-05-27 16:45:09 UTC (rev 169386)
+++ trunk/LayoutTests/ChangeLog 2014-05-27 17:33:04 UTC (rev 169387)
@@ -1,3 +1,13 @@
+2014-05-27 Eric Carlson <[email protected]>
+
+ [Mac] media controls should prevent 'click' events from reaching the page
+ https://bugs.webkit.org/show_bug.cgi?id=133268
+
+ Reviewed by by Jer Noble.
+
+ * media/media-controls-cancel-events-expected.txt: Added.
+ * media/media-controls-cancel-events.html: Added.
+
2014-05-27 Jon Lee <[email protected]>
Update ENABLE(MEDIA_SOURCE) on Mac
Added: trunk/LayoutTests/media/media-controls-cancel-events-expected.txt (0 => 169387)
--- trunk/LayoutTests/media/media-controls-cancel-events-expected.txt (rev 0)
+++ trunk/LayoutTests/media/media-controls-cancel-events-expected.txt 2014-05-27 17:33:04 UTC (rev 169387)
@@ -0,0 +1,21 @@
+Test that 'click' events in the media controls don't propogate to the page.
+
+This test only runs in DRT!
+
+
+EVENT(canplaythrough)
+
+clicking in the play button
+
+EVENT(playing)
+
+clicking in mute button
+
+EVENT(volumechange)
+
+clicking in closed caption button
+
+100ms timer fired
+
+END OF TEST
+
Added: trunk/LayoutTests/media/media-controls-cancel-events.html (0 => 169387)
--- trunk/LayoutTests/media/media-controls-cancel-events.html (rev 0)
+++ trunk/LayoutTests/media/media-controls-cancel-events.html 2014-05-27 17:33:04 UTC (rev 169387)
@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src=""
+ <script src=""
+ <script src=""
+ <script>
+ function bodyClick(event)
+ {
+ consoleWrite("");
+ failTest("'click' event handler on video parent triggered!");
+ }
+
+ function moveMouseToControlElement(elementName, click)
+ {
+ var controlLocation;
+ try {
+ controlLocation = mediaControlsButtonCoordinates(video, elementName);
+ } catch (exception) {
+ failTest(exception.description);
+ return;
+ }
+
+ eventSender.mouseMoveTo(controlLocation[0], controlLocation[1]);
+ if (click) {
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+ }
+
+ function canplaythrough()
+ {
+ consoleWrite("<br>clicking in the play button<br>");
+ moveMouseToControlElement("play-button", true);
+ }
+
+ function playing()
+ {
+ consoleWrite("<br>clicking in mute button<br>");
+ moveMouseToControlElement("mute-button", true);
+ }
+
+ function volumechange()
+ {
+ consoleWrite("<br>clicking in closed caption button<br>");
+ moveMouseToControlElement("toggle-closed-captions-button", true);
+ window.setTimeout(finish, 100);
+ }
+
+ function finish()
+ {
+ consoleWrite("100ms timer fired<br>");
+ endTest();
+ }
+
+ function start()
+ {
+ findMediaElement();
+
+ waitForEventOnce("canplaythrough", canplaythrough);
+ waitForEventOnce("playing", playing);
+ waitForEventOnce('volumechange', volumechange);
+
+ video.src = "" "content/test");
+
+ if (!window.internals) {
+ failTest('This test requires window.internals.');
+ return;
+ }
+ }
+ </script>
+ </head>
+
+ <body _onload_="start()" _onclick_="bodyClick()">
+ <p>Test that 'click' events in the media controls don't propogate to the page.</p>
+ <p>This test only runs in DRT!</p>
+ <video controls>
+ <track src="" kind="captions" srclang="en">
+ </video>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (169386 => 169387)
--- trunk/Source/WebCore/ChangeLog 2014-05-27 16:45:09 UTC (rev 169386)
+++ trunk/Source/WebCore/ChangeLog 2014-05-27 17:33:04 UTC (rev 169387)
@@ -1,3 +1,29 @@
+2014-05-27 Eric Carlson <[email protected]>
+
+ [Mac] media controls should prevent 'click' events from reaching the page
+ https://bugs.webkit.org/show_bug.cgi?id=133268
+
+ Reviewed by Jer Noble.
+
+ Test: media/media-controls-cancel-events.html
+
+ * Modules/mediacontrols/mediaControlsApple.js:
+ (Controller.prototype.handleEvent): Allow event handler to cancel event default action.
+ (Controller.prototype.handleRewindButtonClicked): Cancel event default.
+ (Controller.prototype.handlePlayButtonClicked): Ditto.
+ (Controller.prototype.handleMuteButtonClicked): Ditto.
+ (Controller.prototype.handleMinButtonClicked): Ditto.
+ (Controller.prototype.handleCaptionButtonClicked): Ditto.
+ (Controller.prototype.handleFullscreenButtonClicked): Ditto.
+ * Modules/mediacontrols/mediaControlsiOS.js:
+ (ControllerIOS.prototype.handlePlayButtonTouchEnd): Ditto.
+ (ControllerIOS.prototype.handlePlayButtonTouchCancel): Ditto.
+ (ControllerIOS.prototype.handleFullscreenTouchEnd): Ditto.
+ (ControllerIOS.prototype.handleFullscreenTouchCancel): Ditto.
+ (ControllerIOS.prototype.handleStartPlaybackButtonTouchEnd): Ditto.
+ (ControllerIOS.prototype.handleStartPlaybackButtonTouchCancel): Ditto.
+ (ControllerIOS.prototype.handleWirelessPickerButtonClicked): Ditto.
+
2014-05-27 Jon Lee <[email protected]>
Fix Mavericks bots from r169383.
Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js (169386 => 169387)
--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js 2014-05-27 16:45:09 UTC (rev 169386)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js 2014-05-27 17:33:04 UTC (rev 169387)
@@ -202,6 +202,8 @@
handleEvent: function(event)
{
+ var preventDefault = false;
+
try {
if (event.target === this.video) {
var handlerName = this.HandledVideoEvents[event.type];
@@ -215,12 +217,17 @@
this.listeners[event.type].forEach(function(entry) {
if (entry.element === event.currentTarget && entry.handler instanceof Function)
- entry.handler.call(this, event);
+ preventDefault |= entry.handler.call(this, event);
}, this);
} catch(e) {
if (window.console)
console.error(e);
}
+
+ if (preventDefault) {
+ event.stopPropagation();
+ event.preventDefault();
+ }
},
createBase: function()
@@ -669,6 +676,7 @@
this.video.currentTime - this.RewindAmount,
this.video.seekable.start(0));
this.video.currentTime = newTime;
+ return true;
},
canPlay: function()
@@ -682,6 +690,7 @@
this.video.play();
else
this.video.pause();
+ return true;
},
handleTimelineChange: function(event)
@@ -757,6 +766,7 @@
this.video.muted = !this.video.muted;
if (this.video.muted)
this.controls.muteButton.setAttribute('aria-label', this.UIString('Unmute'));
+ return true;
},
handleMinButtonClicked: function(event)
@@ -766,6 +776,7 @@
this.controls.muteButton.setAttribute('aria-label', this.UIString('Mute'));
}
this.video.volume = 0;
+ return true;
},
handleMaxButtonClicked: function(event)
@@ -792,6 +803,7 @@
this.destroyCaptionMenu();
else
this.buildCaptionMenu();
+ return true;
},
handleFullscreenButtonClicked: function(event)
@@ -800,6 +812,7 @@
document.webkitExitFullscreen();
else
this.video.webkitRequestFullscreen();
+ return true;
},
handleControlsChange: function()
Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js (169386 => 169387)
--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js 2014-05-27 16:45:09 UTC (rev 169386)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js 2014-05-27 17:33:04 UTC (rev 169387)
@@ -272,12 +272,12 @@
else
this.video.pause();
- event.stopPropagation();
+ return true;
},
handlePlayButtonTouchCancel: function(event) {
this.controls.playButton.classList.remove('active');
- event.stopPropagation();
+ return true;
},
handleBaseGestureStart: function(event) {
@@ -352,12 +352,12 @@
this.handleFullscreenButtonClicked();
- event.stopPropagation();
+ return true;
},
handleFullscreenTouchCancel: function(event) {
this.controls.fullscreenButton.classList.remove('active');
- event.stopPropagation();
+ return true;
},
handleStartPlaybackButtonTouchStart: function(event) {
@@ -367,15 +367,16 @@
handleStartPlaybackButtonTouchEnd: function(event) {
this.controls.fullscreenButton.classList.remove('active');
if (this.video.error)
- return;
+ return true;
this.video.play();
- event.stopPropagation();
+
+ return true;
},
handleStartPlaybackButtonTouchCancel: function(event) {
this.controls.fullscreenButton.classList.remove('active');
- event.stopPropagation();
+ return true;
},
handleReadyStateChange: function(event) {
@@ -394,7 +395,7 @@
handleWirelessPickerButtonClicked: function(event) {
this.video.webkitShowPlaybackTargetPicker();
- event.stopPropagation();
+ return true;
},
get pageScaleFactor() {