1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 2 <html> 3 <head> 4 <link rel="stylesheet" href="../js/resources/js-test-style.css"> 5 <script src="../js/resources/js-test-pre.js"></script> 6 </head> 7 <body> 8 <div id="console"></div> 9 10 <script> 11 doc = (new DOMParser).parseFromString("<doc><elem>1</elem><elem>2</elem></doc>", "application/xml"); 12 13 expr = doc.createExpression("1", null); 14 15 shouldBe("expr.evaluate(doc.documentElement.firstChild, XPathResult.STRING_TYPE, null).stringValue", "'1'"); 16 shouldBe("expr.evaluate(doc.documentElement.firstChild.nextSibling, XPathResult.STRING_TYPE, null).stringValue", "'1'"); 17 18 expr = doc.createExpression(".", null); 19 20 shouldBe("expr.evaluate(doc.documentElement.firstChild, XPathResult.STRING_TYPE, null).stringValue", "'1'"); 21 shouldBe("expr.evaluate(doc.documentElement.firstChild.nextSibling, XPathResult.STRING_TYPE, null).stringValue", "'2'"); 22 23 expr = doc.createExpression("string(.)", null); 24 25 shouldBe("expr.evaluate(doc.documentElement.firstChild, XPathResult.STRING_TYPE, null).stringValue", "'1'"); 26 shouldBe("expr.evaluate(doc.documentElement.firstChild.nextSibling, XPathResult.STRING_TYPE, null).stringValue", "'2'"); 27 28 expr = doc.createExpression("1 + .", null); 29 30 shouldBe("expr.evaluate(doc.documentElement.firstChild, XPathResult.NUMBER_TYPE, null).numberValue", "2"); 31 shouldBe("expr.evaluate(doc.documentElement.firstChild.nextSibling, XPathResult.NUMBER_TYPE, null).numberValue", "3"); 32 33 var successfullyParsed = true; 34 35 </script> 36 <script src="../js/resources/js-test-post.js"></script> 37 </body> 38 </html> 39