| <html> |
| <!-- |
| This test ensures the optimization done in searching logic to find best candidate focusable node with minimum iterations. |
| |
| * Pre-conditions: |
| 1) TestRunner support for SNav enable/disable. |
| |
| * Navigation steps: |
| 1) Loads this page, focus goes to "2". |
| 2) lastSpatialNavigationCandidateCount() returns the number of nodes actually considered to determine best candidate focusable node, |
| along the most recent navigation direction. |
| --> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| <script src="resources/spatial-navigation-utils.js"></script> |
| <script type="application/javascript"> |
| |
| var resultMap = [ |
| ["DONE", "DONE"] |
| ]; |
| |
| if (window.testRunner) { |
| testRunner.dumpAsText(); |
| testRunner.setSpatialNavigationEnabled(true); |
| testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1); |
| testRunner.waitUntilDone(); |
| } |
| |
| function runTest() |
| { |
| initTest(resultMap, additionalTest); |
| } |
| |
| function additionalTest() |
| { |
| document.getElementById("2").focus(); |
| eventSender.keyDown("downArrow"); |
| shouldBe("internals.lastSpatialNavigationCandidateCount()", "9"); |
| eventSender.keyDown("downArrow"); |
| shouldBe("internals.lastSpatialNavigationCandidateCount()", "6"); |
| eventSender.keyDown("downArrow"); |
| shouldBe("internals.lastSpatialNavigationCandidateCount()", "2"); |
| eventSender.keyDown("rightArrow"); |
| eventSender.keyDown("upArrow"); |
| eventSender.keyDown("leftArrow"); |
| shouldBe("internals.lastSpatialNavigationCandidateCount()", "9"); |
| eventSender.keyDown("leftArrow"); |
| shouldBe("internals.lastSpatialNavigationCandidateCount()", "6"); |
| eventSender.keyDown("leftArrow"); |
| shouldBe("internals.lastSpatialNavigationCandidateCount()", "2"); |
| eventSender.keyDown("upArrow"); |
| shouldBe("internals.lastSpatialNavigationCandidateCount()", "5"); |
| eventSender.keyDown("upArrow"); |
| shouldBe("internals.lastSpatialNavigationCandidateCount()", "2"); |
| testCompleted(); |
| } |
| |
| function testCompleted() |
| { |
| if (window.testRunner) |
| testRunner.notifyDone(); |
| } |
| |
| window.onload = runTest; |
| |
| </script> |
| <script src="../resources/js-test-post.js"></script> |
| </head> |
| <body id="some-content" xmlns="http://www.w3.org/1999/xhtml"> |
| <table style="text-align: left; 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="text-align: center;"><a id="4" href="a">4</a></td> |
| <td><br><iframe width='100' height='100' src="data:text/html, |
| <table style='text-align: center; margin-left: auto; margin-right: auto;'> |
| <tbody> |
| <tr> |
| <td style='text-align: center;'><a id='5' href='a'>5</a></td> |
| </tr> |
| </tbody> |
| </table>"> |
| </iframe> |
| </td> |
| <td style="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> |
| |