Source/WebCore/ChangeLog

 12012-04-02 Dave Michael <dmichael@chromium.org>
 2
 3 Unable to focus on embedded plugins such as Flash via javascript focus()
 4 https://bugs.webkit.org/show_bug.cgi?id=32292
 5
 6 Reviewed by Ryosuke Niwa.
 7
 8 Make embed, object, and applet elements support focus() when
 9 appropriate. Prior to this patch, javascript focus() had no effect on
 10 embed, object, or applet elements unless tabindex or contenteditable is
 11 set. With this patch, focus() will focus the element unless the plugin
 12 content has failed to load (i.e., we are showing either fallback content
 13 or an unavailable plugin indicator).
 14
 15 Test: plugins/focus.html
 16 java/focus.html
 17
 18 * html/HTMLPlugInElement.cpp:
 19 (WebCore::HTMLPlugInElement::supportsFocus):
 20 Overridden to return true except when the plugin content has failed to load.
 21 * html/HTMLPlugInElement.h:
 22 (WebCore::HTMLPlugInElement::useFallbackContent):
 23 Moved up from HTMLPlugInImageElement.
 24 (WebCore::HTMLPlugInElement::supportsFocus):
 25 * html/HTMLPlugInElement.h:
 26 (WebCore::HTMLPlugInImageElement::useFallbackContent):
 27 Removed. Now the implementation is inherited from HTMLPlugInElement.
 28
1292013-04-03 Jessie Berlin <jberlin@apple.com>
230
331 Update the localizable strings file.

Source/WebCore/html/HTMLPlugInElement.cpp

@@bool HTMLPlugInElement::isPluginElement() const
242242 return true;
243243}
244244
 245bool HTMLPlugInElement::supportsFocus() const
 246{
 247 if (HTMLFrameOwnerElement::supportsFocus())
 248 return true;
 249
 250 if (useFallbackContent() || !renderer() || !renderer()->isEmbeddedObject())
 251 return false;
 252 return !toRenderEmbeddedObject(renderer())->showsUnavailablePluginIndicator();
 253}
 254
245255#if ENABLE(NETSCAPE_PLUGIN_API)
246256
247257NPObject* HTMLPlugInElement::getNPObject()

Source/WebCore/html/HTMLPlugInElement.h

@@protected:
8282 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
8383 virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
8484
 85 virtual bool useFallbackContent() const { return false; }
 86
8587 // Subclasses should use guardedDispatchBeforeLoadEvent instead of calling dispatchBeforeLoadEvent directly.
8688 bool guardedDispatchBeforeLoadEvent(const String& sourceURL);
8789

@@private:
9698
9799 virtual RenderWidget* renderWidgetForJSBindings() const = 0;
98100
 101 virtual bool supportsFocus() const OVERRIDE;
 102
99103 virtual bool isKeyboardFocusable(KeyboardEvent*) const;
100104 virtual bool isPluginElement() const;
101105

Source/WebCore/html/HTMLPlugInImageElement.h

@@private:
119119 virtual void finishParsingChildren();
120120
121121 void updateWidgetIfNecessary();
122  virtual bool useFallbackContent() const { return false; }
123122
124123 virtual void updateSnapshot(PassRefPtr<Image>) OVERRIDE;
125124 virtual void dispatchPendingMouseClick() OVERRIDE;

LayoutTests/ChangeLog

 12013-04-03 Dave Michael <dmichael@chromium.org>
 2
 3 Unable to focus on embedded plugins such as Flash via javascript focus()
 4 https://bugs.webkit.org/show_bug.cgi?id=32292
 5
 6 Reviewed by Ryosuke Niwa.
 7
 8 Add/update testing to ensure embed, object, and applet tags now support
 9 focus except when plugin content did not load.
 10
 11 * fast/events/resources/tabindex-focus-blur-all-frame1.html: Change embed and object
 12 elements to reference an invalid plugin, to be consistent with applet. These
 13 element types are not focusable when there is valid plugin content.
 14 * fast/events/resources/tabindex-focus-blur-all-frame2.html: Same as above.
 15 * fast/events/resources/tabindex-focus-blur-all-iframe1.html: Same as above.
 16 * fast/events/resources/tabindex-focus-blur-all-iframe2.html: Same as above.
 17 * java/focus-expected.txt: Added.
 18 * java/focus.html: Added.
 19 * plugins/focus-expected.txt: Added.
 20 * plugins/focus.html: Added.
 21
1222013-04-03 Felipe Zimmerle <felipe@zimmerle.org>
223
324 CSP blocks inline style when cloning a node

LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame1.html

2020applet:<br>
2121<applet width="100" height="100" code="" tabindex="-1" id="applet1"></applet><br>
2222object:<br>
23 <object type="application/x-webkit-test-netscape" width="100" height="100" id="object1"></object><br>
 23<object type="application/x-no-such-plugin" width="100" height="100" id="object1"></object><br>
2424embed:<br>
25 <embed type="application/x-webkit-test-netscape" width="100" height="100" tabindex="3" id="embed1"></embed><br>
 25<embed type="application/x-no-such-plugin" width="100" height="100" tabindex="3" id="embed1"></embed><br>
