Title: [147591] trunk
Revision
147591
Author
[email protected]
Date
2013-04-03 15:35:36 -0700 (Wed, 03 Apr 2013)

Log Message

Unable to focus on embedded plugins such as Flash via _javascript_ focus()
https://bugs.webkit.org/show_bug.cgi?id=32292

Patch by Dave Michael <[email protected]> on 2013-04-03
Reviewed by Ryosuke Niwa.

Source/WebCore:

Make embed, object, and applet elements support focus() when
appropriate. Prior to this patch, _javascript_ focus() had no effect on
embed, object, or applet elements unless tabindex or contenteditable is
set. With this patch, focus() will focus the element unless the plugin
content has failed to load (i.e., we are showing either fallback content
or an unavailable plugin indicator).

Test: plugins/focus.html
      java/focus.html

* html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::supportsFocus):
Overridden to return true except when the plugin content has failed to load.
* html/HTMLPlugInElement.h:
(WebCore::HTMLPlugInElement::useFallbackContent):
Moved up from HTMLPlugInImageElement.
(WebCore::HTMLPlugInElement::supportsFocus):
* html/HTMLPlugInElement.h:
(WebCore::HTMLPlugInImageElement::useFallbackContent):
Removed. Now the implementation is inherited from HTMLPlugInElement.

LayoutTests:

Add/update testing to ensure embed, object, and applet tags now support
focus except when plugin content did not load.

* fast/events/resources/tabindex-focus-blur-all-frame1.html: Change embed and object
    elements to reference an invalid plugin, to be consistent with applet. These
    element types are not focusable when there is valid plugin content.
* fast/events/resources/tabindex-focus-blur-all-frame2.html: Same as above.
* fast/events/resources/tabindex-focus-blur-all-iframe1.html: Same as above.
* fast/events/resources/tabindex-focus-blur-all-iframe2.html: Same as above.
* java/focus-expected.txt: Added.
* java/focus.html: Added.
* plugins/focus-expected.txt: Added.
* plugins/focus.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (147590 => 147591)


--- trunk/LayoutTests/ChangeLog	2013-04-03 22:33:15 UTC (rev 147590)
+++ trunk/LayoutTests/ChangeLog	2013-04-03 22:35:36 UTC (rev 147591)
@@ -1,3 +1,24 @@
+2013-04-03  Dave Michael  <[email protected]>
+
+        Unable to focus on embedded plugins such as Flash via _javascript_ focus()
+        https://bugs.webkit.org/show_bug.cgi?id=32292
+
+        Reviewed by Ryosuke Niwa.
+
+        Add/update testing to ensure embed, object, and applet tags now support
+        focus except when plugin content did not load.
+
+        * fast/events/resources/tabindex-focus-blur-all-frame1.html: Change embed and object
+            elements to reference an invalid plugin, to be consistent with applet. These
+            element types are not focusable when there is valid plugin content.
+        * fast/events/resources/tabindex-focus-blur-all-frame2.html: Same as above.
+        * fast/events/resources/tabindex-focus-blur-all-iframe1.html: Same as above.
+        * fast/events/resources/tabindex-focus-blur-all-iframe2.html: Same as above.
+        * java/focus-expected.txt: Added.
+        * java/focus.html: Added.
+        * plugins/focus-expected.txt: Added.
+        * plugins/focus.html: Added.
+
 2013-04-03  Glenn Adams  <[email protected]>
 
         Element boundaries prevent Japanese line break opportunities

Modified: trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame1.html (147590 => 147591)


--- trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame1.html	2013-04-03 22:33:15 UTC (rev 147590)
+++ trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame1.html	2013-04-03 22:35:36 UTC (rev 147591)
@@ -20,9 +20,9 @@
 applet:<br>
 <applet width="100" height="100" code="" tabindex="-1" id="applet1"></applet><br>
 object:<br>
-<object type="application/x-webkit-test-netscape" width="100" height="100" id="object1"></object><br>
+<object type="application/x-no-such-plugin" width="100" height="100" id="object1"></object><br>
 embed:<br>
-<embed type="application/x-webkit-test-netscape" width="100" height="100" tabindex="3" id="embed1"></embed><br>
+<embed type="application/x-no-such-plugin" width="100" height="100" tabindex="3" id="embed1"></embed><br>
 
 <!--presentation-related elements-->
 <div id="div1b" tabindex="0">

Modified: trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame2.html (147590 => 147591)


--- trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame2.html	2013-04-03 22:33:15 UTC (rev 147590)
+++ trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame2.html	2013-04-03 22:35:36 UTC (rev 147591)
@@ -20,9 +20,9 @@
 applet:<br>
 <applet width="100" height="100" code="" tabindex="2" id="applet3"></applet><br>
 object:<br>
