blob: 132d782f5e11555ffb40c325d5db1de9dc357338 [file] [log] [blame]
andersca42ff9372006-05-08 21:30:14 +00001
2/*
3Copyright © 2001-2004 World Wide Web Consortium,
4(Massachusetts Institute of Technology, European Research Consortium
5for Informatics and Mathematics, Keio University). All
6Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9
10[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11*/
12
13
14// expose test function names
15function exposeTestFunctionNames()
16{
17return ['Comment_Nodes'];
18}
19
20var docsLoaded = -1000000;
21var builder = null;
22
23//
24// This function is called by the testing framework before
25// running the test suite.
26//
27// If there are no configuration exceptions, asynchronous
28// document loading is started. Otherwise, the status
29// is set to complete and the exception is immediately
30// raised when entering the body of the test.
31//
32function setUpPage() {
33 setUpPageStatus = 'running';
34 try {
35 //
36 // creates test document builder, may throw exception
37 //
38 builder = createConfiguredBuilder();
39
40 docsLoaded = 0;
41
42 var docRef = null;
43 if (typeof(this.doc) != 'undefined') {
44 docRef = this.doc;
45 }
46 docsLoaded += preload(docRef, "doc", "staff");
47
48 if (docsLoaded == 1) {
ap@webkit.org32a25932009-02-23 13:27:32 +000049 setUpPageStatus = 'complete';
andersca42ff9372006-05-08 21:30:14 +000050 }
51 } catch(ex) {
52 catchInitializationError(builder, ex);
ap@webkit.org32a25932009-02-23 13:27:32 +000053 setUpPageStatus = 'complete';
andersca42ff9372006-05-08 21:30:14 +000054 }
55}
56
57
58
59//
60// This method is called on the completion of
61// each asychronous load started in setUpTests.
62//
63// When every synchronous loaded document has completed,
64// the page status is changed which allows the
65// body of the test to be executed.
66function loadComplete() {
67 if (++docsLoaded == 1) {
68 setUpPageStatus = 'complete';
69 }
70}
71
72
73/**
74*
75 S1.2.6 Comment Nodes -
76 Create ANY_TYPE XPathResult matching //comment(),
77 check that each matching Node is a Comment Node.
78
79* @author Bob Clary
80* @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#Mapping
81* @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator
82* @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator-createNSResolver
83* @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator-evaluate
84* @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathNSResolver
85* @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult
86* @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult-iterateNext
87*/
88function Comment_Nodes() {
89 var success;
90 if(checkInitialization(builder, "Comment_Nodes") != null) return;
91 var ANY_TYPE = 0;
92 var NUMBER_TYPE = 1;
93 var STRING_TYPE = 2;
94 var BOOLEAN_TYPE = 3;
95 var UNORDERED_NODE_ITERATOR_TYPE = 4;
96 var ORDERED_NODE_ITERATOR_TYPE = 5;
97 var UNORDERED_NODE_SNAPSHOT_TYPE = 6;
98 var ORDERED_NODE_SNAPSHOT_TYPE = 7;
99 var ANY_UNORDERED_NODE_TYPE = 8;
100 var FIRST_ORDERED_NODE_TYPE = 9;
101 var doc;
102 var resolver;
103 var evaluator;
104 var contextNode;
105 var inresult = null;
106
107 var outresult = null;
108
109 var expression = "//comment()";
110 var xpathType = ANY_TYPE;
111 var currNode;
112 var nodeType;
113
114 var docRef = null;
115 if (typeof(this.doc) != 'undefined') {
116 docRef = this.doc;
117 }
118 doc = load(docRef, "doc", "staff");
119 evaluator = createXPathEvaluator(doc);
120resolver = evaluator.createNSResolver(doc);
121 contextNode = doc;
122outresult = evaluator.evaluate(expression,contextNode,resolver,xpathType,inresult);
123 currNode = outresult.iterateNext();
124
125 while(
126
127 (currNode != null)
128
129 ) {
130 nodeType = currNode.nodeType;
131
132 assertEquals("S1.2.6-Comment-Nodes-nodeType",8,nodeType);
133 currNode = outresult.iterateNext();
134
135 }
136
137}
138
139
140
141
142function runTest() {
143 Comment_Nodes();
144}