Title: [97367] trunk
Revision
97367
Author
[email protected]
Date
2011-10-13 08:57:09 -0700 (Thu, 13 Oct 2011)

Log Message

REGRESSION (r95381): Standalone video can be focused and draws a focus ring.
https://bugs.webkit.org/show_bug.cgi?id=69097

Patch by Deepak Sherveghar <[email protected]> on 2011-10-13
Reviewed by Eric Carlson.

Source/WebCore:

We don't want to focus a media element in a standalone document.

Test: fast/events/media-focus-in-standalone-media-document.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::supportsFocus): return false if media element is in a standalone media document.

LayoutTests:

New test to check that media element in a standalone document are not focussed.

* fast/events/media-focus-in-standalone-media-document-expected.txt: Added.
* fast/events/media-focus-in-standalone-media-document.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (97366 => 97367)


--- trunk/LayoutTests/ChangeLog	2011-10-13 15:28:38 UTC (rev 97366)
+++ trunk/LayoutTests/ChangeLog	2011-10-13 15:57:09 UTC (rev 97367)
@@ -1,3 +1,15 @@
+2011-10-13  Deepak Sherveghar  <[email protected]>
+
+        REGRESSION (r95381): Standalone video can be focused and draws a focus ring.
+        https://bugs.webkit.org/show_bug.cgi?id=69097
+
+        Reviewed by Eric Carlson.
+
+        New test to check that media element in a standalone document are not focussed.
+
+        * fast/events/media-focus-in-standalone-media-document-expected.txt: Added.
+        * fast/events/media-focus-in-standalone-media-document.html: Added.
+
 2011-10-13  Sergio Villar Senin  <[email protected]>
 
         Unreviewed, rebaselined GTK SVG test result.

Added: trunk/LayoutTests/fast/events/media-focus-in-standalone-media-document-expected.txt (0 => 97367)


--- trunk/LayoutTests/fast/events/media-focus-in-standalone-media-document-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/media-focus-in-standalone-media-document-expected.txt	2011-10-13 15:57:09 UTC (rev 97367)
@@ -0,0 +1,13 @@
+This tests that media element in a standalone media document cannot be focused directly using focus() method or by mouse click.
+
+
+
+*** Should not focus video element by calling focus() method.
+EXPECTED (standaloneMediaDocument.activeElement != '[object HTMLVideoElement]') OK
+
+*** Should not focus video element by mouse click.
+*** Video element clicked.
+EXPECTED (standaloneMediaDocument.activeElement != '[object HTMLVideoElement]') OK
+
+END OF TEST
+

Added: trunk/LayoutTests/fast/events/media-focus-in-standalone-media-document.html (0 => 97367)


--- trunk/LayoutTests/fast/events/media-focus-in-standalone-media-document.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/media-focus-in-standalone-media-document.html	2011-10-13 15:57:09 UTC (rev 97367)
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script src=""
+        <script type="text/_javascript_">
+            var videoElement;
+            var standaloneMediaDocument;
+            var skipOnFirstEmptyLoad = 0;
+
+            function frameLoaded()
+            {
+                if (++skipOnFirstEmptyLoad == 1)
+                    return;
+
+                standaloneMediaDocument = document.getElementById("videoframe").contentDocument;
+                videoElement = standaloneMediaDocument.querySelector("video");
+
+                videoElement.addEventListener('click',function(){
+                    consoleWrite("*** Video element clicked.");
+                },false);
+
+                testFocus();
+                testFocusbyMouseClick();
+                consoleWrite("");
+                endTest();
+            }
+
+            function testFocus()
+            {
+                consoleWrite("<br>*** Should not focus video element by calling focus() method.");
+                videoElement.focus();
+                testExpected("standaloneMediaDocument.activeElement", videoElement, "!=");
+            }
+
+            function testFocusbyMouseClick()
+            {
+                // Simulate click event to try focus video element.
+                consoleWrite("<br>*** Should not focus video element by mouse click.");
+                var click = document.createEvent("MouseEvents");
+                click.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, document);
+                videoElement.dispatchEvent(click);
+                testExpected("standaloneMediaDocument.activeElement", videoElement, "!=");
+            }
+        </script>
+    </head>
+    <body>
+        <p>
+            This tests that  media element in a standalone media document cannot be focused directly using focus() method or by mouse click.
+        </p>
+        <iframe id="videoframe" width=380 height=330 _onload_="frameLoaded()"></iframe>
+        <script type="text/_javascript_">
+            document.getElementById("videoframe").src = "" + findMediaFile("video", "content/test");
+        </script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (97366 => 97367)


--- trunk/Source/WebCore/ChangeLog	2011-10-13 15:28:38 UTC (rev 97366)
+++ trunk/Source/WebCore/ChangeLog	2011-10-13 15:57:09 UTC (rev 97367)
@@ -1,3 +1,17 @@
+2011-10-13  Deepak Sherveghar  <[email protected]>
+
+        REGRESSION (r95381): Standalone video can be focused and draws a focus ring.
+        https://bugs.webkit.org/show_bug.cgi?id=69097
+
+        Reviewed by Eric Carlson.
+
+        We don't want to focus a media element in a standalone document.
+
+        Test: fast/events/media-focus-in-standalone-media-document.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::supportsFocus): return false if media element is in a standalone media document.
+
 2011-10-13  Mikhail Naganov  <[email protected]>
 
         Web Inspector: [Chromium] Add an ability to look up and explore an object from a heap profile.

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (97366 => 97367)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2011-10-13 15:28:38 UTC (rev 97366)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2011-10-13 15:57:09 UTC (rev 97367)
@@ -248,6 +248,9 @@
 
 bool HTMLMediaElement::supportsFocus() const
 {
+    if (ownerDocument()->isMediaDocument())
+        return false;
+
     // If no controls specified, we should still be able to focus the element if it has tabIndex.
     return controls() ||  HTMLElement::supportsFocus();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to