| 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 ['XPathEvaluator_evaluate_NAMESPACE_ERR']; | 15 return ['XPathEvaluator_evaluate_NAMESPACE_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 docRef = null; | 40 var docRef = null; |
| 43 if (typeof(this.doc) != 'undefined') { | 41 if (typeof(this.doc) != 'undefined') { |
| 44 docRef = this.doc; | 42 docRef = this.doc; |
| 45 } | 43 } |
| 46 docsLoaded += preload(docRef, "doc", "staffNS"); | 44 docsLoaded += preload(docRef, "doc", "staffNS"); |
| 47 | 45 |
| 48 if (docsLoaded == 1) { | 46 if (docsLoaded == 1) { |
| 49 setUpPageStatus = 'complete'; | 47 setUpPageStatus = 'complete'; |
| 50 } | 48 } |
| 51 } catch(ex) { | 49 } catch(ex) { |
| 52 » catchInitializationError(builder, ex); | 50 catchInitializationError(builder, ex); |
| 53 setUpPageStatus = 'complete'; | 51 setUpPageStatus = 'complete'; |
| 54 } | 52 } |
| 55 } | 53 } |
| 56 | 54 |
| 57 | |
| 58 | |
| 59 // | 55 // |
| 60 // This method is called on the completion of | 56 // This method is called on the completion of |
| 61 // each asychronous load started in setUpTests. | 57 // each asychronous load started in setUpTests. |
| 62 // | 58 // |
| 63 // When every synchronous loaded document has completed, | 59 // When every synchronous loaded document has completed, |
| 64 // the page status is changed which allows the | 60 // the page status is changed which allows the |
| 65 // body of the test to be executed. | 61 // body of the test to be executed. |
| 66 function loadComplete() { | 62 function loadComplete() { |
| 67 if (++docsLoaded == 1) { | 63 if (++docsLoaded == 1) { |
| 68 setUpPageStatus = 'complete'; | 64 setUpPageStatus = 'complete'; |
| 69 } | 65 } |
| 70 } | 66 } |
| 71 | 67 |
| 68 /** |
| 69 * |
| 70 Test if XPathEvaluator.evaluate properly throws NAMESPACE_ERROR |
| 72 | 71 |
| 73 /** | |
| 74 * | |
| 75 Test if XPathEvaluator.evaluate properly throws NAMESPACE_ERROR | |
| 76 | |
| 77 * @author Philippe Le Hégaret | 72 * @author Philippe Le Hégaret |
| 78 * @author Bob Clary | 73 * @author Bob Clary |
| 79 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvalua
tor-evaluate | 74 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvalua
tor-evaluate |
| 80 */ | 75 */ |
| 81 function XPathEvaluator_evaluate_NAMESPACE_ERR() { | 76 function XPathEvaluator_evaluate_NAMESPACE_ERR() { |
| 82 var success; | 77 var success; |
| 83 if(checkInitialization(builder, "XPathEvaluator_evaluate_NAMESPACE_ERR") !=
null) return; | 78 if(checkInitialization(builder, "XPathEvaluator_evaluate_NAMESPACE_ERR") !=
null) return; |
| 84 var doc; | 79 var doc; |
| 85 var xpEvaluator; | 80 var xpEvaluator; |
| 86 var root; | 81 var root; |
| 87 var result; | 82 var result; |
| 88 var nullNSResolver = null; | 83 var nullNSResolver = null; |
| 89 | 84 |
| 90 var nullResult = null; | 85 var nullResult = null; |
| 91 | 86 |
| 92 | |
| 93 var docRef = null; | 87 var docRef = null; |
| 94 if (typeof(this.doc) != 'undefined') { | 88 if (typeof(this.doc) != 'undefined') { |
| 95 docRef = this.doc; | 89 docRef = this.doc; |
| 96 } | 90 } |
| 97 doc = load(docRef, "doc", "staffNS"); | 91 doc = load(docRef, "doc", "staffNS"); |
| 98 xpEvaluator = createXPathEvaluator(doc); | 92 xpEvaluator = createXPathEvaluator(doc); |
| 99 root = doc.documentElement; | 93 root = doc.documentElement; |
| 100 | 94 |
| 101 | 95 { |
| 102 » { | 96 success = false; |
| 103 » » success = false; | 97 try { |
| 104 » » try { | |
| 105 result = xpEvaluator.evaluate("//foo:bar",root,nullNSResolver,0,null
Result); | 98 result = xpEvaluator.evaluate("//foo:bar",root,nullNSResolver,0,null
Result); |
| 106 } | 99 } |
| 107 » » catch(ex) { | 100 catch(ex) { |
| 108 success = (typeof(ex.code) != 'undefined' && ex.code == 14); | 101 success = (typeof(ex.code) != 'undefined' && ex.code == 14); |
| 109 » » } | 102 } |
| 110 » » assertTrue("throw_NAMESPACE_ERR",success); | 103 assertTrue("throw_NAMESPACE_ERR",success); |
| 111 » } | 104 } |
| 112 | 105 |
| 113 } | 106 } |
| 114 | 107 |
| 115 | |
| 116 | |
| 117 | |
| 118 function runTest() { | 108 function runTest() { |
| 119 XPathEvaluator_evaluate_NAMESPACE_ERR(); | 109 XPathEvaluator_evaluate_NAMESPACE_ERR(); |
| 120 } | 110 } |
| OLD | NEW |