>>Is this a bug in htmlunit?

No.

addEventListener() is supported only if Firefox, not IE.

You have to use FF simulation instead.

Ahmed


________________________________
From: Dale Ogilvie <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, November 4, 2008 5:00:50 AM
Subject: [Webtest] Javascript exception with document.addEventListener


Hello,

We are seeing the following error:

  [invoke] DEBUG (com.canoo.webtest.steps.Step) - Handling exception
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot find
function addEventListener in object [object].
(http://blah.com/dropdown2.js#40) 
  [invoke] ======= EXCEPTION START ========
  [invoke] EcmaError: lineNumber=[40] column=[0] lineSource=[<no
source>] name=[TypeError]
  [invoke] com.gargoylesoftware.htmlunit.ScriptException: TypeError:
Cannot find function addEventListener in object [object]. 
  [invoke]    at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContex
tAction.run(JavaScriptEngine.java:553)
  [invoke]    at org.mozilla.javascript.Context.call(Context.java:499)
  [invoke]    at
org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
  [invoke]    at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaSc
riptEngine.java:436)
  [invoke]    at
com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(H
tmlPage.java:1017)
  [invoke]    at
com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(Html
Script.java:333)
  [invoke]    at
com.gargoylesoftware.htmlunit.html.HtmlScript.onAddedToPage(HtmlScript.j
ava:233)
  [invoke]    at
com.gargoylesoftware.htmlunit.html.HtmlPage.notifyNodeAdded(HtmlPage.jav
a:1744)
  [invoke]    at
com.gargoylesoftware.htmlunit.html.DomNode.appendChild(DomNode.java:879)
  [invoke]    at
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.startEl
ement(HTMLParser.java:457)
  [invoke]    at
org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

The following html snippet seems to trigger the exception:

<html>
<head>
<script type="text/javascript">
document.addEventListener("mousedown", handleMousedown, true);

// Handles onmousedown events anywhere on the page (except menu buttons)
// to turn off action menus
function handleMousedown(event)
{
  alert("Hello");
}
</script>
</head>
<body>
<p>Hello</p>
</body>
</html>

Is this a bug in htmlunit?

Dale
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest



      

Reply via email to