| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 Copyright © 2001-2004 World Wide Web Consortium, | 2 Copyright © 2001-2004 World Wide Web Consortium, |
| 4 (Massachusetts Institute of Technology, European Research Consortium | 3 (Massachusetts Institute of Technology, European Research Consortium |
| 5 for Informatics and Mathematics, Keio University). All | 4 for Informatics and Mathematics, Keio University). All |
| 6 Rights Reserved. This work is distributed under the W3C® Software License [1] i
n the | 5 Rights Reserved. This work is distributed under the W3C® Software License [1] i
n the |
| 7 hope that it will be useful, but WITHOUT ANY WARRANTY; without even | 6 hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
| 8 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 7 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 9 | 8 |
| 10 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 | 9 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 |
| 11 */ | 10 */ |
| 12 | 11 |
| 13 | |
| 14 // expose test function names | 12 // expose test function names |
| 15 function exposeTestFunctionNames() | 13 function exposeTestFunctionNames() |
| 16 { | 14 { |
| 17 return ['XPathExpression_evaluate_WRONG_DOCUMENT_ERR']; | 15 return ['XPathExpression_evaluate_WRONG_DOCUMENT_ERR']; |
| 18 } | 16 } |
| 19 | 17 |
| 20 var docsLoaded = -1000000; | 18 var docsLoaded = -1000000; |
| 21 var builder = null; | 19 var builder = null; |
| 22 | 20 |
| 23 // | 21 // |
| 24 // This function is called by the testing framework before | 22 // This function is called by the testing framework before |
| 25 // running the test suite. | 23 // running the test suite. |
| 26 // | 24 // |
| 27 // If there are no configuration exceptions, asynchronous | 25 // If there are no configuration exceptions, asynchronous |
| 28 // document loading is started. Otherwise, the status | 26 // document loading is started. Otherwise, the status |
| 29 // is set to complete and the exception is immediately | 27 // is set to complete and the exception is immediately |
| 30 // raised when entering the body of the test. | 28 // raised when entering the body of the test. |
| 31 // | 29 // |
| 32 function setUpPage() { | 30 function setUpPage() { |
| 33 setUpPageStatus = 'running'; | 31 setUpPageStatus = 'running'; |
| 34 try { | 32 try { |
| 35 // | 33 // |
| 36 // creates test document builder, may throw exception | 34 // creates test document builder, may throw exception |
| 37 // | 35 // |
| 38 builder = createConfiguredBuilder(); | 36 builder = createConfiguredBuilder(); |
| 39 | 37 |
| 40 docsLoaded = 0; | 38 docsLoaded = 0; |
| 41 | 39 |
| 42 var doc1Ref = null; | 40 var doc1Ref = null; |
| 43 if (typeof(this.doc1) != 'undefined') { | 41 if (typeof(this.doc1) != 'undefined') { |
| 44 doc1Ref = this.doc1; | 42 doc1Ref = this.doc1; |
| 45 } | 43 } |
| 46 docsLoaded += preload(doc1Ref, "doc1", "staffNS"); | 44 docsLoaded += preload(doc1Ref, "doc1", "staffNS"); |
| 47 | 45 |
| 48 var doc2Ref = null; | 46 var doc2Ref = null; |
| 49 if (typeof(this.doc2) != 'undefined') { | 47 if (typeof(this.doc2) != 'undefined') { |
| 50 doc2Ref = this.doc2; | 48 doc2Ref = this.doc2; |
| 51 } | 49 } |
| 52 docsLoaded += preload(doc2Ref, "doc2", "staff"); | 50 docsLoaded += preload(doc2Ref, "doc2", "staff"); |
| 53 | 51 |
| 54 if (docsLoaded == 2) { | 52 if (docsLoaded == 2) { |
| 55 setUpPageStatus = 'complete'; | 53 setUpPageStatus = 'complete'; |
| 56 } | 54 } |
| 57 } catch(ex) { | 55 } catch(ex) { |
| 58 » catchInitializationError(builder, ex); | 56 catchInitializationError(builder, ex); |
| 59 setUpPageStatus = 'complete'; | 57 setUpPageStatus = 'complete'; |
| 60 } | 58 } |
| 61 } | 59 } |
| 62 | 60 |
| 63 | |
| 64 | |
| 65 // | 61 // |
| 66 // This method is called on the completion of | 62 // This method is called on the completion of |
| 67 // each asychronous load started in setUpTests. | 63 // each asychronous load started in setUpTests. |
| 68 // | 64 // |
| 69 // When every synchronous loaded document has completed, | 65 // When every synchronous loaded document has completed, |
| 70 // the page status is changed which allows the | 66 // the page status is changed which allows the |
| 71 // body of the test to be executed. | 67 // body of the test to be executed. |
| 72 function loadComplete() { | 68 function loadComplete() { |
| 73 if (++docsLoaded == 2) { | 69 if (++docsLoaded == 2) { |
| 74 setUpPageStatus = 'complete'; | 70 setUpPageStatus = 'complete'; |
| 75 } | 71 } |
| 76 } | 72 } |
| 77 | 73 |
| 74 /** |
| 75 * |
| 76 Test if XPathExpression.evaluate properly throws WRONG_DOCUMENT_ERROR |
| 78 | 77 |
| 79 /** | |
| 80 * | |
| 81 Test if XPathExpression.evaluate properly throws WRONG_DOCUMENT_ERROR | |
| 82 | |
| 83 * @author Philippe Le Hégaret | 78 * @author Philippe Le Hégaret |
| 84 * @author Bob Clary | 79 * @author Bob Clary |
| 85 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathExpres
sion-evaluate | 80 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathExpres
sion-evaluate |
| 86 */ | 81 */ |
| 87 function XPathExpression_evaluate_WRONG_DOCUMENT_ERR() { | 82 function XPathExpression_evaluate_WRONG_DOCUMENT_ERR() { |
| 88 var success; | 83 var success; |
| 89 if(checkInitialization(builder, "XPathExpression_evaluate_WRONG_DOCUMENT_ERR
") != null) return; | 84 if(checkInitialization(builder, "XPathExpression_evaluate_WRONG_DOCUMENT_ERR
") != null) return; |
| 90 var doc1; | 85 var doc1; |
| 91 var doc2; | 86 var doc2; |
| 92 var xpEvaluator; | 87 var xpEvaluator; |
| 93 var root; | 88 var root; |
| 94 var result; | 89 var result; |
| 95 var nullNSResolver = null; | 90 var nullNSResolver = null; |
| 96 | 91 |
| 97 var nullResult = null; | 92 var nullResult = null; |
| 98 | 93 |
| 99 var xpathExpression; | 94 var xpathExpression; |
| 100 | 95 |
| 101 var doc1Ref = null; | 96 var doc1Ref = null; |
| 102 if (typeof(this.doc1) != 'undefined') { | 97 if (typeof(this.doc1) != 'undefined') { |
| 103 doc1Ref = this.doc1; | 98 doc1Ref = this.doc1; |
| 104 } | 99 } |
| 105 doc1 = load(doc1Ref, "doc1", "staffNS"); | 100 doc1 = load(doc1Ref, "doc1", "staffNS"); |
| 106 | 101 |
| 107 var doc2Ref = null; | 102 var doc2Ref = null; |
| 108 if (typeof(this.doc2) != 'undefined') { | 103 if (typeof(this.doc2) != 'undefined') { |
| 109 doc2Ref = this.doc2; | 104 doc2Ref = this.doc2; |
| 110 } | 105 } |
| 111 doc2 = load(doc2Ref, "doc2", "staff"); | 106 doc2 = load(doc2Ref, "doc2", "staff"); |
| 112 xpEvaluator = createXPathEvaluator(doc1); | 107 xpEvaluator = createXPathEvaluator(doc1); |
| 113 xpathExpression = xpEvaluator.createExpression("//foo",nullNSResolver); | 108 xpathExpression = xpEvaluator.createExpression("//foo",nullNSResolver); |
| 114 root = doc2.documentElement; | 109 root = doc2.documentElement; |
| 115 | 110 |
| 116 | 111 { |
| 117 » { | 112 success = false; |
| 118 » » success = false; | 113 try { |
| 119 » » try { | |
| 120 result = xpathExpression.evaluate(root,0,nullResult); | 114 result = xpathExpression.evaluate(root,0,nullResult); |
| 121 } | 115 } |
| 122 » » catch(ex) { | 116 catch(ex) { |
| 123 success = (typeof(ex.code) != 'undefined' && ex.code == 4); | 117 success = (typeof(ex.code) != 'undefined' && ex.code == 4); |
| 124 » » } | 118 } |
| 125 » » assertTrue("throw_WRONG_DOCUMENT_ERR",success); | 119 assertTrue("throw_WRONG_DOCUMENT_ERR",success); |
| 126 » } | 120 } |
| 127 | 121 |
| 128 } | 122 } |
| 129 | 123 |
| 130 | |
| 131 | |
| 132 | |
| 133 function runTest() { | 124 function runTest() { |
| 134 XPathExpression_evaluate_WRONG_DOCUMENT_ERR(); | 125 XPathExpression_evaluate_WRONG_DOCUMENT_ERR(); |
| 135 } | 126 } |
| OLD | NEW |