Title: [200441] trunk
Revision
200441
Author
[email protected]
Date
2016-05-04 17:05:47 -0700 (Wed, 04 May 2016)

Log Message

AX: Nonfunctional controls appear before every HTML5 video when using VoiceOver
https://bugs.webkit.org/show_bug.cgi?id=153089
<rdar://problem/24050668>

Patch by Aaron Chu <[email protected]> on 2016-05-04
Reviewed by Dean Jackson.

Source/WebCore:

Test: media/video-controls-show-on-kb-or-ax-event.html

* Modules/mediacontrols/mediaControlsApple.js:
(Controller):
(Controller.prototype.createControls):
(Controller.prototype.updateControls):
(Controller.prototype.handlePlayButtonClicked):
(Controller.prototype.setPlaying):
(Controller.prototype.showShowControlsButton):
(Controller.prototype.showControls):
(Controller.prototype.hideControls):
* Modules/mediacontrols/mediaControlsiOS.js:
(ControllerIOS.prototype.addStartPlaybackControls):
(ControllerIOS.prototype.handleStartPlaybackButtonTouchEnd):
(ControllerIOS.prototype.showControls):

Fix to make sure the showControls button in a media player behaves correctly.

LayoutTests:

* media/video-controls-show-on-kb-or-ax-event-expected.txt:
* media/video-controls-show-on-kb-or-ax-event.html:

A Layout Test to make sure showControls Button in media player is hidden by default.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (200440 => 200441)


--- trunk/LayoutTests/ChangeLog	2016-05-04 23:41:16 UTC (rev 200440)
+++ trunk/LayoutTests/ChangeLog	2016-05-05 00:05:47 UTC (rev 200441)
@@ -1,3 +1,16 @@
+2016-05-04  Aaron Chu  <[email protected]>
+
+        AX: Nonfunctional controls appear before every HTML5 video when using VoiceOver
+        https://bugs.webkit.org/show_bug.cgi?id=153089
+        <rdar://problem/24050668>
+
+        Reviewed by Dean Jackson.
+
+        * media/video-controls-show-on-kb-or-ax-event-expected.txt:
+        * media/video-controls-show-on-kb-or-ax-event.html:
+
+        A Layout Test to make sure showControls Button in media player is hidden by default.
+
 2016-05-04  Dean Jackson  <[email protected]>
 
         Disabling WebGL2 should mean no context is created

Modified: trunk/LayoutTests/media/video-controls-show-on-kb-or-ax-event-expected.txt (200440 => 200441)


--- trunk/LayoutTests/media/video-controls-show-on-kb-or-ax-event-expected.txt	2016-05-04 23:41:16 UTC (rev 200440)
+++ trunk/LayoutTests/media/video-controls-show-on-kb-or-ax-event-expected.txt	2016-05-05 00:05:47 UTC (rev 200441)
@@ -1,6 +1,14 @@
-This tests that, after the video controls fade out, they can be shown when VoiceOver or a keyboard user clicks the hidden "Show Controls" button.
+This tests:
+1. Initially, toolbar is visible, "Show Controls" button is not.
+2. After the video controls fade out, they can be shown when VoiceOver or a keyboard user clicks the invisible "Show Controls" button.
+3. When the video is paused, the controls become visible and the "Show Controls" button is hidden.
 
 PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
 
-
-

Modified: trunk/LayoutTests/media/video-controls-show-on-kb-or-ax-event.html (200440 => 200441)


--- trunk/LayoutTests/media/video-controls-show-on-kb-or-ax-event.html	2016-05-04 23:41:16 UTC (rev 200440)
+++ trunk/LayoutTests/media/video-controls-show-on-kb-or-ax-event.html	2016-05-05 00:05:47 UTC (rev 200441)
@@ -1,41 +1,95 @@
-<body>
+<body _onload_="initialChecksBeforePlay()">
 <p>
-    This tests that, after the video controls fade out, they can be shown when VoiceOver or a keyboard user clicks the hidden "Show Controls" button.
+    This tests:<br>
+    1. Initially, toolbar is visible, "Show Controls" button is not.<br>
+    2. After the video controls fade out, they can be shown when VoiceOver or a keyboard user clicks the invisible "Show Controls" button.<br>
+    3. When the video is paused, the controls become visible and the "Show Controls" button is hidden.<br>
 </p>
+
+<video id="video" controls _onplaying_="testPlaying()"  _onpause_="testPausing()" src=""
+
 <p id="result">
     FAIL: Test did not run.<br>
 </p>
-<video id="video" controls autoplay _onplaying_="playing()" src=""
 <script>
     if (window.testRunner) {
         testRunner.waitUntilDone();
         testRunner.dumpAsText();
     }
 
