Commit 306a5bfd authored by Hugo Holgersson's avatar Hugo Holgersson Committed by Commit Bot

Snav: Convert snav-z-index.html to testharness.js

See Issue 803086 for motivation and context of
this effort.

Bug: 803086, 1000578
Change-Id: Ib36de3f671204ce0d9b4d05e68966e735ba5544e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1949784Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Commit-Queue: Hugo Holgersson <hholgersson@fb.com>
Cr-Commit-Position: refs/heads/master@{#721413}
parent 21cc9c54
PASS successfullyParsed is true
TEST COMPLETE
PASS gFocusedDocument.activeElement.getAttribute("id") is "s22"
PASS gFocusedDocument.activeElement.getAttribute("id") is "p11"
PASS gFocusedDocument.activeElement.getAttribute("id") is "s23"
PASS gFocusedDocument.activeElement.getAttribute("id") is "p12"
PASS gFocusedDocument.activeElement.getAttribute("id") is "s24"
PASS gFocusedDocument.activeElement.getAttribute("id") is "s25"
PASS gFocusedDocument.activeElement.getAttribute("id") is "s24"
PASS gFocusedDocument.activeElement.getAttribute("id") is "p12"
PASS gFocusedDocument.activeElement.getAttribute("id") is "p22"
PASS gFocusedDocument.activeElement.getAttribute("id") is "p12"
PASS gFocusedDocument.activeElement.getAttribute("id") is "s24"
PASS gFocusedDocument.activeElement.getAttribute("id") is "s14"
PASS gFocusedDocument.activeElement.getAttribute("id") is "s13"
PASS gFocusedDocument.activeElement.getAttribute("id") is "s12"
PASS gFocusedDocument.activeElement.getAttribute("id") is "s22"
PASS gFocusedDocument.activeElement.getAttribute("id") is "p11"
PASS gFocusedDocument.activeElement.getAttribute("id") is "p21"
PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
This test is testing that we can prefer the elements with higher Z indexes.
<html> <style>
<head> div.simple { border: 3px solid red;}
<script src="../../resources/js-test.js"></script> div.simple:focus { border: 3px solid gray;}
<script src="resources/spatial-navigation-utils.js"></script> div.positioned { border: 3px solid blue;}
<script type="application/javascript"> div.positioned:focus{ border: 3px solid gray;}
#popup {position: absolute; top:120; left:240; border: 8px solid black; z-index:1000}
</style>
var resultMap = [ Test that SpatNav prefers the elements with higher Z-indices.
["Down", "s22"],
["Down", "p11"],
["Down", "s23"],
["Down", "p12"],
["Down", "s24"],
["Down", "s25"],
["Up", "s24"],
["Up", "p12"],
["Right", "p22"],
["Left", "p12"],
["Left", "s24"],
["Left", "s14"],
["Up", "s13"],
["Up", "s12"],
["Right", "s22"],
["Right", "p11"],
["Right", "p21"],
["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();
requestAnimationFrame(() => initTest(resultMap, testCompleted));
}
function testCompleted()
{
if (window.testRunner)
testRunner.notifyDone();
}
window.onload = runTest;
</script>
<style>
div.simple { border: 3px solid red;}
div.simple:focus { border: 3px solid gray;}
div.positioned { border: 3px solid blue;}
div.positioned:focus{ border: 3px solid gray;}
#popup {position: absolute; top:120; left:240; border: 8px solid black; z-index:1000}
</style>
</head>
<body id="some-content" xmlns="http://www.w3.org/1999/xhtml" style="padding:20px">
<div id="popup"> <div id="popup">
<table><tr><td> <table><tr><td>
<div tabindex="1" id="p11" class="positioned"><img src="resources/green.png" width=160px height=60px></div> <div tabindex="1" id="p11" class="positioned"><img src="resources/green.png" width=160px height=60px></div>
...@@ -81,7 +32,31 @@ ...@@ -81,7 +32,31 @@
<div tabindex="4" id="s24" class="simple"><img src="resources/green.png" width=160px height=60px></div> <div tabindex="4" id="s24" class="simple"><img src="resources/green.png" width=160px height=60px></div>
<div tabindex="5" id="s25" class="simple"><img src="resources/green.png" width=160px height=60px></div> <div tabindex="5" id="s25" class="simple"><img src="resources/green.png" width=160px height=60px></div>
</td></tr></table> </td></tr></table>
<div id="console"></div> <script src="../../resources/testharness.js"></script>
This test is testing that we can prefer the elements with higher Z indexes. <script src="../../resources/testharnessreport.js"></script>
</body> <script src="resources/snav-testharness.js"></script>
</html> <script>
var resultMap = [
["Down", "s22"],
["Down", "p11"],
["Down", "s23"],
["Down", "p12"],
["Down", "s24"],
["Down", "s25"],
["Up", "s24"],
["Up", "p12"],
["Right", "p22"],
["Left", "p12"],
["Left", "s24"],
["Left", "s14"],
["Up", "s13"],
["Up", "s12"],
["Right", "s22"],
["Right", "p11"],
["Right", "p21"],
["Up", "start"],
];
// Start at a known place.
document.getElementById("start").focus();
snav.assertFocusMoves(resultMap);
</script>
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