| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../../../js/resources/js-test-pre.js"></script> |
| <script src="test.js"></script> |
| <script src="../../xpath-test-pre.js"></script> |
| </head> |
| <body> |
| <div id="console"></div> |
| |
| <script> |
| function nsResolver(prefix) { |
| if (prefix == 'x') |
| return 'http://spam.com'; |
| return null; |
| } |
| |
| result = DOM.evaluate("child::*", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("child::*", result, CHILDREN); |
| |
| result = DOM.evaluate("/child::*", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("/child::*", result, [ROOT]); |
| |
| result = DOM.evaluate("/*/*", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("/*/*", result, CHILDREN); |
| |
| result = DOM.evaluate("/child::*/*/child::GCHILD", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("/child::*/*/child::GCHILD", result, GCHILDREN1.concat(GCHILDREN2)); |
| |
| result = DOM.evaluate("//*", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("//*", result, [ROOT, CHILD1].concat(GCHILDREN1, [CHILD2], GCHILDREN2, [CHILD3, LANG], LCHILDREN)); |
| |
| result = DOM.evaluate("//GCHILD", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("//GCHILD", result, GCHILDREN1.concat(GCHILDREN2)); |
| |
| result = DOM.evaluate("//@attr1", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("//@attr1", result, [ATTR1, ATTR2]); |
| |
| result = DOM.evaluate("x:GCHILD", CHILD1, nsResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("x:GCHILD", result, []); |
| |
| result = DOM.evaluate(".//GCHILD", CHILD2, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot(".//GCHILD", result, GCHILDREN2); |
| |
| result = DOM.evaluate(".//GCHILD", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot(".//GCHILD", result, GCHILDREN1.concat(GCHILDREN2)); |
| |
| result = DOM.evaluate("/", text, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("/", result, [DOM]); |
| |
| result = DOM.evaluate("//CHILD1/..", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("//CHILD1/..", result, [ROOT]); |
| |
| result = DOM.evaluate(".//foo:*", CHILD3, DOM.createNSResolver(CHILD3), XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot(".//foo:*", result, []); |
| |
| result = DOM.evaluate("CHILD1 | CHILD2", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("CHILD1 | CHILD2", result, [CHILD1, CHILD2]); |
| |
| result = DOM.evaluate("descendant::GCHILD[3]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("descendant::GCHILD[3]", result, [GCHILD21]); |
| |
| result = DOM.evaluate("descendant::GCHILD[parent::CHILD1]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("descendant::GCHILD[parent::CHILD1]", result, GCHILDREN1); |
| |
| result = DOM.evaluate("descendant::GCHILD[position() > 1]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("descendant::GCHILD[position() > 1]", result, [GCHILD12].concat(GCHILDREN2)); |
| |
| result = DOM.evaluate("@attr1[.='val1']", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("@attr1[.='val1']", result, [ATTR1]); |
| |
| shouldBe('DOM.evaluate("1", ROOT, null, XPathResult.ANY_TYPE, null).numberValue', "1"); |
| shouldBe('DOM.evaluate("00200", ROOT, null, XPathResult.ANY_TYPE, null).numberValue', "200"); |
| shouldBe('DOM.evaluate("3+4*7", ROOT, null, XPathResult.ANY_TYPE, null).numberValue', "31"); |
| shouldBe('DOM.evaluate("3-4*1", ROOT, null, XPathResult.ANY_TYPE, null).numberValue', "-1"); |
| shouldBe('DOM.evaluate("string(\'1\')", ROOT, null, XPathResult.ANY_TYPE, null).stringValue', "'1'"); |
| shouldBe('DOM.evaluate("concat(\'1\', \'2\')", ROOT, null, XPathResult.ANY_TYPE, null).stringValue', "'12'"); |
| shouldBe('DOM.evaluate("true()", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "true"); |
| shouldBe('DOM.evaluate("false()", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "false"); |
| shouldBe('DOM.evaluate("1=3<4", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "true"); |
| shouldBe('DOM.evaluate("1 or 2 and 3", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "true"); |
| shouldBe('DOM.evaluate("1 and 2 = 3", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "false"); |
| shouldBe('DOM.evaluate("-1 or 2", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "true"); |
| shouldBe('DOM.evaluate(". or *", ROOT, null, XPathResult.ANY_TYPE, null).booleanValue', "true"); |
| |
| result = DOM.evaluate("text()", CHILD3, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("text()", result, []); |
| |
| result = DOM.evaluate("processing-instruction('f')", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("processing-instruction('f')", result, []); |
| |
| result = DOM.evaluate("(child::*)", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("(child::*)", result, CHILDREN); |
| |
| shouldBe('DOM.evaluate(". * 0", ROOT, null, XPathResult.NUMBER_TYPE, null).numberValue', "NaN"); |
| shouldBe('DOM.evaluate(".. * 0", ROOT, null, XPathResult.NUMBER_TYPE, null).numberValue', "NaN"); |
| shouldBe('DOM.evaluate("/.. * 0", ROOT, null, XPathResult.NUMBER_TYPE, null).numberValue', "NaN"); |
| |
| result = DOM.evaluate("CHILD2/@CODE", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("CHILD2/@CODE", result, [IDATTR2]); |
| |
| shouldBe('DOM.evaluate("CHILD2/@CODE * 0", ROOT, null, XPathResult.NUMBER_TYPE, null).numberValue', "0"); |
| |
| result = DOM.evaluate("f\xf6\xf8", LANG, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
| checkSnapshot("f\xf6\xf8", result, [NONASCIIQNAME]); |
| |
| shouldThrow('DOM.evaluate("\\\\", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)'); |
| |
| var successfullyParsed = true; |
| |
| </script> |
| <script src="../../../js/resources/js-test-post.js"></script> |
| </body> |
| </html> |