fast/events/tabindex-focus-blur-all.html<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=32292">bug 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 data-expected-tabindex=-1></embed>
<object id="objectElem" type="application/x-webkit-test-netscape" windowedPlugin="false" width=100 height=100 shouldFocus=true data-expected-tabindex=0></object>

<embed id="embedElemWithFallbackContents" type="application/x-webkit-test-netscape" width=100 height=100 shouldFocus=true  data-expected-tabindex=-1>Fallback contents.</embed>
<object id="objectElemWithFallbackContents" type="application/x-webkit-test-netscape" windowedPlugin="false" width=100 height=100 shouldFocus=true data-expected-tabindex=0>Fallback contents.</object>

<embed id="noPluginEmbedElem" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 shouldFocus=false data-expected-tabindex=-1></embed>
<object id="noPluginObjectElem" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 shouldFocus=false data-expected-tabindex=0></object>

<embed id="noPluginEmbedElemWithFallbackContents" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 shouldFocus=false data-expected-tabindex=-1>Fallback contents.</embed>
<object id="noPluginObjectElemWithFallbackContents" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 shouldFocus=false data-expected-tabindex=0>Fallback contents.</object>

<embed id="noPluginEmbedElemWithTabindex" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 tabindex=-1 shouldFocus=true data-expected-tabindex=-1></embed>
<object id="noPluginObjectElemWithTabindex" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 tabindex=-1 shouldFocus=true data-expected-tabindex=-1></object>

<embed id="noPluginEmbedElemWithContenteditable" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 contenteditable=true shouldFocus=true data-expected-tabindex=-1></embed>
<object id="noPluginObjectElemWithContenteditable" type="application/x-no-such-plugin" windowedPlugin="false" width=100 height=100 contenteditable=true shouldFocus=true data-expected-tabindex=0></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());
            shouldBe('pluginElement.tabIndex', 'parseInt(pluginElement.getAttribute("data-expected-tabindex"))');
            pluginElement.blur();
        }
    }
}

document.addEventListener("DOMContentLoaded", RunTest, false);

</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>
