|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
[ htmlunit-Bugs-1933943 ] Issues with nested object function callsBugs item #1933943, was opened at 2008-04-03 21:00
Message generated for change (Comment added) made by sdanig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1933943&group_id=47038 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: None Group: None Status: Open Resolution: Accepted Priority: 5 Private: No Submitted By: Matt Inger (mattinger) Assigned to: Nobody/Anonymous (nobody) Summary: Issues with nested object function calls Initial Comment: I am having some issues with nested function calls. I get the following error: Exception in thread "main" ======= EXCEPTION START ======== EcmaError: lineNumber=[15] column=[0] lineSource=[<no source>] name=[TypeError] sourceName=[script in file:test.html from (3, 36) to (0, 0)] message=[TypeError: iterator is not a function, it is org.mozilla.javascript.NativeObject. (script in file:test.html from (3, 36) to (0, 0)#15)] com.gargoylesoftware.htmlunit.ScriptException: TypeError: iterator is not a function, it is org.mozilla.javascript.NativeObject. (script in file:test.html from (3, 36) to (0, 0)#15) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:557) at org.mozilla.javascript.Context.call(Context.java:577) at org.mozilla.javascript.Context.call(Context.java:499) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:439) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:414) I have isolated the issue in a small html file which has no outside dependencies. If i remove the "new" from in front of the function definition when I call ".each", then the error disappears. Html Code (test.html) ---------------------- <html> <head> <script type="text/javascript"> Object.extend = function(destination, source) { for (var property in source) { destination[property] = source[property]; } return destination; }; Object.extend( Array.prototype, { _each: function(iterator) { for (var i=0;i<this.length;i++) iterator(this[i]); }, each: function(iterator) { this._each(function(value) { iterator(value) }) } } ); var x = [ "a", "b", "c" ]; x.each(new function(a, b) { }); </script> </head> <body> </body> </html> Java Code (HtmlTest.java) ---------------------------- import com.gargoylesoftware.htmlunit.AlertHandler; import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlPage; public class HtmlTest { public static void main(String args[]) throws Exception { WebClient client = new WebClient(BrowserVersion.INTERNET_EXPLORER_6_0); HtmlPage page = (HtmlPage) client.getPage("file:test.html"); System.out.println(page.asXml()); } } ---------------------------------------------------------------------- >Comment By: Daniel Gredler (sdanig) Date: 2008-07-02 16:01 Message: Logged In: YES user_id=1109422 Originator: NO At this point, this bug is only about not being able to alias the eval function. It works fine with any other function. For some background, see: http://groups.google.com/group/mozilla.dev.tech.js-engine.rhino/browse_thread/thread/1f1c24f58f662c58 ---------------------------------------------------------------------- Comment By: Ahmed Ashour (asashour) Date: 2008-04-09 16:03 Message: Logged In: YES user_id=950730 Originator: NO Well, this is a different. SimpleScriptableTest.passFunctionAsParameter() has been added as @NotYetImplemented. The following is the smaller case (instead of 'nested calls') <html><head><title>First</title><script> function run(fun) { fun('alert(1)'); } function test() { run(eval); } </script></head><body onload='test()'> </body></html> ---------------------------------------------------------------------- Comment By: Matt Inger (mattinger) Date: 2008-04-06 22:27 Message: Logged In: YES user_id=83032 Originator: YES No, the source was an internal script, which I have since corrected, but figured I would report the issue. It was never noticed in IE or FF, because there was some questionable javascript causing errors in htmlunit. Eval was being passed as an argument to a function, which apparantly isn't acceptable to htmlunit: array.each( eval ); So, the script was being replaced inline (via a ScriptPreProcessor) with: array.each( new function(s) { eval(s); }} ); I have since corrected this to remove the "new". ---------------------------------------------------------------------- Comment By: Ahmed Ashour (asashour) Date: 2008-04-06 17:40 Message: Logged In: YES user_id=950730 Originator: NO After testing, I have to reject this case. Please add "try {}catch" around your code, and you will find IE and FF throw an error. Retest and advise if you think otherwise. <html><head><title>First</title><script> try{ Object.extend = function(destination, source) { for (var property in source) { destination[property] = source[property]; } return destination; }; Object.extend(Array.prototype, { _each: function(some_function) { for (var i=0;i<this.length;i++) some_function(this[i]); }, each: function(some_function) { this._each(function(value) { some_function(value) }) } }); var x = [ 'a', 'b', 'c' ]; x.each(new function(a, b) { }); } catch(e) { alert(e.message); } </script></head><body> </body></html> ---------------------------------------------------------------------- Comment By: Ahmed Ashour (asashour) Date: 2008-04-05 02:30 Message: Logged In: YES user_id=950730 Originator: NO Thanks a lot for isolating this. - SimpleScriptableTest.iterator() has been added as @NotYetImplemented. - Out of curiosity, was the source of this bug any public JS library (e.g. Dojo, Prototype, jQuery)? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1933943&group_id=47038 ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ HtmlUnit-develop mailing list HtmlUnit-develop@... https://lists.sourceforge.net/lists/listinfo/htmlunit-develop |
| Free Forum Powered by Nabble | Forum Help |