2626
2727<!--presentation-related elements-->
2828<div id="div1b" tabindex="0">

LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame2.html

2020applet:<br>
2121<applet width="100" height="100" code="" tabindex="2" id="applet3"></applet><br>
2222object:<br>
23 <object type="application/x-webkit-test-netscape" width="100" height="100" tabindex="0" id="object3"></object><br>
 23<object type="application/x-no-such-plugin" width="100" height="100" tabindex="0" id="object3"></object><br>
2424embed:<br>
25 <embed type="application/x-webkit-test-netscape" width="100" height="100" tabindex="-1" id="embed3"></embed><br>
 25<embed type="application/x-no-such-plugin" width="100" height="100" tabindex="-1" id="embed3"></embed><br>
2626
2727<!--presentation-related elements-->
2828<div id="div3b">

LayoutTests/fast/events/resources/tabindex-focus-blur-all-iframe1.html

2020applet:<br>
2121<applet width="100" height="100" code="" id="applet2"></applet><br>
2222object:<br>
23 <object type="application/x-webkit-test-netscape" width="100" height="100" tabindex="3" id="object2"></object><br>
 23<object type="application/x-no-such-plugin" width="100" height="100" tabindex="3" id="object2"></object><br>
2424embed:<br>
25 <embed type="application/x-webkit-test-netscape" width="100" height="100" tabindex="0" id="embed2"></embed><br>
 25<embed type="application/x-no-such-plugin" width="100" height="100" tabindex="0" id="embed2"></embed><br>
2626
2727<!--presentation-related elements-->
2828<div id="div2b" tabindex="-1">

LayoutTests/fast/events/resources/tabindex-focus-blur-all-iframe2.html

2020applet:<br>
2121<applet width="100" height="100" code="" tabindex="0" id="applet4"></applet><br>
2222object:<br>
23 <object type="application/x-webkit-test-netscape" width="100" height="100" tabindex="-1" id="object4"></object><br>
 23<object type="application/x-no-such-plugin" width="100" height="100" tabindex="-1" id="object4"></object><br>
2424embed:<br>
25 <embed type="application/x-webkit-test-netscape" width="100" height="100" id="embed4"></embed><br>
 25<embed type="application/x-no-such-plugin" width="100" height="100" id="embed4"></embed><br>
2626
2727<!--presentation-related elements-->
2828<div id="div4b" tabindex="3">

LayoutTests/java/focus-expected.txt

 1Test for Applet for bug 32292: Unable to focus on embedded plugins such as Flash via javascript focus().
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS successfullyParsed is true
 7
 8TEST COMPLETE
 9PASS "appletElem"; document.activeElement === pluginElement is true
 10PASS "appletElemWithFallbackContents"; document.activeElement === pluginElement is true
 11PASS "noCodeAppletElem"; document.activeElement === pluginElement is false
 12PASS "noCodeAppletElemWithFallbackContents"; document.activeElement === pluginElement is false
 13PASS "noCodeAppletElemWithTabindex"; document.activeElement === pluginElement is true
 14PASS "noCodeAppletElemWithContenteditable"; document.activeElement === pluginElement is true
 15Test for bug 32292: "Unable to focus on embedded plugins such as Flash via javascript focus()"
 16
 17This tests focusing Applets. See LayoutTests/plugins for Embed and Object elements.
 18
 19

LayoutTests/java/focus.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<meta charset="utf-8">
 5<script src="../fast/js/resources/js-test-pre.js"></script>
 6<script>
 7if (window.testRunner)
 8 testRunner.overridePreference("WebKitJavaEnabled", "1");
 9</script>
 10</head>
 11<body>
 12<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=32292">bug 32292</a>:
 13"Unable to focus on embedded plugins such as Flash via javascript focus()"</p>
 14<p>This tests focusing Applets. See LayoutTests/plugins for Embed and Object elements.</p>
 15<div id=appletOwner>
 16
 17<applet id="appletElem" width=150 height=25 code="SharedApplet.class" name="javaTest" shouldFocus=true></applet>
 18
 19<applet id="appletElemWithFallbackContents" width=150 height=25 code="SharedApplet.class" name="javaTest" shouldFocus=true>Fallback Contents.</applet>
 20
 21<applet id="noCodeAppletElem" width=150 height=25 code="DoesNotExist.class" shouldFocus=false></applet>
 22
 23<applet id="noCodeAppletElemWithFallbackContents" width=150 height=25 code="DoesNotExist.class" shouldFocus=false>Fallback contents.</applet>
 24
 25<applet id="noCodeAppletElemWithTabindex" width=150 height=25 code="DoesNotExist.class" tabindex=-1 shouldFocus=true></applet>
 26
 27<applet id="noCodeAppletElemWithContenteditable" width=150 height=25 code="DoesNotExist.class" shouldFocus=true></applet>
 28
 29</div>
 30<script>
 31
 32description("Test for Applet for bug 32292: Unable to focus on embedded plugins such as Flash via javascript focus().");
 33
 34function RunTest() {
 35 var owner = document.getElementById("appletOwner");
 36 for (var i = 0; i < owner.childNodes.length; ++i) {
 37 pluginElement = owner.childNodes[i];
 38 if (pluginElement.id) {
 39 pluginElement.focus();
 40 shouldBe('"' + pluginElement.id + '"; document.activeElement === pluginElement',
 41 pluginElement.getAttribute("shouldFocus").toString());
 42 pluginElement.blur();
 43 }
 44 }
 45}
 46
 47document.addEventListener("DOMContentLoaded", RunTest, false);
 48
 49</script>
 50<script src="../fast/js/resources/js-test-post.js"></script>
 51</body>
 52</html>