-    function playing() {
+    var result = document.getElementById("result");
+    result.innerHTML = "";
+    // Initially, the showControls Button should be hidden.
+    var root = internals.shadowRoot(document.getElementById("video"));
+    var button = root.firstChild.querySelector('button');
+    var controls = root.firstChild.querySelector('[role="toolbar"]');
+    var video = document.getElementById('video');
 
-        // Mouse over the video then mouse out to hide controls more quickly.
-        eventSender.mouseMoveTo(100,100);
-        eventSender.mouseMoveTo(1,1);
+    function isElementHidden(elem) {
+        return (elem.hidden && getComputedStyle(elem).display === 'none')
+    }
+    function initialChecksBeforePlay() {
+        // Before we start, check to make sure toolbar is in place and showControlsbutton is hidden.
+        result.innerHTML += (!isElementHidden(controls))? 'PASS<br>': 'FAIL: Controls are not available at the beginning.<br>';
+        result.innerHTML += (isElementHidden(button))? 'PASS<br>': 'FAIL: "Show Controls" button is not hidden initially.<br>';
 
+        video.play();
+    }
+
+    function testPlaying() {
+        // Make sure we are getting the updated root and button.
+        root = internals.shadowRoot(document.getElementById("video"));
+
+        // We give it a 100ms buffer for the video to set all the properties before sending mouse events.
+        setTimeout(function () {
+            // Mouse over the video then mouse out to hide controls more quickly.
+            eventSender.mouseMoveTo(150,150);
+            eventSender.mouseMoveTo(0,0);
+        }, 100);
+
+        // 300ms after the mouse events, all UI changes should complete and we can start making assertions.
         setTimeout(function() {
-            var result = document.getElementById("result");
-            result.innerHTML = "";
-            var root = internals.shadowRoot(document.getElementById("video"))
-            
-            var button = root.firstChild.querySelector('button');
-            if (button) {
+            // Make sure we are getting the latest copy of the element.
+            controls = root.firstChild.querySelector('[role="toolbar"]');
+            result.innerHTML += !controls? 'PASS<br>': 'FAIL: Toolbar still around after mouseout.<br>';
+
+            // Make sure we are getting the latest copy of the element.
+            button = root.firstChild.querySelector('button');
+            result.innerHTML += !isElementHidden(button)? 'PASS<br>': 'FAIL: Button should be visible.<br>';
+
+            if(button && !isElementHidden(button)) {
                 button.focus();
-                eventSender.keyDown(' '); // Use keyboard to press the selected button.
-            } else
-                result.innerHTML += 'FAIL: "Show Controls" button is not available.<br>';	
+                eventSender.keyDown(' ');
+            } else 
+                result.innerHTML += 'FAIL: "Show Controls" button is hidden or unavailable.<br>';
 
-            // Verifies the toolbar is back in the DOM.
-            var controls = root.firstChild.querySelector('[role="toolbar"]');
-            result.innerHTML += controls ? 'PASS': 'FAIL: Test ending, but toolbar is not visible.';
+            // Make sure we are getting the latest copy of the element.
+            controls = root.firstChild.querySelector('[role="toolbar"]');
+            result.innerHTML += controls? 'PASS<br>': 'FAIL: Toolbar should exist<br>';
 
+            eventSender.mouseMoveTo(150,150);
+            eventSender.mouseMoveTo(0,0);
+
+            setTimeout(function () {
+                controls = root.firstChild.querySelector('[role="toolbar"]');
+                result.innerHTML += !controls? 'PASS<br>': 'FAIL: Toolbar should not exist<br>';
+                // We are done testing playing state, moving on to testing the paused state.
+                video.pause();
+            }, 300);
+        }, 400);
+    }
+
+    function testPausing() {
+        // We are giving 100ms + 300s buffer for the video to set its properties and make UI changes.
+        setTimeout(function () {
+            controls = root.firstChild.querySelector('[role="toolbar"]');
+            result.innerHTML += controls? 'PASS<br>': 'FAIL: Toolbar should exist<br>';
+
+            button = root.firstChild.querySelector('button');
+            result.innerHTML += isElementHidden(button)? 'PASS<br>': 'FAIL: Button should not be visible.<br>';
+
             testRunner.notifyDone();
-        }, 300) // Wait for video toolbar to hide.
+        }, 400);
     }
 </script>
 </body>

Modified: trunk/Source/WebCore/ChangeLog (200440 => 200441)