-<object type="application/x-webkit-test-netscape" width="100" height="100" tabindex="0" id="object3"></object><br>
+<object type="application/x-no-such-plugin" width="100" height="100" tabindex="0" id="object3"></object><br>
 embed:<br>
-<embed type="application/x-webkit-test-netscape" width="100" height="100" tabindex="-1" id="embed3"></embed><br>
+<embed type="application/x-no-such-plugin" width="100" height="100" tabindex="-1" id="embed3"></embed><br>
 
 <!--presentation-related elements-->
 <div id="div3b">

Modified: trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-iframe1.html (147590 => 147591)


--- trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-iframe1.html	2013-04-03 22:33:15 UTC (rev 147590)
+++ trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-iframe1.html	2013-04-03 22:35:36 UTC (rev 147591)
@@ -20,9 +20,9 @@
 applet:<br>
 <applet width="100" height="100" code="" id="applet2"></applet><br>
 object:<br>
-<object type="application/x-webkit-test-netscape" width="100" height="100" tabindex="3" id="object2"></object><br>
+<object type="application/x-no-such-plugin" width="100" height="100" tabindex="3" id="object2"></object><br>
 embed:<br>
-<embed type="application/x-webkit-test-netscape" width="100" height="100" tabindex="0" id="embed2"></embed><br>
+<embed type="application/x-no-such-plugin" width="100" height="100" tabindex="0" id="embed2"></embed><br>
 
 <!--presentation-related elements-->
 <div id="div2b" tabindex="-1">

Modified: trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-iframe2.html (147590 => 147591)


--- trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-iframe2.html	2013-04-03 22:33:15 UTC (rev 147590)
+++ trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-iframe2.html	2013-04-03 22:35:36 UTC (rev 147591)
@@ -20,9 +20,9 @@
 applet:<br>
 <applet width="100" height="100" code="" tabindex="0" id="applet4"></applet><br>
 object:<br>
-<object type="application/x-webkit-test-netscape" width="100" height="100" tabindex="-1" id="object4"></object><br>
+<object type="application/x-no-such-plugin" width="100" height="100" tabindex="-1" id="object4"></object><br>
 embed:<br>
-<embed type="application/x-webkit-test-netscape" width="100" height="100" id="embed4"></embed><br>
+<embed type="application/x-no-such-plugin" width="100" height="100" id="embed4"></embed><br>
 
 <!--presentation-related elements-->
 <div id="div4b" tabindex="3">

Added: trunk/LayoutTests/java/focus-expected.txt (0 => 147591)


--- trunk/LayoutTests/java/focus-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/java/focus-expected.txt	2013-04-03 22:35:36 UTC (rev 147591)
@@ -0,0 +1,19 @@
+Test for Applet for bug 32292: Unable to focus on embedded plugins such as Flash via _javascript_ focus().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS "appletElem"; document.activeElement === pluginElement is true
+PASS "appletElemWithFallbackContents"; document.activeElement === pluginElement is true
+PASS "noCodeAppletElem"; document.activeElement === pluginElement is false
+PASS "noCodeAppletElemWithFallbackContents"; document.activeElement === pluginElement is false
+PASS "noCodeAppletElemWithTabindex"; document.activeElement === pluginElement is true
+PASS "noCodeAppletElemWithContenteditable"; document.activeElement === pluginElement is true
+Test for bug 32292: "Unable to focus on embedded plugins such as Flash via _javascript_ focus()"
+
+This tests focusing Applets. See LayoutTests/plugins for Embed and Object elements.
+
+         

Added: trunk/LayoutTests/java/focus.html (0 => 147591)


--- trunk/LayoutTests/java/focus.html	                        (rev 0)
+++ trunk/LayoutTests/java/focus.html	2013-04-03 22:35:36 UTC (rev 147591)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script>
+if (window.testRunner)
+    testRunner.overridePreference("WebKitJavaEnabled", "1");
+</script>
+</head>
+<body>
+<p>Test for <a href="" 32292</a>:
+"Unable to focus on embedded plugins such as Flash via _javascript_ focus()"</p>
+<p>This tests focusing Applets. See LayoutTests/plugins for Embed and Object elements.</p>
+<div id=appletOwner>
+
+<applet id="appletElem" width=150 height=25 code="SharedApplet.class" name="javaTest" shouldFocus=true></applet>
+
+<applet id="appletElemWithFallbackContents" width=150 height=25 code="SharedApplet.class" name="javaTest" shouldFocus=true>Fallback Contents.</applet>
+
+<applet id="noCodeAppletElem" width=150 height=25 code="DoesNotExist.class" shouldFocus=false></applet>
+
+<applet id="noCodeAppletElemWithFallbackContents" width=150 height=25 code="DoesNotExist.class" shouldFocus=false>Fallback contents.</applet>
+
+<applet id="noCodeAppletElemWithTabindex" width=150 height=25 code="DoesNotExist.class" tabindex=-1 shouldFocus=true></applet>
+
+<applet id="noCodeAppletElemWithContenteditable" width=150 height=25 code="DoesNotExist.class" shouldFocus=true></applet>
+
+</div>
+<script>
+
+description("Test for Applet for bug 32292: Unable to focus on embedded plugins such as Flash via _javascript_ focus().");
+
+function RunTest() {
+    var owner = document.getElementById("appletOwner");
+    for (var i = 0; i < owner.childNodes.length; ++i) {
+        pluginElement = owner.childNodes[i];
+        if (pluginElement.id) {
+            pluginElement.focus();
+            shouldBe('"' + pluginElement.id + '"; document.activeElement === pluginElement',
+                pluginElement.getAttribute("shouldFocus").toString());
+            pluginElement.blur();
+        }
+    }
+}
+
+document.addEventListener("DOMContentLoaded", RunTest, false);
+
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/plugins/focus-expected.txt (0 => 147591)


--- trunk/LayoutTests/plugins/focus-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/plugins/focus-expected.txt	2013-04-03 22:35:36 UTC (rev 147591)
@@ -0,0 +1,26 @@
+Test for Embed and Object for bug 32292: Unable to focus on embedded plugins such as Flash via _javascript_ focus().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS "embedElem"; document.activeElement === pluginElement is true
+PASS "objectElem"; document.activeElement === pluginElement is true
+PASS "embedElemWithFallbackContents"; document.activeElement === pluginElement is true
+PASS "objectElemWithFallbackContents"; document.activeElement === pluginElement is true
+PASS "noPluginEmbedElem"; document.activeElement === pluginElement is false
+PASS "noPluginObjectElem"; document.activeElement === pluginElement is false
+PASS "noPluginEmbedElemWithFallbackContents"; document.activeElement === pluginElement is false
+PASS "noPluginObjectElemWithFallbackContents"; document.activeElement === pluginElement is false
+PASS "noPluginEmbedElemWithTabindex"; document.activeElement === pluginElement is true
+PASS "noPluginObjectElemWithTabindex"; document.activeElement === pluginElement is true
+PASS "noPluginEmbedElemWithContenteditable"; document.activeElement === pluginElement is true
+PASS "noPluginObjectElemWithContenteditable"; document.activeElement === pluginElement is true
+fast/events/tabindex-focus-blur-all.html
+Test for bug 32292: "Unable to focus on embedded plugins such as Flash via _javascript_ focus()"
+
+This tests focusing Embeds and Objects. See LayoutTests/java for Applet elements.
+
+   Fallback contents.     Fallback contents. Fallback contents.      

Added: trunk/LayoutTests/plugins/focus.html (0 => 147591)


--- trunk/LayoutTests/plugins/focus.html	                        (rev 0)
+++ trunk/LayoutTests/plugins/focus.html	2013-04-03 22:35:36 UTC (rev 147591)
@@ -0,0 +1,52 @@
+fast/events/tabindex-focus-blur-all.html<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<p>Test for <a href="" 32292</a>:
+"Unable to focus on embedded plugins such as Flash via _javascript_ focus()"</p>
+<p>This tests focusing Embeds and Objects. See LayoutTests/java for Applet elements.</p>
+<div id=embedOwner>
+<embed id="embedElem" type="application/x-webkit-test-netscape" width=100 height=100 shouldFocus=true></embed>
+<object id="objectElem" type="application/x-webkit-test-netscape" windowedPlugin="false" width=100 height=100 shouldFocus=true></object>
+
+<embed id="embedElemWithFallbackContents" type="application/x-webkit-test-netscape" width=100 height=100 shouldFocus=true>Fallback contents.</embed>
+<object id="objectElemWithFallbackContents" type="application/x-webkit-test-netscape" windowedPlugin="false" width=100 height=100 shouldFocus=true>Fallback contents.</object>
+
+<embed id="noPluginEmbedElem" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 shouldFocus=false></embed>
+<object id="noPluginObjectElem" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 shouldFocus=false></object>
+
+<embed id="noPluginEmbedElemWithFallbackContents" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 shouldFocus=false>Fallback contents.</embed>
+<object id="noPluginObjectElemWithFallbackContents" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 shouldFocus=false>Fallback contents.</object>
+
+<embed id="noPluginEmbedElemWithTabindex" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 tabindex=-1 shouldFocus=true></embed>
+<object id="noPluginObjectElemWithTabindex" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 tabindex=-1 shouldFocus=true></object>
+
+<embed id="noPluginEmbedElemWithContenteditable" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 contenteditable=true shouldFocus=true></embed>
+<object id="noPluginObjectElemWithContenteditable" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 contenteditable=true shouldFocus=true></object>
+</div>
+<script>
+
+description("Test for Embed and Object for bug 32292: Unable to focus on embedded plugins such as Flash via _javascript_ focus().");
+
+function RunTest() {
+    var owner = document.getElementById("embedOwner");
+    for (var i = 0; i < owner.childNodes.length; ++i) {
+        pluginElement = owner.childNodes[i];
+        if (pluginElement.id) {
+            pluginElement.focus();
+            shouldBe('"' + pluginElement.id + '"; document.activeElement === pluginElement',
+                pluginElement.getAttribute("shouldFocus").toString());
+            pluginElement.blur();
+        }
+    }
+}
+
+document.addEventListener("DOMContentLoaded", RunTest, false);
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (147590 => 147591)


--- trunk/Source/WebCore/ChangeLog	2013-04-03 22:33:15 UTC (rev 147590)
+++ trunk/Source/WebCore/ChangeLog	2013-04-03 22:35:36 UTC (rev 147591)
@@ -1,3 +1,31 @@
+2013-04-03  Dave Michael  <[email protected]>
+
+        Unable to focus on embedded plugins such as Flash via _javascript_ focus()
+        https://bugs.webkit.org/show_bug.cgi?id=32292
+
+        Reviewed by Ryosuke Niwa.
+
+        Make embed, object, and applet elements support focus() when
+        appropriate. Prior to this patch, _javascript_ focus() had no effect on
+        embed, object, or applet elements unless tabindex or contenteditable is
+        set. With this patch, focus() will focus the element unless the plugin
+        content has failed to load (i.e., we are showing either fallback content
+        or an unavailable plugin indicator).
+
+        Test: plugins/focus.html
+              java/focus.html
+
+        * html/HTMLPlugInElement.cpp:
+        (WebCore::HTMLPlugInElement::supportsFocus):
+        Overridden to return true except when the plugin content has failed to load.
+        * html/HTMLPlugInElement.h:
+        (WebCore::HTMLPlugInElement::useFallbackContent):
+        Moved up from HTMLPlugInImageElement.
+        (WebCore::HTMLPlugInElement::supportsFocus):
+        * html/HTMLPlugInElement.h:
+        (WebCore::HTMLPlugInImageElement::useFallbackContent):
+        Removed. Now the implementation is inherited from HTMLPlugInElement.
+
 2013-04-03  Glenn Adams  <[email protected]>
 
         Element boundaries prevent Japanese line break opportunities

Modified: trunk/Source/WebCore/html/HTMLPlugInElement.cpp (147590 => 147591)


--- trunk/Source/WebCore/html/HTMLPlugInElement.cpp	2013-04-03 22:33:15 UTC (rev 147590)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.cpp	2013-04-03 22:35:36 UTC (rev 147591)
@@ -242,6 +242,16 @@
     return true;
 }
 
+bool HTMLPlugInElement::supportsFocus() const
+{
+    if (HTMLFrameOwnerElement::supportsFocus())
+        return true;
+
+    if (useFallbackContent() || !renderer() || !renderer()->isEmbeddedObject())
+        return false;
+    return !toRenderEmbeddedObject(renderer())->showsUnavailablePluginIndicator();
+}
+
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
 NPObject* HTMLPlugInElement::getNPObject()

Modified: trunk/Source/WebCore/html/HTMLPlugInElement.h (147590 => 147591)


--- trunk/Source/WebCore/html/HTMLPlugInElement.h	2013-04-03 22:33:15 UTC (rev 147590)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.h	2013-04-03 22:35:36 UTC (rev 147591)
@@ -83,6 +83,8 @@
     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
     virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
 
+    virtual bool useFallbackContent() const { return false; }
+
     // Subclasses should use guardedDispatchBeforeLoadEvent instead of calling dispatchBeforeLoadEvent directly.
     bool guardedDispatchBeforeLoadEvent(const String& sourceURL);
 
@@ -97,6 +99,8 @@
 
     virtual RenderWidget* renderWidgetForJSBindings() const = 0;
 
+    virtual bool supportsFocus() const OVERRIDE;
+
     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
     virtual bool isPluginElement() const;
 

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (147590 => 147591)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h	2013-04-03 22:33:15 UTC (rev 147590)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h	2013-04-03 22:35:36 UTC (rev 147591)
@@ -120,7 +120,6 @@
     virtual void finishParsingChildren();
 
     void updateWidgetIfNecessary();
-    virtual bool useFallbackContent() const { return false; }
 
     virtual void updateSnapshot(PassRefPtr<Image>) OVERRIDE;
     virtual void dispatchPendingMouseClick() OVERRIDE;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to