Commit fc8f959d authored by JunHo Seo's avatar JunHo Seo Committed by Commit Bot

Snav: Convert some legacy js-tests to testharness

Convert list:
snav-1st-stop
snav-aligned-not-aligned
snav-clipped-overflowed-content
snav-container-only-white-space
snav-container-white-space
snav-date

Bug: 803086
Change-Id: Id5723780293df17fd0c0020914630d2f1ea7d198
Reviewed-on: https://chromium-review.googlesource.com/1177527Reviewed-by: default avatarHugo Holgersson <hugoh@vewd.com>
Commit-Queue: JunHo Seo <junho0924.seo@lge.com>
Cr-Commit-Position: refs/heads/master@{#584651}
parent 1307fc94
1 2 3
4 5 6
7 8 9
PASS successfullyParsed is true
TEST COMPLETE
PASS gFocusedDocument.activeElement.getAttribute("id") is "1"
<html>
<!--
This test ensures the correctness of Spatial Navigation (SNav) algorithm from a non-focus scenario.
* Pre-conditions:
1) DRT support for SNav enable/disable.
* Navigation steps:
1) Loads this page and send key down.
2) The 1st link should be focused.
-->
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/spatial-navigation-utils.js"></script>
<script type="application/javascript">
var resultMap = [
["Down", "1"],
["DONE", "DONE"]
];
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
testRunner.overridePreference("WebKitSpatialNavigationEnabled", 1);
testRunner.waitUntilDone();
}
function runTest()
{
// starting the test from no focused node.
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">
<table style="text-align: left; width: 100%; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="1">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="1" href="a">1</a></td>
<td style="vertical-align: top; text-align: center;"><a id="2" href="a">2</a></td>
<td style="vertical-align: top; text-align: center;"><a id="3" href="a">3</a></td>
</tr>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="4" href="a">4</a></td>
<td style="vertical-align: top; text-align: center;"><a id="5" href="a">5</td>
<td style="vertical-align: top; text-align: center;"><a id="6" href="a">6</a></td>
</tr>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="7" href="a">7</a></td>
<td style="vertical-align: top; text-align: center;"><a id="8" href="a">8</a></td>
<td style="vertical-align: top; text-align: center;"><a id="9" href="a">9</a></td>
</tr>
</tbody>
</table>
<div id="console"></div>
</body>
</html>
<table style="text-align: left; width: 100%; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="1">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="1" href="a">1</a></td>
<td style="vertical-align: top; text-align: center;"><a id="2" href="a">2</a></td>
<td style="vertical-align: top; text-align: center;"><a id="3" href="a">3</a></td>
</tr>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="4" href="a">4</a></td>
<td style="vertical-align: top; text-align: center;"><a id="5" href="a">5</td>
<td style="vertical-align: top; text-align: center;"><a id="6" href="a">6</a></td>
</tr>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="7" href="a">7</a></td>
<td style="vertical-align: top; text-align: center;"><a id="8" href="a">8</a></td>
<td style="vertical-align: top; text-align: center;"><a id="9" href="a">9</a></td>
</tr>
</tbody>
</table>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
var resultMap = [
["Down", "1"],
];
snav.assertFocusMoves(resultMap);
</script>
This test ensures that Spatial Navigation works with symmetrically positoned rects
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
E1E2E3E4E5
PASS gFocusedDocument.activeElement.getAttribute("id") is "e4"
PASS gFocusedDocument.activeElement.getAttribute("id") is "e5"
PASS gFocusedDocument.activeElement.getAttribute("id") is "e4"
PASS gFocusedDocument.activeElement.getAttribute("id") is "e1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "e2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "e3"
PASS gFocusedDocument.activeElement.getAttribute("id") is "e4"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/spatial-navigation-utils.js"></script>
</head>
<style>
body a {
position: absolute;
height: 50px;
width: 100px;
border: 1px solid black;
a {
position: absolute;
height: 50px;
width: 100px;
border: 1px solid black;
}
#e1 {
left: 50px;
top: 250px;
left: 50px;
top: 250px;
}
#e2 {
left: 200px;
top: 300px;
height: 100px;
left: 200px;
top: 300px;
height: 100px;
}
#e3 {
left: 350px;
top: 300px;
left: 350px;
top: 300px;
}
#e4 {
left: 500px;
top: 200px;
height: 100px;
left: 500px;
top: 200px;
height: 100px;
}
#e5 {
left: 650px;
top: 250px;
left: 650px;
top: 250px;
}
</style>
<body id="some-content" onload="runTest()">
<p id="description"></p>
<div id="elements">
<a id="e1" href="#e1">E1</a>
<a id="e2" href="#e2">E2</a>
<a id="e3" href="#e3">E3</a>
<a id="e4" href="#e4">E4</a>
<a id="e5" href="#e5">E5</a>
</div>
<div id="console"></div>
<script type="application/javascript">
description('This test ensures that Spatial Navigation works with symmetrically positoned rects');
jsTestIsAsync = true;
var resultMap = [
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
var resultMap = [
["Right", "e4"],
["Right", "e5"],
["Left", "e4"],
......@@ -56,21 +47,9 @@ var resultMap = [
["Down", "e2"],
["Right", "e3"],
["Right", "e4"],
["DONE", "DONE"]
];
if (window.testRunner) {
testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
testRunner.overridePreference("WebKitSpatialNavigationEnabled", 1);
}
function runTest()
{
// starting the test itself: get to a known place.
document.getElementById("e1").focus();
];
initTest(resultMap, finishJSTest);
}
// Start at a known place.
document.getElementById("e1").focus();
snav.assertFocusMoves(resultMap);
</script>
</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 "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "3"
PASS gFocusedDocument.activeElement.getAttribute("id") is "3"
PASS gFocusedDocument.activeElement.getAttribute("id") is "3"
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 "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 "1"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
This test tests that a div with css overflow:auto will scroll to reveal its focusable elements
<html>
<!--
This test ensures the correctness of a basic aspect of spatial navigation traversal
routines: focusable elements in scrollable containers (e.g. <div>) should be
accessible, including offscreen content.
* Pre-conditions:
1) DRT support for spatial navivation enable/disable.
* Navigation steps:
1) Loads this page, focus goes to "start" automatically.
2) Move focus down to the visible focusable element in
scrollable div.
3) Traverse the page through other focusable elements down the page.
and then back up.
* Expected results: All focusable element in scrollable content, including
offscreen ones, should be accessible via spatial navigation. -->
<head>
<style type="text/css">
div.scroll {
height: 200px;
width: 300px;
overflow: auto;
border: 1px solid #666;
background-color: #ccc;
padding: 8px;
}
</style>
<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", "2"],
["Down", "2"],
["Down", "3"],
["Right", "3"],
["Right", "3"],
["Right", "3"],
["Right", "4"],
["Down", "5"],
["Up", "2"],
["Up", "2"],
["Up", "2"],
["Up", "2"],
["Up", "1"],
["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">
<a id="start" href="a"><img src="resources/green.png" width=30px height=30px></a>
<div class="scroll">
<a id="1" href="a"><img src="resources/green.png" width=30px height=35px></a>
<div></div>
<img src="resources/green.png" width=200px height=280px>
<div></div>
<a id="2" href="a"><img src="resources/green.png" width=30px height=30px></a>
</div>
<div class="scroll">
<a id="3" href="a"><img src="resources/green.png" width=30px height=35px></a>
<a id="4" href="a" style="margin-left: 400px"><img src="resources/green.png" width=30px height=35px></a>
</div>
<a id="5" href="a"><img src="resources/green.png" width=30px height=30px></a>
<div id="console"></div>
<div>This test tests that a div with css overflow:auto will scroll to reveal its focusable elements</div>
</body>
</html>
<style>
div.scroll {
height: 200px;
width: 300px;
overflow: auto;
border: 1px solid #666;
background-color: #ccc;
padding: 8px;
}
</style>
<a id="start" href="a"><img src="resources/green.png" width=30px height=30px></a>
<div class="scroll">
<a id="1" href="a"><img src="resources/green.png" width=30px height=35px></a>
<div></div>
<img src="resources/green.png" width=200px height=280px>
<div></div>
<a id="2" href="a"><img src="resources/green.png" width=30px height=30px></a>
</div>
<div class="scroll">
<a id="3" href="a"><img src="resources/green.png" width=30px height=35px></a>
<a id="4" href="a" style="margin-left: 400px"><img src="resources/green.png" width=30px height=35px></a>
</div>
<a id="5" href="a"><img src="resources/green.png" width=30px height=30px></a>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
var resultMap = [
["Down", "1"],
["Down", "1"],
["Down", "1"],
["Down", "1"],
["Down", "2"],
["Down", "2"],
["Down", "3"],
["Right", "3"],
["Right", "3"],
["Right", "3"],
["Right", "4"],
["Down", "5"],
["Up", "2"],
["Up", "2"],
["Up", "2"],
["Up", "2"],
["Up", "1"],
["Up", "1"],
["Up", "start"],
];
// Start at a known place.
document.getElementById("start").focus();
snav.assertFocusMoves(resultMap);
</script>
This is an element
This is an element
PASS successfullyParsed is true
TEST COMPLETE
PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
This test tests that a anchor element with only white spaces gives the correct size in ContainerNode::getRect().
<html>
<!--
This test ensures the correctness of a basic aspect of spatial navigation traversal
routines: focusable elements in scrollable containers (e.g. <div>) should be
accessible, including offscreen content.
* Pre-conditions:
1) DRT support for spatial navivation enable/disable.
* Navigation steps:
1) Loads this page, focus goes to "start" automatically.
2) Move focus down to the visible focusable element in
scrollable div.
3) Traverse the page through other focusable elements down the page.
and then back up.
* Expected results: All focusable element in scrollable content, including
offscreen ones, should be accessible via spatial navigation. -->
<head>
<style>
:focus {outline: 1px solid black;}
</style>
<script src="../../resources/js-test.js"></script>
<script src="resources/spatial-navigation-utils.js"></script>
<script type="application/javascript">
var resultMap = [
["Down", "2"],
["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>
<a href="#" id="start">This is an element</a><br>
<div>
<a href="#" id="1">
</a>
</div>
<div>
<a href="#" id="2">This is an element</a><br>
</div>
<div id="console"></div>
<div>This test tests that a anchor element with only white spaces gives the correct size in ContainerNode::getRect().</div>
</body>
</html>
<style>
:focus {outline: 1px solid black;}
</style>
<a href="#" id="start">This is an element</a><br>
<div>
<a href="#" id="1"></a>
</div>
<div>
<a href="#" id="2">This is an element</a><br>
</div>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
var resultMap = [
["Down", "2"],
["Up", "start"],
];
// Start at a known place.
document.getElementById("start").focus();
snav.assertFocusMoves(resultMap);
</script>
This is an element
This is an element
This is an element
This is an element
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 "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"
This test tests that a anchor element with in image in it and a space after the image, can still give the correct size in ContainerNode::getRect().
<html>
<!--
This test ensures the correctness of a basic aspect of spatial navigation traversal
routines: focusable elements in scrollable containers (e.g. <div>) should be
accessible, including offscreen content.
* Pre-conditions:
1) DRT support for spatial navivation enable/disable.
* Navigation steps:
1) Loads this page, focus goes to "start" automatically.
2) Move focus down to the visible focusable element in
scrollable div.
3) Traverse the page through other focusable elements down the page.
and then back up.
* Expected results: All focusable element in scrollable content, including
offscreen ones, should be accessible via spatial navigation. -->
<head>
<style>
:focus {outline: 1px solid black;}
</style>
<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", "4"],
["Down", "5"],
["Up", "4"],
["Up", "3"],
["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>
<a href="#" id="start">This is an element</a><br>
<div>
<a href="#" id="1">
<img src="resources/green.png" height="42" width="76" border="0"/>
</a>
</div>
<div>
<a href="#" id="2">This is an element</a><br>
</div>
<a href="#" id="3">This is an element</a><br>
<a href="#" id="4">
<img src="resources/green.png" height="42" width="76" alt="llinker1" border="0"/>
</a><br>
<a href="#" id="5">This is an element</a><br>
<div id="console"></div>
<div>This test tests that a anchor element with in image in it and a space after the image, can still give the correct size in ContainerNode::getRect().</div>
</body>
</html>
<style>
:focus {outline: 1px solid black;}
</style>
<a href="#" id="start">This is an element</a><br>
<div>
<a href="#" id="1">
<img src="resources/green.png" height="42" width="76" border="0"/>
</a>
</div>
<div>
<a href="#" id="2">This is an element</a><br>
</div>
<a href="#" id="3">This is an element</a><br>
<a href="#" id="4">
<img src="resources/green.png" height="42" width="76" alt="llinker1" border="0"/>
</a><br>
<a href="#" id="5">This is an element</a><br>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
var resultMap = [
["Down", "1"],
["Down", "2"],
["Down", "3"],
["Down", "4"],
["Down", "5"],
["Up", "4"],
["Up", "3"],
["Up", "2"],
["Up", "1"],
["Up", "start"],
];
// Start at a known place.
document.getElementById("start").focus();
snav.assertFocusMoves(resultMap);
</script>
CONSOLE WARNING: line 20: The specified value "text" does not conform to the required format, "yyyy-MM-dd".
This test ensures the correctness of Spatial Navigation (SNav) algorithm over date input element (having shadow DOM).
* Navigation steps:
1) Loads this page, focus goes to "start" automatically.
2) Focus moves away from input box, left and right to neighbor nodes and back.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Left Right
PASS gFocusedDocument.activeElement.getAttribute("id") is "left"
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 "right"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/spatial-navigation-utils.js"></script>
<script>
window.jsTestIsAsync = true;
if (window.testRunner) {
testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
testRunner.overridePreference("WebKitSpatialNavigationEnabled", 1);
}
</script>
</head>
<body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
<p id="description"></p>
<table style="text-align: left; width: 100%; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="1">
<tbody>
<tr>
......@@ -22,33 +7,21 @@ if (window.testRunner) {
</tr>
</tbody>
</table>
<div id="console"></div>
<script type="application/javascript">
description('This test ensures the correctness of Spatial Navigation (SNav) algorithm over date input element (having shadow DOM).<br>\
* Navigation steps:<br>\
1) Loads this page, focus goes to "start" automatically.<br>\
2) Focus moves away from input box, left and right to neighbor nodes and back.<br>');
var resultMap = [
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
var resultMap = [
["Left", "left"],
["Right", "start"], // month
["Right", "start"], // day
["Right", "start"], // year
["Right", "right"],
["Left", "start"],
["DONE", "DONE"]
];
];
function runTest()
{
// starting the test itself: get to a known place.
document.getElementById("start").focus();
initTest(resultMap, finishJSTest);
}
window.onload = runTest;
// Start at a known place.
document.getElementById("start").focus();
snav.assertFocusMoves(resultMap);
</script>
</body>
</html>
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