File: html5test.html

package info (click to toggle)
node-nwmatcher 1.3.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 1,676 kB
  • ctags: 777
  • sloc: sh: 98; makefile: 27
file content (84 lines) | stat: -rw-r--r-- 2,246 bytes parent folder | download
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>NWMatcher HTML5 elements selection test</title>
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script type="text/javascript" src="../../src/nwmatcher.js"></script>
<!--
<script type="text/javascript" src="../../src/nwmatcher-base.js"></script>
<script type="text/javascript" src="../../src/modules/nwmatcher-pseudos.js"></script>
-->
<style type="text/css">
abbr { Helvetica, sans-serif; font-weight: bold; }
mark { background-color: yellow; }
span { background-color: lime; }
.pass { background-color: lime; }
.fail { background-color: red; }
</style>
</head>

<body>

<h1>NWMatcher HTML5 elements selection test</h1>

<p>Usual nonsense content...</p>

<p>
<abbr id="IBA" title="International Barbershop Association">IBA</abbr>
Located at <mark id="NUM">116</mark> Messina Avenue, London NW6 4LD
<abbr id="UK" title="United Kingdom">UK</abbr>
</p>

<section>
  <ul>
	<li id="first">First</li>
	<li id="second">Second</li>
	<li id="last">Last</li>
  </ul>
</section>

<hr>

<script type="text/javascript">

window.onload = function() {

  function log(msg) {
    document.body.appendChild(document.createElement('div')).innerHTML = msg;
  }

  var i, temp, test, selectors = {
    'abbr:first-of-type': 'IBA',
    'abbr:last-of-type': 'UK',
    'mark:only-of-type': 'NUM',
    'abbr:nth-of-type(1)': 'IBA',
    'abbr:nth-of-type(2)': 'UK',
    'abbr:nth-last-of-type(1)': 'UK',
    'abbr:nth-last-of-type(2)': 'IBA',
    'section li:first-of-type': 'first',
    'section li:last-of-type': 'last'
  };

  log('--- TEST USING NW.Dom.select ---');

  for (i in selectors) {
    temp = NW.Dom.select(i)[0];
    test = temp && temp.id == selectors[i];
    log((test ? temp.innerHTML : 'FAIL') + ' <span class="' + (test ? 'pass' : 'fail') + '">' + i + '</span>');
  }

  log('--- TEST USING document.querySelectorAll ---');

  for (i in selectors) {
    temp = document.querySelectorAll(i)[0];
    test = temp && temp.id == selectors[i];
    log((test ? temp.innerHTML : 'FAIL') + ' <span class="' + (test ? 'pass' : 'fail') + '">' + i + '</span>');
  }

};

</script>

</body>
</html>