1<html> 2<head> 3<link rel="stylesheet" href="../js/resources/js-test-style.css"> 4<script src="../js/resources/js-test-pre.js"></script> 5<script src="xpath-test-pre.js"></script> 6<style> 7#context {display:none} 8</style> 9</head> 10<body> 11<p>Test that an NCName and * are interpreted as an operator when in 12binary operator context, and as a NameTest otherwise. 13 14<p>See <a href="http://bugs.webkit.org/show_bug.cgi?id=50366">bug 50366</a>: 15XPath lexer misinterprets expression starting with "div".</p> 16 17<div id="console"></div> 18 19<div id="context"> 20 <div id="two" div="x">2</div> 21</div> 22 23<script> 24var context = document.getElementById('context'); 25var div = document.getElementById('two'); 26 27// =========== div =========== 28 29test(document, context, "div", [div], null); // div with no preceding token 30test(document, context, " div", [div], null); 31// div following every possible [28] ExprToken http://www.w3.org/TR/xpath/ 32test(document, context, "(div) div (div)", 2/2, null); // div after ( and ) 33test(document, context, "self::node()[div] div 1", 2/1, null); // div after [ and ] 34test(document, context, ". div .", 2/2, null); // div after . 35test(document, div, ".. div ..", 2/2, null); // div after .. 36test(document, context, "string(div/@div)", "x", null); // div after @ 37test(document, context, "substring-before('1992', div)", "199", null); // div after , 38test(document, div, "self::div", [div], null); // div after :: 39test(document, context, "* div 4", 2/4, null); // div after NameTest * 40test(document, context, "'3' div 4", 3/4, null); // div after Literal 41test(document, context, "\"3\" div 4", 3/4, null); // div after Literal 42test(document, context, "12 div 4", 12/4, null); // div after Number 43 44// div following every [32] Operator 45test(document, context, "true() and div", true, null); // div after OperatorName and 46test(document, context, "false() or div", true, null); // div after OperatorName or 47test(document, context, "div mod div", 0, null); // div after OperatorName mod 48test(document, context, "div div div", 1, null); // div after OperatorName div 49test(document, context, "3 * div", 6, null); // div after MultiplyOperator 50test(document, context, "div/div", [], null); // div after / 51test(document, context, "div//div", [], null); // div after // 52test(document, context, "zz|div", [div], null); // div after | 53test(document, context, "div+div", 4, null); // div after + 54test(document, context, "- - div", 2, null); // div after unary - 55test(document, context, "5 -div", 3, null); // div after binary - 56test(document, context, "div=div", true, null); // div after = 57test(document, context, "div!=div", false, null); // div after = 58test(document, context, "div<div", false, null); // div after < 59test(document, context, "div<=div", true, null); // div after <= 60test(document, context, "div>div", false, null); // div after > 61test(document, context, "div>=div", true, null); // div after >= 62 63 64// =========== * =========== 65 66test(document, context, "*", [div], null); // * with no preceding token 67test(document, context, " *", [div], null); 68// * following every possible [28] ExprToken http://www.w3.org/TR/xpath/ 69test(document, context, "(*) * (*)", 2*2, null); // * after ( and ) 70test(document, context, "self::node()[*] * 1", 2*1, null); // * after [ and ] 71test(document, context, ". * .", 2*2, null); // * after . 72test(document, div, ".. * ..", 2*2, null); // * after .. 73// (* can't follow @) 74test(document, context, "substring-before('1992', *)", "199", null); // * after , 75test(document, div, "self::*", [div], null); // * after :: 76test(document, context, "* * 4", 2*4, null); // * after NameTest * 77test(document, context, "'3' * 4", 3*4, null); // * after Literal 78test(document, context, "\"3\" * 4", 3*4, null); // * after Literal 79test(document, context, "12 * 4", 12*4, null); // * after Number 80 81// * following every [32] Operator 82test(document, context, "true() and *", true, null); // * after OperatorName and 83test(document, context, "false() or *", true, null); // * after OperatorName or 84test(document, context, "* mod *", 0, null); // * after OperatorName mod 85test(document, context, "* div *", 1, null); // * after OperatorName div 86test(document, context, "3 * *", 6, null); // * after MultiplyOperator 87test(document, context, "*/*", [], null); // * after / 88test(document, context, "*//*", [], null); // * after // 89test(document, context, "zz|*", [div], null); // * after | 90test(document, context, "*+*", 4, null); // * after + 91test(document, context, "- - *", 2, null); // * after unary - 92test(document, context, "5 -*", 3, null); // * after binary - 93test(document, context, "*=*", true, null); // * after = 94test(document, context, "*!=*", false, null); // * after = 95test(document, context, "*<*", false, null); // * after < 96test(document, context, "*<=*", true, null); // * after <= 97test(document, context, "*>*", false, null); // * after > 98test(document, context, "*>=*", true, null); // * after >= 99 100var xmlDoc = (new DOMParser).parseFromString("<or xmlns='uri'>5</or>", "text/xml"); 101var nsResolver = function(prefix) {return 'uri';} 102// div and * after : 103test(xmlDoc, xmlDoc, "or:or", [xmlDoc.documentElement], nsResolver); 104test(xmlDoc, xmlDoc, "or:*", [xmlDoc.documentElement], nsResolver); 105 106// A few tests with mod as well 107var xmlDoc2 = (new DOMParser).parseFromString("<mod and='x'>8</mod>", "text/xml"); 108test(xmlDoc2, xmlDoc2, "mod", [xmlDoc2.documentElement], null); 109test(xmlDoc2, xmlDoc2, "mod mod mod", 0, null); 110test(xmlDoc2, xmlDoc2, "(mod) mod 5", 3, null); 111test(xmlDoc2, xmlDoc2, "string(mod/@and)", 'x', null); 112 113 114var successfullyParsed = true; 115</script> 116<script src="../js/resources/js-test-post.js"></script> 117</body> 118</html> 119