@@ -38,6 +38,60 @@ protected boolean isWebClientCached() {
3838 return true ;
3939 }
4040
41+ /**
42+ * @throws Exception if the test fails
43+ */
44+ @ Test
45+ @ Alerts ({"4" , "null" })
46+ public void xPathNull () throws Exception {
47+ final String content = "<html><head>\n "
48+ + "<script>\n "
49+ + LOG_TITLE_FUNCTION
50+ + "function test() {\n "
51+ + " try {\n "
52+ + " var node = '';"
53+ + " var expr = null;\n "
54+ + " var result = document.evaluate(expr, document.documentElement, null, XPathResult.ANY_TYPE, null);\n "
55+ + " node = result.iterateNext();\n "
56+ + " log(result.resultType);\n "
57+ + " log(node);\n "
58+ + " } catch (e) {log(e.name)}\n "
59+ + "}\n "
60+ + "</script></head>\n "
61+ + "<body onload='test()'>\n "
62+ + " <select name='test'><option value='1'>foo and foo</option></select>\n "
63+ + "</body></html>" ;
64+
65+ loadPageVerifyTitle2 (content );
66+ }
67+
68+ /**
69+ * @throws Exception if the test fails
70+ */
71+ @ Test
72+ @ Alerts ({"4" , "null" })
73+ public void xPathUndefined () throws Exception {
74+ final String content = "<html><head>\n "
75+ + "<script>\n "
76+ + LOG_TITLE_FUNCTION
77+ + "function test() {\n "
78+ + " try {\n "
79+ + " var node = '';"
80+ + " var expr = undefined;\n "
81+ + " var result = document.evaluate(expr, document.documentElement, null, XPathResult.ANY_TYPE, null);\n "
82+ + " node = result.iterateNext();\n "
83+ + " log(result.resultType);\n "
84+ + " log(node);\n "
85+ + " } catch (e) {log(e.name)}\n "
86+ + "}\n "
87+ + "</script></head>\n "
88+ + "<body onload='test()'>\n "
89+ + " <select name='test'><option value='1'>foo and foo</option></select>\n "
90+ + "</body></html>" ;
91+
92+ loadPageVerifyTitle2 (content );
93+ }
94+
4195 /**
4296 * @throws Exception if the test fails
4397 */
@@ -55,7 +109,7 @@ public void optionText() throws Exception {
55109 + " for (var i = 0; i < value.length; i++) {\n "
56110 + " log(value.charCodeAt(i));\n "
57111 + " }\n "
58- + " } catch (e) {log('error' )}\n "
112+ + " } catch (e) {log(e.name )}\n "
59113 + "}\n "
60114 + "</script></head>\n "
61115 + "<body onload='test()'>\n "
@@ -84,7 +138,7 @@ public void pipe() throws Exception {
84138 + " res += node;\n "
85139 + " }\n "
86140 + " log(res);\n "
87- + " } catch (e) {log('error' )}\n "
141+ + " } catch (e) {log(e.name )}\n "
88142 + "}\n "
89143 + "</script></head>\n "
90144 + "<body onload='test()'>\n "
@@ -114,7 +168,7 @@ public void math() throws Exception {
114168 + " res += node.id;\n "
115169 + " }\n "
116170 + " log(res);\n "
117- + " } catch (e) {log('error' )}\n "
171+ + " } catch (e) {log(e.name )}\n "
118172 + "}\n "
119173 + "</script></head>\n "
120174 + "<body onload='test()'>\n "
@@ -433,7 +487,7 @@ private void compareStringValue(final String xpath) throws Exception {
433487 + " var expr = '" + xpath + "';\n "
434488 + " var result = document.evaluate(expr, document.documentElement, null, XPathResult.ANY_TYPE, null);\n "
435489 + " log(\" '\" + result.stringValue + \" '\" );\n "
436- + " } catch (e) {log('error' )}\n "
490+ + " } catch (e) {log(e.name )}\n "
437491 + "}\n "
438492 + "</script></head>\n "
439493 + "<body onload='test()'>\n "
@@ -457,7 +511,7 @@ private void compareBooleanValue(final String xpath) throws Exception {
457511 + " var expr = '" + xpath + "';\n "
458512 + " var result = document.evaluate(expr, document.documentElement, null, XPathResult.ANY_TYPE, null);\n "
459513 + " log(result.booleanValue);\n "
460- + " } catch (e) {log('error' )}\n "
514+ + " } catch (e) {log(e.name )}\n "
461515 + "}\n "
462516 + "</script></head>\n "
463517 + "<body onload='test()'>\n "
0 commit comments