1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Include test fixture.
6 GEN_INCLUDE(['../testing/chromevox_unittest_base.js']);
11 * @extends {ChromeVoxUnitTestBase}
13 function CvoxFindUtilUnitTest() {}
15 CvoxFindUtilUnitTest.prototype = {
16 __proto__: ChromeVoxUnitTestBase.prototype,
24 TEST_F('CvoxFindUtilUnitTest', 'Links', function() {
25 this.loadDoc(function() {/*!
27 <p id="before">Before</p>
30 <a href="#c3" id="c3" name="chapter_3"></a>
31 <h2 id="c3_2">Chapter 3</h2>
32 <h2 id="c4">Chapter 4</h2>
35 <a href='#c7' id="c7" name="chapter_7"><h2 id="c7_2">Chapter 7</h2></a>
36 <h2 id="c8">Chapter 8</h2>
37 <p id="after">After</p>
41 var sel = cvox.CursorSelection.fromNode($('before'));
43 var ret = cvox.FindUtil.findNext(sel, cvox.DomPredicates.linkPredicate);
44 assertEquals('c3', ret.start.node.id);
45 ret = cvox.FindUtil.findNext(ret, cvox.DomPredicates.linkPredicate);
46 assertEquals('c7', ret.start.node.id);
48 ret.setReversed(true);
49 ret = cvox.FindUtil.findNext(ret, cvox.DomPredicates.linkPredicate);
50 assertEquals('c3', ret.start.node.id);