--- /dev/null
+Tests to ensure that accesskey works in iframes and other iframes don't effect current accesskey maps.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Accesskeys should work in an iframe. "iframe1" has both "inputG" and "inputH" (accesskey="c") elements.
+PASS iframe1.contentDocument.getElementById("inputG").focus(); pressAccessKey("c"); targetsOfFocusEvents is ["inputG", "inputH"]
+
+"inputC" element has an accessKey of "a" and other iframes also have elements with accesskey of "a". An acccesskey should not be overridden by other iframes, so "inputC" should be selected.
+PASS document.getElementById("inputB").focus(); pressAccessKey("a"); targetsOfFocusEvents; is ["inputB", "inputC"]
+
+A child iframe, iframe1, has an element with accesskey of "d", which should be ignored.
+PASS document.getElementById("inputB").focus(); pressAccessKey("d"); targetsOfFocusEvents is ["inputB"]
+
+An accesskey defined in an ancestor iframe should be ignored. "inputD" has accesskey of "b", which should not be selected from descendant iframes, iframe1 and iframe2.
+PASS iframe1.contentDocument.getElementById("inputG").focus(); pressAccessKey("b"); targetsOfFocusEvents is ["inputG"]
+PASS iframe2.contentDocument.getElementById("inputK").focus(); pressAccessKey("b"); targetsOfFocusEvents is ["inputK"]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../js/resources/js-test-pre.js"></script>
+<p id="description"></p>
+<div id="sandbox"></div>
+<pre id="console"></pre>
+<script>
+description("Tests to ensure that accesskey works in iframes and other iframes don't effect current accesskey maps.");
+
+function pressAccessKey(key)
+{
+ if (navigator.userAgent.search(/\bMac OS X\b/) != -1)
+ modifiers = ["ctrlKey", "altKey"];
+ else
+ modifiers = ["altKey"];
+ eventSender.keyDown(key, modifiers);
+}
+
+var targetsOfFocusEvents = [];
+
+function clearEventRecords()
+{
+ targetsOfFocusEvents = [];
+}
+
+function recordFocusEvent(event)
+{
+ if (event.type == 'focus')
+ targetsOfFocusEvents.push(event.target.id);
+}
+
+function createDomInDocument(doc, tagName, attributes)
+{
+ var element = doc.createElement(tagName);
+ for (var name in attributes)
+ element.setAttribute(name, attributes[name]);
+
+ if (attributes['id'])
+ element.addEventListener('focus', recordFocusEvent, false);
+ return element;
+}
+
+function test()
+{
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var sandbox = document.getElementById('sandbox');
+ sandbox.appendChild(createDomInDocument(document, 'input', {'id': 'inputB'}));
+ sandbox.appendChild(createDomInDocument(document, 'input', {'id': 'inputC', 'accesskey': 'a'}));
+ sandbox.appendChild(createDomInDocument(document, 'input', {'id': 'inputD', 'accesskey': 'b'}));
+ sandbox.appendChild(createDomInDocument(document, 'input', {'id': 'inputE', 'accesskey': 'c'}));
+
+ window.iframe1 = document.createElement('iframe');
+ sandbox.appendChild(iframe1);
+ iframe1.contentDocument.body.appendChild(createDomInDocument(iframe1.contentDocument, 'input', {'id': 'inputG', 'accesskey': 'a'}));
+ iframe1.contentDocument.body.appendChild(createDomInDocument(iframe1.contentDocument, 'input', {'id': 'inputH', 'accesskey': 'c'}));
+ iframe1.contentDocument.body.appendChild(createDomInDocument(iframe1.contentDocument, 'input', {'id': 'inputI', 'accesskey': 'd'}));
+
+ window.iframe2 = iframe1.contentDocument.createElement('iframe');
+ iframe1.contentDocument.body.appendChild(iframe2);
+ iframe2.contentDocument.body.appendChild(createDomInDocument(iframe2.contentDocument, 'input', {'id': 'inputK'}));
+ iframe2.contentDocument.body.appendChild(createDomInDocument(iframe2.contentDocument, 'input', {'id': 'inputL', 'accesskey': 'a'}));
+
+ debug('Accesskeys should work in an iframe. "iframe1" has both "inputG" and "inputH" (accesskey="c") elements.');
+ clearEventRecords();
+ shouldBe('iframe1.contentDocument.getElementById("inputG").focus(); pressAccessKey("c"); targetsOfFocusEvents', '["inputG", "inputH"]');
+
+ debug('\n"inputC" element has an accessKey of "a" and other iframes also have elements with accesskey of "a". An acccesskey should not be overridden by other iframes, so "inputC" should be selected.');
+ clearEventRecords();
+ shouldBe('document.getElementById("inputB").focus(); pressAccessKey("a"); targetsOfFocusEvents;', '["inputB", "inputC"]');
+
+ debug('\nA child iframe, iframe1, has an element with accesskey of "d", which should be ignored.');
+ clearEventRecords();
+ shouldBe('document.getElementById("inputB").focus(); pressAccessKey("d"); targetsOfFocusEvents', '["inputB"]');
+
+ debug('\nAn accesskey defined in an ancestor iframe should be ignored. "inputD" has accesskey of "b", which should not be selected from descendant iframes, iframe1 and iframe2.');
+ clearEventRecords();
+ shouldBe('iframe1.contentDocument.getElementById("inputG").focus(); pressAccessKey("b"); targetsOfFocusEvents', '["inputG"]');
+ clearEventRecords();
+ shouldBe('iframe2.contentDocument.getElementById("inputK").focus(); pressAccessKey("b"); targetsOfFocusEvents', '["inputK"]');
+}
+
+test();
+
+var successfullyParsed = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>