Commit a417a16c authored by Hugo Holgersson's avatar Hugo Holgersson Committed by Commit Bot

Snav: Convert all snav*iframe*.html tests to snav-testharness.js

The changes to snav-testharness.js lets us assert navigations
in and out of iframes:

 1) To be able to test focus movements in and out of iframes,
    we need to listen for 'keyup'-events on the document where
    focus is _about_to_go_.

    'keyup' targets the currently focused document. When 'keyup'
    comes, 'keydown' has already changed focus to the new document.

 2) Previously each movement had its own async_test(). Now we use
    one async_test() with many "test steps": one for each movement.
    This helps us avoid tricky (mis)usage of testharness.js's
    fetch_tests_from_window().

The changes to the HTML files are mostly mechanical except that
I gave some elements new or renamed ids so they become easier
to distinguish when debugging.

Once we've fixed Issue 801162, the tests' expectations will change:
We want spatnav to first _focus_ the iframe (before scrolling it
or searching inside of it).

Bug: 803086, 891658, 801162
Change-Id: Ib53bb224398510b5744927a5d892381870fa4690
Reviewed-on: https://chromium-review.googlesource.com/c/1314469
Commit-Queue: Hugo Holgersson <hugoh@vewd.com>
Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#604962}
parent 4dea3aba
<html>
<body>
<iframe width='80%' height="70px" frameborder="0" src="data:text/html,
<body>
<a id='1' href='%23'>b</a>
<a id='2' href='%23'>c</a>
<a id='3' href='%23'>d</a>
<a id='4' href='%23'>e</a>
<a id='5' href='%23'>f</a>
<a id='6' href='%23'>g</a>
<a id='7' href='%23'>h</a>
<a id='8' href='%23'>i</a>
</body>
"></iframe>
</body>
<html>
(function() { (function() {
"use strict"; "use strict";
let gAsyncTest;
// TODO: Use WebDriver's API instead of eventSender.
// Hopefully something like:
// test_driver.move_focus(direction).then(...)
function triggerMove(direction) { function triggerMove(direction) {
switch (direction) { switch (direction) {
case 'Up': case 'Up':
...@@ -18,33 +23,60 @@ ...@@ -18,33 +23,60 @@
} }
} }
function stepAndAssertMoves(expectedMoves, focusMoves) { function focusedDocument(currentDocument=document) {
if (expectedMoves.length == 0) let subframes = Array.from(currentDocument.defaultView.frames);
for (let frame of subframes) {
let focused = focusedDocument(frame.document);
if (focused)
return focused;
}
if (currentDocument.hasFocus())
return currentDocument;
return null;
}
// Allows us to query element ids also in iframes' documents.
function findElement(searchString) {
let searchPath = searchString.split(",");
let currentDocument = document;
let elem = undefined;
while (searchPath.length > 0) {
let id = searchPath.shift();
elem = currentDocument.getElementById(id);
assert_not_equals(elem, null, 'Could not find "' + searchString + '",');
if (elem.tagName == "IFRAME")
currentDocument = elem.contentDocument;
}
return elem;
}
function stepAndAssertMoves(expectedMoves) {
if (expectedMoves.length == 0) {
gAsyncTest.done();
return; return;
}
let move = expectedMoves.shift(); let move = expectedMoves.shift();
let direction = move[0]; let direction = move[0];
let expectedId = move[1]; let expectedId = move[1];
// TODO: Use WebDriver's API instead of eventSender. let wanted = findElement(expectedId);
// Hopefully something like: let receivingDoc = wanted.ownerDocument;
// test_driver.move_focus(direction).then(...) let verifyAndAdvance = gAsyncTest.step_func(function() {
async_test(t => { let focused = focusedDocument().activeElement;
let checkFocus = t.step_func_done(function() { assert_equals(focused, wanted);
let expectedElement = document.getElementById(expectedId); // Kick off another async test step.
assert_equals(document.activeElement, expectedElement); stepAndAssertMoves(expectedMoves);
});
// Kick off another async test before closing this one.
stepAndAssertMoves(expectedMoves, focusMoves + 1);
});
// "... the default action MUST be to shift the document focus". // "... the default action MUST be to shift the document focus".
// https://www.w3.org/TR/uievents/#event-type-keydown // https://www.w3.org/TR/uievents/#event-type-keydown
// Any focus movement must have happened during keydown, so once we got // Any focus movement must have happened during keydown, so once we got
// the succeeding keyup-event, it's safe to assert activeElement. // the succeeding keyup-event, it's safe to assert activeElement.
document.addEventListener('keyup', checkFocus, {once: true}); // The keyup-event targets the, perhaps newly, focused document.
triggerMove(direction); receivingDoc.addEventListener('keyup', verifyAndAdvance, {once: true});
}, focusMoves + "th move: " + direction + '-key moves focus to ' + triggerMove(direction);
'the element with id: ' + expectedId + '.');
} }
// TODO: Port all old spatial navigation layout tests to this method. // TODO: Port all old spatial navigation layout tests to this method.
...@@ -59,7 +91,13 @@ ...@@ -59,7 +91,13 @@
assertFocusMoves: function(expectedMoves) { assertFocusMoves: function(expectedMoves) {
snav.assertSnavEnabledAndTestable(); snav.assertSnavEnabledAndTestable();
stepAndAssertMoves(expectedMoves, 0); gAsyncTest = async_test("Focus movements:\n" +
JSON.stringify(expectedMoves).replace(/],/g, ']\n') + '\n');
// All iframes must be loaded before trying to navigate to them.
window.addEventListener('load', gAsyncTest.step_func(() => {
stepAndAssertMoves(expectedMoves);
}));
} }
} }
})(); })();
Link
Link
Link
Here is a link.
Link
PASS successfullyParsed is true
TEST COMPLETE
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "3"
PASS gFocusedDocument.activeElement.getAttribute("id") is "4"
PASS gFocusedDocument.activeElement.getAttribute("id") is "5"
PASS gFocusedDocument.activeElement.getAttribute("id") is "6"
PASS gFocusedDocument.activeElement.getAttribute("id") is "7"
PASS gFocusedDocument.activeElement.getAttribute("id") is "8"
PASS gFocusedDocument.activeElement.getAttribute("id") is "9"
PASS gFocusedDocument.activeElement.getAttribute("id") is "8"
PASS gFocusedDocument.activeElement.getAttribute("id") is "7"
PASS gFocusedDocument.activeElement.getAttribute("id") is "6"
PASS gFocusedDocument.activeElement.getAttribute("id") is "5"
PASS gFocusedDocument.activeElement.getAttribute("id") is "4"
PASS gFocusedDocument.activeElement.getAttribute("id") is "3"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
<html> <table style="text-align: top;" border="0" cellpadding="3px" cellspacing="3px">
<!-- <tr>
This test ensures the cross iframe traversal correctness of spatial navigation: <td valign="top" width="10%">
focusable elements in nested inner frame should be accessible. <a id="start" href="#">Link</a><br>
</td>
<td valign="top">
<iframe id="frameA" width="50%" height="100px" frameborder="1" srcdoc="
<body id='frameAbody'>
<iframe id='frameB' width='80%' height='70px' frameborder='0' srcdoc='
<body id=frameBbody>
<a id=1 href=www>b</a>
<a id=2 href=www>c</a>
<a id=3 href=www>d</a>
<a id=4 href=www>e</a>
<a id=5 href=www>f</a>
<a id=6 href=www>g</a>
<a id=7 href=www>h</a>
<a id=8 href=www>i</a>
</body>
'></iframe>
"></iframe><br>
</td>
<td valign="top" width="10%">
<a id="9" href="#">Link</a><br>
</td>
</tr>
<tr>
<td valign="top" width="10%">
<a id="10" href="#">Link</a><br>
</td>
<td valign="top">
<p><a id="11" href="#">Here</a> is a link.</p>
</td>
<td valign="top" width="10%">
<a id="12" href="#">Link</a><br>
</td>
</tr>
</table>
* Pre-conditions: <p>Ensure spatnav can navigate in and out of nested iframes.</p>
1) DRT support for spatial navigation enable/disable.
* Navigation steps: <script src="../../resources/testharness.js"></script>
1) Loads this page, focus goes to "start" automatically. <script src="../../resources/testharnessreport.js"></script>
2) Focus moves along the elements in the two level deep nested frame, <script src="resources/snav-testharness.js"></script>
but going back to the main frame later on. <script>
--> var resultMap = [
<head> // ["Right", "frameA,frameAbody"], crbug.com/801162
<script src="../../resources/js-test.js"></script> // ["Right", "frameA,frameB,frameBbody"], crbug.com/801162
<script src="resources/spatial-navigation-utils.js"></script> ["Right", "frameA,frameB,1"],
<script type="application/javascript"> ["Right", "frameA,frameB,2"],
["Right", "frameA,frameB,3"],
var resultMap = [ ["Right", "frameA,frameB,4"],
["Right", "1"], ["Right", "frameA,frameB,5"],
["Right", "2"], ["Right", "frameA,frameB,6"],
["Right", "3"], ["Right", "frameA,frameB,7"],
["Right", "4"], ["Right", "frameA,frameB,8"],
["Right", "5"], ["Right", "9"],
["Right", "6"], // ["Left", "frameA,frameAbody"], crbug.com/801162
["Right", "7"], // ["Left", "frameA,frameB,frameBbody"], crbug.com/801162
["Right", "8"], ["Left", "frameA,frameB,8"],
["Right", "9"], ["Left", "frameA,frameB,7"],
["Left", "8"], ["Left", "frameA,frameB,6"],
["Left", "7"], ["Left", "frameA,frameB,5"],
["Left", "6"], ["Left", "frameA,frameB,4"],
["Left", "5"], ["Left", "frameA,frameB,3"],
["Left", "4"], ["Left", "frameA,frameB,2"],
["Left", "3"], ["Left", "frameA,frameB,1"],
["Left", "2"], ["Left", "start"],
["Left", "1"], ];
["Left", "start"], // Start at a known place.
["DONE", "DONE"] document.getElementById("start").focus();
]; snav.assertFocusMoves(resultMap);
</script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
testRunner.overridePreference("WebKitSpatialNavigationEnabled", 1);
testRunner.waitUntilDone();
}
function runTest()
{
// starting the test itself: get to a known place.
document.getElementById("start").focus();
initTest(resultMap, testCompleted);
}
function testCompleted()
{
if (window.testRunner)
testRunner.notifyDone();
}
window.onload = runTest;
</script>
</head>
<body>
<table style="text-align: top;" border="0" cellpadding="3px" cellspacing="3px">
<tr>
<td valign="top" width="10%">
<a id="start" href="#">Link</a><br>
</td>
<td valign="top">
<iframe width="50%" height="100px" frameborder="1" src="resources/iframe.html"></iframe><br>
</td>
<td valign="top" width="10%">
<a id="9" href="#">Link</a><br>
</td>
</tr>
<tr>
<td valign="top" width="10%">
<a id="10" href="#">Link</a><br>
</td>
<td valign="top">
<p><a id="11" href="#">Here</a> is a link.</p>
</td>
<td valign="top" width="10%">
<a id="12" href="#">Link</a><br>
</td>
</tr>
</table>
<div id="console"></div>
</body>
</html>
a
e
PASS successfullyParsed is true
TEST COMPLETE
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
PASS gFocusedDocument.activeElement.getAttribute("id") is "end"
PASS gFocusedDocument.activeElement.getAttribute("id") is "end"
PASS gFocusedDocument.activeElement.getAttribute("id") is "end"
PASS gFocusedDocument.activeElement.getAttribute("id") is "end"
PASS gFocusedDocument.activeElement.getAttribute("id") is "end"
PASS gFocusedDocument.activeElement.getAttribute("id") is "end"
PASS gFocusedDocument.activeElement.getAttribute("id") is "end"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
This is to test that an iframe with no focusable content still scrolls
<html> <div><a id="start" href="a">a</a></div>
<!--
This test ensures the basic traversal correctness of Spatial Navigation
algorithm: iframes without any focusable content should be ignored.
* Pre-conditions: <iframe id="frameA" width="80" height="80" scrolling="auto" src="data:text/html,
1) DRT support for SNav enable/disable. <body id='frameAbody'>
<img width=120 height=200 src='resources/green.png'>
* Navigation steps: </body>
1) Loads this page, focus goes to "start" automatically. "></iframe><br>
2) Focus moves from "start" to "end" bypassing the two iframes
in between them, once both have no focusable elements inside.
-->
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/spatial-navigation-utils.js"></script>
<script type="application/javascript">
var resultMap = [
["Down", "start"],
["Down", "start"],
["Down", "start"],
["Down", "start"],
["Down", "start"],
["Down", "start"],
["Down", "end"],
["Up" , "end"],
["Up" , "end"],
["Up" , "end"],
["Up" , "end"],
["Up" , "end"],
["Up" , "end"],
["Up" , "start"],
["DONE", "DONE"]
];
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
testRunner.overridePreference("WebKitSpatialNavigationEnabled", 1);
testRunner.waitUntilDone();
}
function runTest()
{
// starting the test itself: get to a known place.
document.getElementById("start").focus();
initTest(resultMap, testCompleted);
}
function testCompleted()
{
if (window.testRunner)
testRunner.notifyDone();
}
window.onload = runTest;
</script>
</head>
<body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
<div><a id="start" href="a">a</a></div>
<iframe width="80" height="80" scrolling="auto" src="data:text/html,
<body>
<img width=120 height=200 src='resources/green.png'>
</body>
"></iframe><br>
<iframe scrolling="auto" src="data:text/html,
<body>
<img width=120 height=200 src='resources/green.png'>
</body>
"></iframe><br>
<a id="end" href="a">e</a> <iframe id="frameB" scrolling="auto" src="data:text/html,
<div id="console"></div> <body id='frameBbody'>
This is to test that an iframe with no focusable content still scrolls <img width=120 height=200 src='resources/green.png'>
</body> </body>
</html> "></iframe><br>
<a id="end" href="a">e</a>
<p>Iframes with no focusable content still scrolls.</p>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
/*
Once crbug.com/801162 is fixed, the expectation will change:
The iframe can only be scrolled when being focused.
*/
var resultMap = [
["Down", "start"],
["Down", "start"],
["Down", "start"],
["Down", "start"],
["Down", "start"],
["Down", "start"],
["Down", "end"],
["Up" , "end"],
["Up" , "end"],
["Up" , "end"],
["Up" , "end"],
["Up" , "end"],
["Up" , "end"],
["Up" , "start"],
];
// Start at a known place.
document.getElementById("start").focus();
snav.assertFocusMoves(resultMap);
</script>
a
a
PASS successfullyParsed is true
TEST COMPLETE
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "3"
PASS gFocusedDocument.activeElement.getAttribute("id") is "7"
PASS gFocusedDocument.activeElement.getAttribute("id") is "6"
PASS gFocusedDocument.activeElement.getAttribute("id") is "end"
PASS gFocusedDocument.activeElement.getAttribute("id") is "4"
PASS gFocusedDocument.activeElement.getAttribute("id") is "5"
PASS gFocusedDocument.activeElement.getAttribute("id") is "6"
PASS gFocusedDocument.activeElement.getAttribute("id") is "3"
PASS gFocusedDocument.activeElement.getAttribute("id") is "7"
PASS gFocusedDocument.activeElement.getAttribute("id") is "3"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
<html> <div><a id="start" href="a">a</a></div>
<!--
This test ensures the basic iframe traversal correctness of Spatial Navigation <iframe id="frameA" src="data:text/html,
algorithm: focusable elements in a <iframe> should be accessible. <body id='frameAbody'>
<a id='1' href='a'>b</a><br>
* Pre-conditions: <a id='2' href='a'>c</a><br>
1) DRT support for SNav enable/disable. <a id='3' href='a'>d</a><br>
<div style='margin-left:80px'>
* Navigation steps: <a id='7' href='a'>e</a>
1) Loads this page, focus goes to "start" automatically. </div>
2) Focus moves along the elements in the two iframes in the </body>
Web page, eventually going to outer an southward link, but "></iframe><br>
going back to the iframe on the top later on.
-->
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/spatial-navigation-utils.js"></script>
<script type="application/javascript">
var resultMap = [
["Down", "1"],
["Down", "2"],
["Down", "3"],
["Down", "7"],
["Down", "6"],
["Down", "end"],
["Up", "4"],
["Right", "5"],
["Right", "6"],
["Up", "3"],
["Right", "7"],
["Up", "3"],
["Up", "2"],
["Up", "1"],
["DONE", "DONE"]
];
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
testRunner.overridePreference("WebKitSpatialNavigationEnabled", 1);
testRunner.waitUntilDone();
}
function runTest()
{
// starting the test itself: get to a known place.
document.getElementById("start").focus();
initTest(resultMap, testCompleted);
}
function testCompleted()
{
if (window.testRunner)
testRunner.notifyDone();
}
window.onload = runTest;
</script>
</head>
<body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
<div><a id="start" href="a">a</a></div>
<iframe src="data:text/html,
<body>
<a id='1' href='a'>b</a><br>
<a id='2' href='a'>c</a><br>
<a id='3' href='a'>d</a><br>
<div style='margin-left:80px'>
<a id='7' href='a'>e</a>
</div>
</body>
"></iframe><br>
<iframe src="data:text/html,
<body>
<a id='4' href='a'>g</a>
<a id='5' href='a'>h</a>
<a id='6' href='a'>i</a>
</body>
"></iframe><br>
<a id="end" href="a">a</a> <iframe id="frameB" src="data:text/html,
<div id="console"></div> <body id='frameBbody'>
<a id='4' href='a'>g</a>
<a id='5' href='a'>h</a>
<a id='6' href='a'>i</a>
</body> </body>
</html> "></iframe><br>
<a id="end" href="a">a</a>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
/*
Once crbug.com/801162 is fixed, the expectation will change:
Spatnav must focus the iframe before it can search it.
*/
var resultMap = [
["Down", "frameA,1"],
["Down", "frameA,2"],
["Down", "frameA,3"],
["Down", "frameA,7"],
["Down", "frameB,6"],
["Down", "end"],
["Up", "frameB,4"],
["Right", "frameB,5"],
["Right", "frameB,6"],
["Up", "frameA,3"],
["Right", "frameA,7"],
["Up", "frameA,3"],
["Up", "frameA,2"],
["Up", "frameA,1"],
];
// Start at a known place.
document.getElementById("start").focus();
snav.assertFocusMoves(resultMap);
</script>
Link
PASS successfullyParsed is true
TEST COMPLETE
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "3"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
<html> <table style="text-align: top;" border="0" cellpadding="3px" cellspacing="3px">
<!-- <tr>
This test ensures the cross iframe traversal correctness of Spatial Navigation <td valign="top" width="10%">
algorithm: focusable elements in an <iframe> should be accessible even when <a id="start" href="http://google.com">Link</a><br>
the current focused element is in another <iframe> in the same page. </td>
<td valign="top">
* Pre-conditions: <iframe id="frameA" width="50%" height="100px" frameborder="1" src="data:text/html,
1) DRT support for SNav enable/disable. <body id='frameAbody'>
<a id='1' href='http://a'>b</a>
* Navigation steps: <a id='2' href='http://a'>c</a>
1) Loads this page, focus goes to "start" automatically. <a id='3' href='http://a'>d</a>
2) Focus moves along the elements in the two iframes in the </body>
Web page, eventually going to outer an southward link, but "></iframe><br>
going back to the iframe on the top later on. </td>
--> </tr>
<head> </table>
<script src="../../resources/js-test.js"></script>
<script src="resources/spatial-navigation-utils.js"></script> <script src="../../resources/testharness.js"></script>
<script type="application/javascript"> <script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
var resultMap = [ <script>
["Right", "1"], var resultMap = [
["Right", "2"], // ["Right", "frameA,frameAbody"], crbug.com/801162
["Right", "3"], ["Right", "frameA,1"],
["Left", "2"], ["Right", "frameA,2"],
["Left", "1"], ["Right", "frameA,3"],
["Left", "start"], ["Left", "frameA,2"],
["DONE", "DONE"] ["Left", "frameA,1"],
]; ["Left", "start"],
];
if (window.testRunner) { // Start at a known place.
testRunner.dumpAsText(); document.getElementById("start").focus();
testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1); snav.assertFocusMoves(resultMap);
testRunner.overridePreference("WebKitSpatialNavigationEnabled", 1); </script>
testRunner.waitUntilDone();
}
function runTest()
{
// starting the test itself: get to a known place.
document.getElementById("start").focus();
initTest(resultMap, testCompleted);
}
function testCompleted()
{
if (window.testRunner)
testRunner.notifyDone();
}
window.onload = runTest;
</script>
</head>
<body>
<table style="text-align: top;" border="0" cellpadding="3px" cellspacing="3px">
<tr>
<td valign="top" width="10%">
<a id="start" href="http://google.com">Link</a><br>
</td>
<td valign="top">
<iframe width="50%" height="100px" frameborder="1" src="data:text/html,
<body>
<a id='1' href='http://a'>b</a>
<a id='2' href='http://a'>c</a>
<a id='3' href='http://a'>d</a>
</body>
"></iframe><br>
</td>
</tr>
</table>
<div id="console"></div>
</body>
</html>
PASS successfullyParsed is true
TEST COMPLETE
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "end"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
<html> <div><a id="start" href="a"><img src="resources/green.png" width=30 height=30></a></div>
<!--
This test ensures the cross iframe traversal correctness of Spatial Navigation <iframe id="frameA" width="80" height="80" scrolling="auto" src="data:text/html,
algorithm: focusable elements in an <iframe> should be accessible even when <body id='frameAbody'>
the current focused element is in another <iframe> in the same page. <a id='1' href='a'><img src='no_image' width=30 height=30></a>
<div>
* Pre-conditions: <img src='no_image' width=50 height=300>
1) DRT support for SNav enable/disable. <a id='2' href='a'><img src='no_image' width=30 height=30></a>
</div>
* Navigation steps:
1) Loads this page, focus goes to "start" automatically.
2) Focus moves along the elements in the two iframes in the
Web page, eventually going to outer an southward link, but
going back to the iframe on the top later on.
-->
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/spatial-navigation-utils.js"></script>
<script type="application/javascript">
var resultMap = [
["Down", "1"],
["Down", "1"],
["Down", "1"],
["Down", "1"],
["Down", "1"],
["Down", "1"],
["Down", "1"],
["Down", "2"],
["Down", "end"],
["Up", "2"],
["Up", "2"],
["Up", "2"],
["Up", "2"],
["Up", "2"],
["Up", "2"],
["Up", "2"],
["Up", "1"],
["Up", "start"],
["DONE", "DONE"]
];
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
testRunner.overridePreference("WebKitSpatialNavigationEnabled", 1);
testRunner.waitUntilDone();
}
function runTest()
{
// starting the test itself: get to a known place.
document.getElementById("start").focus();
initTest(resultMap, testCompleted);
}
function testCompleted()
{
if (window.testRunner)
testRunner.notifyDone();
}
window.onload = runTest;
</script>
</head>
<body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
<div><a id="start" href="a"><img src="resources/green.png" width=30 height=30></a></div>
<iframe width="80" height="80" scrolling="auto" src="data:text/html,
<body>
<a id='1' href='a'><img src='no_image' width=30 height=30></a>
<div>
<img src='no_image' width=50 height=300>
<a id='2' href='a'><img src='no_image' width=30 height=30></a>
</div>
</body>
"></iframe><br>
<div><a id="end" href="a"><img src="resources/green.png" width=30 height=30></a></div>
<div id="console"></div>
</body> </body>
</html> "></iframe><br>
<div><a id="end" href="a"><img src="resources/green.png" width=30 height=30></a></div>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
var resultMap = [
// ["Down", "frameA,frameAbody"], crbug.com/801162
["Down", "frameA,1"],
["Down", "frameA,1"],
["Down", "frameA,1"],
["Down", "frameA,1"],
["Down", "frameA,1"],
["Down", "frameA,1"],
["Down", "frameA,1"],
["Down", "frameA,2"],
["Down", "end"],
// ["Up", "frameA,frameAbody"], crbug.com/801162
["Up", "frameA,2"],
["Up", "frameA,2"],
["Up", "frameA,2"],
["Up", "frameA,2"],
["Up", "frameA,2"],
["Up", "frameA,2"],
["Up", "frameA,2"],
["Up", "frameA,1"],
["Up", "start"],
];
// Start at a known place.
document.getElementById("start").focus();
snav.assertFocusMoves(resultMap);
</script>
Start
b End
PASS successfullyParsed is true
TEST COMPLETE
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "end"
<script src="../../resources/js-test.js"></script> <a id="start" href="#">Start</a><br>
<script src="resources/spatial-navigation-utils.js"></script> <iframe id="frameA" src="data:text/html,
<script type="application/javascript"> <body id='frameAbody'>
<a id='a' href='%23' style='margin-left: 125px'>a</a>
var resultMap = [ </body>"
["Down", "1"], ></iframe><br>
["Down", "end"], <a id="b" href="#">b</a>
["DONE", "DONE"] <a id="c" href="#" style="margin-left: 125px;">c</a>
];
if (window.testRunner) { <p>When spatnav exits an iframe, it goes to the closest focusable. Here: c.</p>
testRunner.dumpAsText();
testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
testRunner.overridePreference("WebKitSpatialNavigationEnabled", 1);
testRunner.waitUntilDone();
}
function runTest() <script src="../../resources/testharness.js"></script>
{ <script src="../../resources/testharnessreport.js"></script>
// Start the test after going to a known place. <script src="resources/snav-testharness.js"></script>
<script>
var resultMap = [
// ["Down", "frameA,frameAbody"], crbug.com/801162
["Down", "frameA,a"],
["Down", "c"],
];
// Start at a known place.
document.getElementById("start").focus(); document.getElementById("start").focus();
snav.assertFocusMoves(resultMap);
initTest(resultMap, testCompleted);
}
function testCompleted()
{
if (window.testRunner)
testRunner.notifyDone();
}
window.onload = runTest;
</script> </script>
<a id="start" href="#">Start</a><br>
<iframe src="data:text/html,
<a id='1' href='%23' style='margin-left: 125px'>a</a>"
></iframe><br>
<a id="2" href="#">b</a>
<a id="end" href="#" style="margin-left: 125px;">End</a>
<div id="console"></div>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment