Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / dom / svg / level3 / xpath / Attribute_Nodes.js
blobc576983f5c41afd2b0de356327f5f915b8218445
1 /*
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 ['Attribute_Nodes'];
18 var docsLoaded = -1000000;
19 var builder = null;
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';
32    try {
33      //
34      //   creates test document builder, may throw exception
35      //
36      builder = createConfiguredBuilder();
38       docsLoaded = 0;
40       var docRef = null;
41       if (typeof(this.doc) != 'undefined') {
42         docRef = this.doc;
43       }
44       docsLoaded += preload(docRef, "doc", "staff");
46        if (docsLoaded == 1) {
47           setUpPageStatus = 'complete';
48        }
49     } catch(ex) {
50         catchInitializationError(builder, ex);
51         setUpPageStatus = 'complete';
52     }
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';
65     }
68 /**
70       S1.2.2 Attribute Nodes -
71       Create ANY_TYPE XPathResult matching  //@*,
72       check that each matching Node is an Attribute Node,
73       that parentNodes of returned Attributes are null,
74       and that ownerElements are in fact Elements.
76 * @author Bob Clary
77 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#Mapping
78 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator
79 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator-createNSResolver
80 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator-evaluate
81 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathNSResolver
82 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult
83 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult-iterateNext
85 function Attribute_Nodes() {
86    var success;
87     if(checkInitialization(builder, "Attribute_Nodes") != null) return;
88     var ANY_TYPE = 0;
89       var NUMBER_TYPE = 1;
90       var STRING_TYPE = 2;
91       var BOOLEAN_TYPE = 3;
92       var UNORDERED_NODE_ITERATOR_TYPE = 4;
93       var ORDERED_NODE_ITERATOR_TYPE = 5;
94       var UNORDERED_NODE_SNAPSHOT_TYPE = 6;
95       var ORDERED_NODE_SNAPSHOT_TYPE = 7;
96       var ANY_UNORDERED_NODE_TYPE = 8;
97       var FIRST_ORDERED_NODE_TYPE = 9;
98       var doc;
99       var resolver;
100       var evaluator;
101       var contextNode;
102       var inresult = null;
104       var outresult = null;
106       var expression = "//@*";
107       var xpathType = ANY_TYPE;
108       var outNode;
109       var nodeType;
110       var parent;
111       var owner;
112       var ownerType;
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);
120 resolver = evaluator.createNSResolver(doc);
121       contextNode =  doc;
122 outresult = evaluator.evaluate(expression,contextNode,resolver,xpathType,inresult);
123       outNode = outresult.iterateNext();
125     while(
127     (outNode != null)
129     ) {
130     nodeType = outNode.nodeType;
132       assertEquals("S1.2.2-Attribute-Nodes-nodeType",2,nodeType);
133        parent = outNode.parentNode;
135       assertNull("S1.2.2-Attribute-Nodes-parentNode",parent);
136     owner = outNode.ownerElement;
138       ownerType = owner.nodeType;
140       assertEquals("S1.2.2-Attribute-Nodes-owner-nodeType",1,ownerType);
141        outNode = outresult.iterateNext();
143     }
147 function runTest() {
148    Attribute_Nodes();