Bugs item #1724695, was opened at 2007-05-24 11:31
Message generated for change (Comment added) made by
henryju
You can respond by visiting:
https://sourcefor
ge.net/tracker/?func=detail&atid=497982&aid=1724695&
amp;group_id=61302
Please note that this message will contain a full copy of
the comment thread,
including the initial issue submission, for this request,
not just the latest update.
>Category: HtmlUnit plugin
Group: Release 1.4.1
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Kai (aexon)
>Assigned to: Julien HENRY (henryju)
Summary: Javascript and its navigator is null
Initial Comment:
Hello together,
I had a problem concerning a very small testapp written by
me. It was derived from a larger testframework developed by
a colleague of mine. The Exception was the same...
The simple HTML source with the javascript snipplet:
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=windows-1252"/>
<meta http-equiv="Content-Language"
content="de"/>
<title> test </title>
</head>
<body>
<script type="text/javascript">
var nv = navigator;
var n = nv.userAgent.toLowerCase ();
alert(n);
</script>
</body>
</html>
The java source:
package test;
import net.sourceforge.jwebunit.junit.WebTestCase;
import net.sourceforge.jwebunit.junit.WebTester ;
public class Test_JavaScript extends WebTestCase {
private WebTester webTester;
private static String baseUrl = "url";
//replaced by me
private static String beginAt = "/startAt";
//replaced by me
public void setUp() throws Exception{
this.webTester = getTester();
}
public void testJavaScript() {
getTestContext().setBaseUrl(baseUrl);
getTestContext().addRequestHeader("Accept-Language"
;, "de,de;q=0.7");
getTestContext().addRequestHeader("User-Agent",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:
1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
beginAt(beginAt);
}
public void tearDown() {
closeBrowser();
}
}
and here the Exception by the eclipse junit testrunner:
.log4j:WARN No appenders could be found for logger
(com.gargoylesoftware.htmlunit.WebClient).
log4j:WARN Please initialize the log4j system properly.
E
Time: 1.371
There was 1 error:
1) testJavaScript( test.Test_JavaScript)======= EXCEPTION
START ========
EcmaError: lineNumber=[2] column=[0] lineSource=[
var n = nv.userAgent.toLowerCase();] name=[TypeError]
sourceName=[Embedded script in URL from (8, 34) to (0, 0)]
message=[TypeError: Cannot call method
"toLowerCase" of null (Embedded script in URL from
(8, 34) to (0, 0)#2)]
com.gargoylesoftware.htmlunit.ScriptException: TypeError:
Cannot call method "toLowerCase" of null (Embedded
script in URL from (8, 34) to (0, 0)#2)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.ex
ecute (JavaScriptEngine.java:260)
at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScrip
tIfPossible(HtmlPage.java:697)
at
com.gargoylesoftware.htmlunit.html.HtmlScript.appendChild(Ht
mlScript.java:188)
at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBui
lder.handleCharacters(HTMLParser.java:455)
at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBui
lder.endElement(HTMLParser.java:415)
at
org.apache.xerces.parsers.AbstractSAXParser.endElement(Unkno
wn Source)
at
org.cyberneko.html.filters.DefaultFilter.endElement(DefaultF
ilter.java:249)
at
org.cyberneko.html.filters.NamespaceBinder.endElement(
NamespaceBinder.java:367)
at
org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBal
ancer.java:1015)
at
org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalance
r.java:888)
at org.cyberneko.html.HTMLScanner$SpecialScanner.scan
(HTMLScanner.java:2841)
at
org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java
:819)
at
org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration
.java:478)
at org.cyberneko.html.HTMLConfiguration.parse
(HTMLConfiguration.java:431)
at org.apache.xerces.parsers.XMLParser.parse(Unknown
Source)
at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBui
lder.parse(HTMLParser.java:346)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse
(HTMLParser.java:229)
at
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlP
age(DefaultPageCreator.java:112)
at
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(
DefaultPageCreator.java:85)
at
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(
WebClient.java:441)
at
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.ja
va:345)
at com.gargoylesoftware.htmlunit.WebClient.getPage
(WebClient.java:399)
at
net.sourceforge.jwebunit.htmlunit.HtmlUnitDialog.beginAt(Htm
lUnitDialog.java:161)
at
net.sourceforge.jwebunit.junit.WebTester.beginAt(WebTester.j
ava:190)
at net.sourceforge.jwebunit.junit.WebTestCase.beginAt
(WebTestCase.java:130)
at
test.Test_JavaScript.testJavaScript(Test_JavaScript.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
ssorImpl.java :39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
thodAccessorImpl.java:25)
at
net.sourceforge.jwebunit.junit.WebTestCase.runBare(WebTestCa
se.java:58)
at test.TestRun.main(TestRun.java :10)
Caused by: org.mozilla.javascript.EcmaError: TypeError:
Cannot call method "toLowerCase" of null (Embedded
script in URL from (8, 34) to (0, 0)#2)
at org.mozilla.javascript.ScriptRuntime.constructError
(ScriptRuntime.java:3226)
at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRu
ntime.java:3216)
at
org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime
.java:3232)
at org.mozilla.javascript.ScriptRuntime.typeError2
(ScriptRuntime.java:3251)
at
org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRu
ntime.java:3270)
at
org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(
ScriptRuntime.java:1966)
at org.mozilla.javascript.Interpreter.interpretLoop
(Interpreter.java:2931)
at
org.mozilla.javascript.Interpreter.interpret(Interpreter.jav
a:2250)
at
org.mozilla.javascript.InterpretedFunction.call(InterpretedF
unction.java:149)
at org.mozilla.javascript.ContextFactory.doTopCall
(ContextFactory.java:337)
at
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFact
ory.doTopCall(HtmlUnitContextFactory.java:151)
at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime
.java:2755)
at
org.mozilla.javascript.InterpretedFunction.exec(InterpretedF
unction.java:160)
at
org.mozilla.javascript.Context.evaluateString(Context.java:1
132)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.ex
ecute (JavaScriptEngine.java:255)
... 42 more
Enclosed exception:
org.mozilla.javascript.EcmaError: TypeError: Cannot call
method "toLowerCase" of null (Embedded script in
URL from (8, 34) to (0, 0)#2)
at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRu
ntime.java:3226)
at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRu
ntime.java:3216)
at org.mozilla.javascript.ScriptRuntime.typeError
(ScriptRuntime.java:3232)
at
org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntim
e.java:3251)
at
org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRu
ntime.java:3270)
at
org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis
(ScriptRuntime.java:1966)
at
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter
.java:2931)
at script(Embedded script in URL from (8, 34) to (0,
0):2)
at org.mozilla.javascript.Interpreter.interpret
(Interpreter.java:2250)
at
org.mozilla.javascript.InterpretedFunction.call(InterpretedF
unction.java:149)
at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFacto
ry.java:337)
at
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFact
ory.doTopCall (HtmlUnitContextFactory.java:151)
at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime
.java:2755)
at
org.mozilla.javascript.InterpretedFunction.exec(InterpretedF
unction.java:160)
at org.mozilla.javascript.Context.evaluateString
(Context.java:1132)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.ex
ecute(JavaScriptEngine.java:255)
at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScrip
tIfPossible(HtmlPage.java:697)
at
com.gargoylesoftware.htmlunit.html.HtmlScript.appendChild(Ht
mlScript.java:188)
at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBui
lder.handleCharacters(HTMLParser.java:455)
at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBui
lder.endElement (HTMLParser.java:415)
at
org.apache.xerces.parsers.AbstractSAXParser.endElement(Unkno
wn Source)
at
org.cyberneko.html.filters.DefaultFilter.endElement(DefaultF
ilter.java:249)
at org.cyberneko.html.filters.NamespaceBinder.endElement
(NamespaceBinder.java:367)
at
org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBal
ancer.java:1015)
at
org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalance
r.java:888)
at org.cyberneko.html.HTMLScanner$SpecialScanner.scan
(HTMLScanner.java:2841)
at
org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java
:819)
at
org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration
.java:478)
at org.cyberneko.html.HTMLConfiguration.parse
(HTMLConfiguration.java:431)
at org.apache.xerces.parsers.XMLParser.parse(Unknown
Source)
at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBui
lder.parse(HTMLParser.java:346)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse
(HTMLParser.java:229)
at
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlP
age(DefaultPageCreator.java:112)
at
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(
DefaultPageCreator.java:85)
at
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(
WebClient.java:441)
at
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.ja
va:345)
at com.gargoylesoftware.htmlunit.WebClient.getPage
(WebClient.java:399)
at
net.sourceforge.jwebunit.htmlunit.HtmlUnitDialog.beginAt(Htm
lUnitDialog.java:161)
at
net.sourceforge.jwebunit.junit.WebTester.beginAt(WebTester.j
ava:190)
at net.sourceforge.jwebunit.junit.WebTestCase.beginAt
(WebTestCase.java:130)
at
test.Test_JavaScript.testJavaScript(Test_JavaScript.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
ssorImpl.java :39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
thodAccessorImpl.java:25)
at
net.sourceforge.jwebunit.junit.WebTestCase.runBare(WebTestCa
se.java:58)
at test.TestRun.main(TestRun.java :10)
== CALLING JAVASCRIPT ==
var nv = navigator;
var n = nv.userAgent.toLowerCase();
alert(n);
======= EXCEPTION END ========
FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1
In the testframework and the simple example the exceptions
are the same.
regards from germany
Kai
ps: this bug was confirmed by Julien Henry on may 20th.
------------------------------------------------------------
----------
>Comment By: Julien HENRY (henryju)
Date: 2007-05-24 12:30
Message:
Logged In: YES
user_id=1235926
Originator: NO
A quick fix is to use getTestContext().setUserAgent()
------------------------------------------------------------
----------
You can respond by visiting:
https://sourcefor
ge.net/tracker/?func=detail&atid=497982&aid=1724695&
amp;group_id=61302
------------------------------------------------------------
-------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and
take
control of your XML. No limits. Just data. Click to get it
now.
http://sourcefor
ge.net/powerbar/db2/
_______________________________________________
JWebUnit-development mailing list
JWebUnit-development lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jw
ebunit-development
|