aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/dom/nodeiterator_test.html
blob: cea874ea1061b395eae58501a174b0e2cbafa943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<!--
Copyright 2008 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>goog.dom.NodeIterator Tests</title>
<script src="../base.js"></script>
<script>
  goog.require('goog.dom.NodeIterator');
  goog.require('goog.testing.dom');
  goog.require('goog.testing.jsunit');
</script>
</head>
<body>

<!--
  The next line goes past 80 characters to avoid ambiguity with
  newlines as text nodes
-->
<div id="test"><a href="#" id="a1">T<b id="b1">e</b>xt</a><span id="span1"></span><p id="p1">Text</p></div>
<ul id="test2"><li id="li1">Not<li id="li2">Closed</ul>

<script>
  function testBasic() {
    goog.testing.dom.assertNodesMatch(
        new goog.dom.NodeIterator(goog.dom.getElement('test')),
        ['#test', '#a1', 'T', '#b1', 'e', 'xt', '#span1', '#p1', 'Text']);
  }

  function testUnclosed() {
    goog.testing.dom.assertNodesMatch(
        new goog.dom.NodeIterator(goog.dom.getElement('test2')),
        ['#test2', '#li1', 'Not', '#li2', 'Closed']);
  }

  function testReverse() {
    goog.testing.dom.assertNodesMatch(
        new goog.dom.NodeIterator(goog.dom.getElement('test'), true),
        ['Text', '#p1', '#span1', 'xt', 'e', '#b1', 'T', '#a1', '#test']);
  }

</script>
</body>
</html>