LayoutTests/plugins/focus-expected.txt

 1Test for Embed and Object for bug 32292: Unable to focus on embedded plugins such as Flash via javascript focus().
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS successfullyParsed is true
 7
 8TEST COMPLETE
 9PASS "embedElem"; document.activeElement === pluginElement is true
 10PASS "objectElem"; document.activeElement === pluginElement is true
 11PASS "embedElemWithFallbackContents"; document.activeElement === pluginElement is true
 12PASS "objectElemWithFallbackContents"; document.activeElement === pluginElement is true
 13PASS "noPluginEmbedElem"; document.activeElement === pluginElement is false
 14PASS "noPluginObjectElem"; document.activeElement === pluginElement is false
 15PASS "noPluginEmbedElemWithFallbackContents"; document.activeElement === pluginElement is false
 16PASS "noPluginObjectElemWithFallbackContents"; document.activeElement === pluginElement is false
 17PASS "noPluginEmbedElemWithTabindex"; document.activeElement === pluginElement is true
 18PASS "noPluginObjectElemWithTabindex"; document.activeElement === pluginElement is true
 19PASS "noPluginEmbedElemWithContenteditable"; document.activeElement === pluginElement is true
 20PASS "noPluginObjectElemWithContenteditable"; document.activeElement === pluginElement is true
 21fast/events/tabindex-focus-blur-all.html
 22Test for bug 32292: "Unable to focus on embedded plugins such as Flash via javascript focus()"
 23
 24This tests focusing Embeds and Objects. See LayoutTests/java for Applet elements.
 25
 26 Fallback contents. Fallback contents. Fallback contents.

LayoutTests/plugins/focus.html

 1fast/events/tabindex-focus-blur-all.html<!DOCTYPE html>
 2<html>
 3<head>
 4<meta charset="utf-8">
 5<script src="../fast/js/resources/js-test-pre.js"></script>
 6</head>
 7<body>
 8<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=32292">bug 32292</a>:
 9"Unable to focus on embedded plugins such as Flash via javascript focus()"</p>
 10<p>This tests focusing Embeds and Objects. See LayoutTests/java for Applet elements.</p>
 11<div id=embedOwner>
 12<embed id="embedElem" type="application/x-webkit-test-netscape" width=100 height=100 shouldFocus=true></embed>
 13<object id="objectElem" type="application/x-webkit-test-netscape" windowedPlugin="false" width=100 height=100 shouldFocus=true></object>
 14
 15<embed id="embedElemWithFallbackContents" type="application/x-webkit-test-netscape" width=100 height=100 shouldFocus=true>Fallback contents.</embed>
 16<object id="objectElemWithFallbackContents" type="application/x-webkit-test-netscape" windowedPlugin="false" width=100 height=100 shouldFocus=true>Fallback contents.</object>
 17
 18<embed id="noPluginEmbedElem" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 shouldFocus=false></embed>
 19<object id="noPluginObjectElem" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 shouldFocus=false></object>
 20
 21<embed id="noPluginEmbedElemWithFallbackContents" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 shouldFocus=false>Fallback contents.</embed>
 22<object id="noPluginObjectElemWithFallbackContents" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 shouldFocus=false>Fallback contents.</object>
 23
 24<embed id="noPluginEmbedElemWithTabindex" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 tabindex=-1 shouldFocus=true></embed>
 25<object id="noPluginObjectElemWithTabindex" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 tabindex=-1 shouldFocus=true></object>
 26
 27<embed id="noPluginEmbedElemWithContenteditable" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 contenteditable=true shouldFocus=true></embed>
 28<object id="noPluginObjectElemWithContenteditable" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 contenteditable=true shouldFocus=true></object>
 29</div>
 30<script>
 31
 32description("Test for Embed and Object for bug 32292: Unable to focus on embedded plugins such as Flash via javascript focus().");
 33
 34function RunTest() {
 35 var owner = document.getElementById("embedOwner");
 36 for (var i = 0; i < owner.childNodes.length; ++i) {
 37 pluginElement = owner.childNodes[i];
 38 if (pluginElement.id) {
 39 pluginElement.focus();
 40 shouldBe('"' + pluginElement.id + '"; document.activeElement === pluginElement',
 41 pluginElement.getAttribute("shouldFocus").toString());
 42 pluginElement.blur();
 43 }
 44 }
 45}
 46
 47document.addEventListener("DOMContentLoaded", RunTest, false);
 48
 49</script>
 50<script src="../fast/js/resources/js-test-post.js"></script>
 51</body>
 52</html>