2 Copyright © 2001-2004 World Wide Web Consortium,
3 (Massachusetts Institute of Technology, European Research Consortium
4 for Informatics and Mathematics, Keio University). All
5 Rights Reserved. This work is distributed under the W3C® Software License [1] in the
6 hope that it will be useful, but WITHOUT ANY WARRANTY; without even
7 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
12 // expose test function names
13 function exposeTestFunctionNames()
15 return ['XPathNSResolver_lookupNamespaceURI_prefix'];
18 var docsLoaded = -1000000;
22 // This function is called by the testing framework before
23 // running the test suite.
25 // If there are no configuration exceptions, asynchronous
26 // document loading is started. Otherwise, the status
27 // is set to complete and the exception is immediately
28 // raised when entering the body of the test.
30 function setUpPage() {
31 setUpPageStatus = 'running';
34 // creates test document builder, may throw exception
36 builder = createConfiguredBuilder();
41 if (typeof(this.doc) != 'undefined') {
44 docsLoaded += preload(docRef, "doc", "staffNS");
46 if (docsLoaded == 1) {
47 setUpPageStatus = 'complete';
50 catchInitializationError(builder, ex);
51 setUpPageStatus = 'complete';
56 // This method is called on the completion of
57 // each asychronous load started in setUpTests.
59 // When every synchronous loaded document has completed,
60 // the page status is changed which allows the
61 // body of the test to be executed.
62 function loadComplete() {
63 if (++docsLoaded == 1) {
64 setUpPageStatus = 'complete';
70 Iterate over all Elements in the test document, creating
71 nsresolvers checking that if the Element has a prefix, then
72 lookupNamespaceURI returns the same value as Element.namespaceURI
75 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator
76 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator-createNSResolver
77 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathNSResolver
78 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathNSResolver-lookupNamespaceURI
80 function XPathNSResolver_lookupNamespaceURI_prefix() {
82 if(checkInitialization(builder, "XPathNSResolver_lookupNamespaceURI_prefix") != null) return;
88 var lookupNamespaceURI;
93 if (typeof(this.doc) != 'undefined') {
96 doc = load(docRef, "doc", "staffNS");
97 elements = doc.getElementsByTagNameNS("*","*");
98 evaluator = createXPathEvaluator(doc);
99 for(var indexN65631 = 0;indexN65631 < elements.length; indexN65631++) {
100 element = elements.item(indexN65631);
101 prefix = element.prefix;
108 resolver = evaluator.createNSResolver(element);
109 namespaceURI = element.namespaceURI;
111 lookupNamespaceURI = resolver.lookupNamespaceURI(prefix);
112 assertEquals("equal",lookupNamespaceURI,namespaceURI);
121 XPathNSResolver_lookupNamespaceURI_prefix();