--- trunk/Source/WebCore/ChangeLog	2016-05-04 23:41:16 UTC (rev 200440)
+++ trunk/Source/WebCore/ChangeLog	2016-05-05 00:05:47 UTC (rev 200441)
@@ -1,3 +1,29 @@
+2016-05-04  Aaron Chu  <[email protected]>
+
+        AX: Nonfunctional controls appear before every HTML5 video when using VoiceOver
+        https://bugs.webkit.org/show_bug.cgi?id=153089
+        <rdar://problem/24050668>
+
+        Reviewed by Dean Jackson.
+
+        Test: media/video-controls-show-on-kb-or-ax-event.html
+
+        * Modules/mediacontrols/mediaControlsApple.js:
+        (Controller):
+        (Controller.prototype.createControls):
+        (Controller.prototype.updateControls):
+        (Controller.prototype.handlePlayButtonClicked):
+        (Controller.prototype.setPlaying):
+        (Controller.prototype.showShowControlsButton):
+        (Controller.prototype.showControls):
+        (Controller.prototype.hideControls):
+        * Modules/mediacontrols/mediaControlsiOS.js:
+        (ControllerIOS.prototype.addStartPlaybackControls):
+        (ControllerIOS.prototype.handleStartPlaybackButtonTouchEnd):
+        (ControllerIOS.prototype.showControls):
+
+        Fix to make sure the showControls button in a media player behaves correctly.
+
 2016-05-04  Dean Jackson  <[email protected]>
 
         Disabling WebGL2 should mean no context is created

Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js (200440 => 200441)


--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2016-05-04 23:41:16 UTC (rev 200440)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2016-05-05 00:05:47 UTC (rev 200441)
@@ -13,6 +13,7 @@
     this.isLive = false;
     this.statusHidden = true;
     this.hasWirelessPlaybackTargets = false;
+    this.canToggleShowControlsButton = false;
     this.isListeningForPlaybackTargetAvailabilityEvent = false;
     this.currentTargetIsWireless = false;
     this.wirelessPlaybackDisabled = false;
@@ -512,7 +513,7 @@
         // Show controls button is an accessibility workaround since the controls are now removed from the DOM. http://webkit.org/b/145684
         var showControlsButton = this.showControlsButton = document.createElement('button');
         showControlsButton.setAttribute('pseudo', '-webkit-media-show-controls');
-        showControlsButton.hidden = true;
+        this.showShowControlsButton(false);
         showControlsButton.setAttribute('aria-label', this.UIString('Show Controls'));
         this.listenFor(showControlsButton, 'click', this.handleShowControlsClick);
         this.base.appendChild(showControlsButton);
@@ -647,9 +648,11 @@
             this.controls.panel.classList.add(this.ClassNames.show);
             this.controls.panel.classList.remove(this.ClassNames.hidden);
             this.resetHideControlsTimer();
+            this.showShowControlsButton(false);
         } else {
             this.controls.panel.classList.remove(this.ClassNames.show);
             this.controls.panel.classList.add(this.ClassNames.hidden);
+            this.showShowControlsButton(true);
         }
     },
 
@@ -987,9 +990,10 @@
 
     handlePlayButtonClicked: function(event)
     {
-        if (this.canPlay())
+        if (this.canPlay()) {
+            this.canToggleShowControlsButton = true;
             this.video.play();
-        else
+        } else
             this.video.pause();
         return true;
     },
@@ -1496,6 +1500,7 @@
             this.controls.playButton.classList.remove(this.ClassNames.paused);
             this.controls.playButton.setAttribute('aria-label', this.UIString('Pause'));
             this.resetHideControlsTimer();
+            this.canToggleShowControlsButton = true;
         }
     },
 
@@ -1515,6 +1520,12 @@
         }
     },
 
+    showShowControlsButton: function (shouldShow) {
+        this.showControlsButton.hidden = !shouldShow;
+        if (shouldShow) 
+            this.showControlsButton.focus();
+    },
+
     showControls: function(focusControls)
     {
         this.updateShouldListenForPlaybackTargetAvailabilityEvent();
@@ -1528,7 +1539,7 @@
             if (focusControls)
                 this.controls.playButton.focus();
         }
-        this.showControlsButton.hidden = true;
+        this.showShowControlsButton(false);
     },
 
     hideControls: function()
@@ -1541,7 +1552,7 @@
         this.controls.panel.classList.remove(this.ClassNames.show);
         if (this.controls.panelBackground)
             this.controls.panelBackground.classList.remove(this.ClassNames.show);
-        this.showControlsButton.hidden = false;
+        this.showShowControlsButton(this.isPlayable() && this.isPlaying && this.canToggleShowControlsButton);
     },
 
     setNeedsUpdateForDisplayedWidth: function()

Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js (200440 => 200441)


--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js	2016-05-04 23:41:16 UTC (rev 200440)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js	2016-05-05 00:05:47 UTC (rev 200441)
@@ -147,6 +147,7 @@
 
     addStartPlaybackControls: function() {
         this.base.appendChild(this.controls.startPlaybackButton);
+        this.showShowControlsButton(false);
     },
 
     removeStartPlaybackControls: function() {
@@ -441,6 +442,7 @@
             return true;
 
         this.video.play();
+        this.canToggleShowControlsButton = true;
         this.updateControls();
 
         return true;
@@ -522,6 +524,7 @@
         if (this.shouldHaveControls() && !this.controls.panelContainer.parentElement) {
             this.base.appendChild(this.controls.inlinePlaybackPlaceholder);
             this.base.appendChild(this.controls.panelContainer);
+            this.showShowControlsButton(false);
         }
     },
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to