I've finally pointed an HtmlUnit test at my wee OPS app, and the test very quickly failed:
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "length" from undefined (http://localhost:8090/udf/xforms-server/xforms-min.js#3127) I had been using HtmlUnit 1.13, so I tried upgrading to 1.14 to no avail. I changed "oxf.xforms.minimal-resources" to "false" and the error remained, but was reported at "xforms.js#10158" instead. In both cases, the line of Javascript code is this: for (var i=0;i<this.focusableElements.length;i++) { So presumably focusableElements is null for some reason. I took a look with the debugger, but wasn't able to learn anything useful about what's going on when that exception is hit -- e.g. what had triggered the Javascript call -- though I can certainly dig further. I also took a look around to see if I could manually add a null check in the .js file, but... I can't find it! I found two similarly-named files in "orbeon-resources-public.jar" but... they don't seem to have the same content as the files served to the browser? (They also have no newlines?) I thought I might change the <script> reference in the page itself, to point instead to a local version of the file, but so far my search tools haven't found the place the tag is inserted. I also tried changing the "browser version" of my HtmlUnit client, but the only one that had any effect was going back to Netscape 4, which failed on a missing function, "indexOf" I think. Finally, if I disable Javascript on the HtmlUnit client, then the page successfully loads (or, the XHTML I dumped to the console looks reasonable), but of course the functionality isn't there. So I'm a bit stuck. Any ideas? Oh, these warnings also appear on the console, though I don't think they are related: Mar 19, 2008 2:02:00 PM com.gargoylesoftware.htmlunit.html.HtmlPage loadJavaScriptFromUrl WARNING: Expected content type of 'text/javascript' or 'application/x-javascript' for remotely loaded JavaScript element at 'http://localhost:8090/udf/xforms-server/xforms-min.js', but got 'application/javascript'. Mar 19, 2008 2:02:00 PM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter warning WARNING: warning: message=[Duplicate parameter name "_dummy".] sourceName=[http://localhost:8090/udf/xforms-server/xforms-min.js] line=[6127] lineSource=[ helpDialogXClose: function(_dummy, _dummy, formID) {] lineOffset=[46] Thanks! rodney |
Administrator
|
Well it seems to me that HtmlUnit is not entirely compatible with our
JavaScript code. To see clearer, first change the following in properties.xml: <property as="xs:boolean" name="oxf.xforms.minimal-resources" value="false"/> <property as="xs:boolean" name="oxf.xforms.combine-resources" value="false"/> Then unzip orbeon-resources-public.jar. In there, you will find all the JavaScript files loaded by the browser, including xforms.js and the YUI JavaScript files. If you unzip that file under WEB-INF/resources, then you can even modify the JavaScript files on the fly. It would be interesting to make this work, because it would allow us to do more unit tests (duh!) in Orbeon Forms itself. Please keep us posted. -Erik On Mar 19, 2008, at 3:17 PM, Rodney Gitzel wrote: > > I've finally pointed an HtmlUnit test at my wee OPS app, and the > test very > quickly failed: > > com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot > read > property "length" from undefined > (http://localhost:8090/udf/xforms-server/xforms-min.js#3127) > > > I had been using HtmlUnit 1.13, so I tried upgrading to 1.14 to no > avail. I > changed "oxf.xforms.minimal-resources" to "false" and the error > remained, > but was reported at "xforms.js#10158" instead. > > In both cases, the line of Javascript code is this: > > for (var i=0;i<this.focusableElements.length;i++) { > > So presumably focusableElements is null for some reason. > > I took a look with the debugger, but wasn't able to learn anything > useful > about what's going on when that exception is hit -- e.g. what had > triggered > the Javascript call -- though I can certainly dig further. > > I also took a look around to see if I could manually add a null > check in the > .js file, but... I can't find it! I found two similarly-named > files in > "orbeon-resources-public.jar" but... they don't seem to have the same > content as the files served to the browser? (They also have no > newlines?) > I thought I might change the <script> reference in the page itself, > to point > instead to a local version of the file, but so far my search tools > haven't > found the place the tag is inserted. > > I also tried changing the "browser version" of my HtmlUnit client, > but the > only one that had any effect was going back to Netscape 4, which > failed on a > missing function, "indexOf" I think. > > Finally, if I disable Javascript on the HtmlUnit client, then the page > successfully loads (or, the XHTML I dumped to the console looks > reasonable), > but of course the functionality isn't there. > > So I'm a bit stuck. Any ideas? > > Oh, these warnings also appear on the console, though I don't think > they are > related: > > Mar 19, 2008 2:02:00 PM com.gargoylesoftware.htmlunit.html.HtmlPage > loadJavaScriptFromUrl > WARNING: Expected content type of 'text/javascript' or > 'application/x-javascript' for remotely loaded > JavaScript element at > 'http://localhost:8090/udf/xforms-server/xforms-min.js', but got > 'application/javascript'. > Mar 19, 2008 2:02:00 PM > com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter warning > WARNING: warning: message=[Duplicate parameter name "_dummy".] > sourceName=[http://localhost:8090/udf/xforms-server/xforms-min.js] > line=[6127] lineSource=[ > helpDialogXClose: function(_dummy, _dummy, formID) {] > lineOffset=[46] > > > Thanks! > > rodney > > > > -- > View this message in context: http://www.nabble.com/Javascript-error-when-using-HtmlUnit-tp16153154p16153154.html > Sent from the ObjectWeb OPS - Users mailing list archive at > Nabble.com. > > > -- > You receive this message as a subscriber of the [hidden email] > mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Sweet!
I unzipped as you said, confirmed the error was still happening, noted it was now being reported in a different place (/ops/javascript/yui/container.js#3020) and added a null check there. No more error! That's only the initial finding, so I'll now do some actual testing to see if I encounter other problems. As for the null check, Erik, does that seem a reasonable thing to do, or is it strange that focusableElements would ever be null? If the latter, I can bring it up on the HtmlUnit list and see what they say (mostly like it would be "talk to the Rhino folks"...). Thanks! rodney
|
Administrator
|
Good news!
With the latest code, I notice that focusableElements is used only in container.js, and on two lines only. The line you quoted initially doesn't seem to happen anymore. So maybe by upgrading to a recent build will just fix the problem. -Erik On Mar 20, 2008, at 11:44 AM, Rodney Gitzel wrote: > > Sweet! > > I unzipped as you said, confirmed the error was still happening, > noted it > was now being reported in a different place > (/ops/javascript/yui/container.js#3020) and added a null check there. > > No more error! > > That's only the initial finding, so I'll now do some actual testing > to see > if I encounter other problems. As for the null check, Erik, does > that seem > a reasonable thing to do, or is it strange that focusableElements > would ever > be null? If the latter, I can bring it up on the HtmlUnit list and > see > what they say (mostly like it would be "talk to the Rhino folks"...). > > Thanks! > > rodney > > > > Erik Bruchez wrote: >> >> Well it seems to me that HtmlUnit is not entirely compatible with our >> JavaScript code. >> >> To see clearer, first change the following in properties.xml: >> >> <property as="xs:boolean" name="oxf.xforms.minimal-resources" >> value="false"/> >> <property as="xs:boolean" name="oxf.xforms.combine-resources" >> value="false"/> >> >> Then unzip orbeon-resources-public.jar. In there, you will find all >> the JavaScript files loaded by the browser, including xforms.js and >> the YUI JavaScript files. >> >> If you unzip that file under WEB-INF/resources, then you can even >> modify the JavaScript files on the fly. >> >> It would be interesting to make this work, because it would allow us >> to do more unit tests (duh!) in Orbeon Forms itself. Please keep us >> posted. >> >> -Erik >> > > -- > View this message in context: http://www.nabble.com/Javascript-error-when-using-HtmlUnit-tp16153154p16185857.html > Sent from the ObjectWeb OPS - Users mailing list archive at > Nabble.com. > > > -- > You receive this message as a subscriber of the [hidden email] > mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
In reply to this post by Rodney Gitzel
Alas...
I wrote a test to see if the submit button on my form would enable once a value is changed, but couldn't get it to work. So I wrote a test of the "xforms-hello" demo app to see if I could detect the text being updated. Can't see that either. No errors, just the text doesn't change. Now, there have been problems in the past where HtmlUnit somehow didn't trigger the Javascript events that a browser would have fired, and I would have to manually do it. AFAIK that went away in version 1.12 or 1.13, but maybe something similar is happening here? Trouble is, the event handlers don't seem to be of the simple "onclick" variety. So here's my question: what exactly happens when the value of the input box of the "xforms-hello" changes? What event triggers OPS to do its magic? Conversely, is there a specific Javascript method that would be called? There are ways to essentially breakpoint that. Which reminds me, I used that to figure out which component that null pointer is happening on: printing out "this" gave "Panel yui -gen0" which seems to be the <div> tag containing the error dialog? Thanks. rodney |
Administrator
|
Rodney,
On Thu, Mar 20, 2008 at 4:52 PM, Rodney Gitzel <[hidden email]> wrote: > So here's my question: what exactly happens when the value of the input box > of the "xforms-hello" changes? What event triggers OPS to do its magic? > Conversely, is there a specific Javascript method that would be called? > There are ways to essentially breakpoint that. If you load xforms.js and look at the functions declared inside/under "ORBEON.xforms.Events = {" you will see all the Orbeon Forms event handlers there. In general it is the "change" event that matters. It is dispatched by the browser if you change a field, after you tab out. For "incremental" fields, we have to listen to key events. This is more complicated, so you might want to get this working first in the non-incremental case. Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
I've added an alert to the start of this function (line 1007 or so):
alert( event == null ? 'null' : 'change event on ' + event.constructor ) ; When I load the 'xforms-hello' page in Firefox and change the 'first name' value, there is first an odd pause until I click somewhere else on the page. Then the following alert comes up: "change event on [Event]" That seems right (a further alert confirms that event.target.name is 'xforms-element-3'). But when I hit the page with HtmlUnit I pick this up instead: "change event on function Object() { [native code for Object.Object, arity=1] }" So something is passed in as an 'event', but it's certainly not an Event. :-( I want to report this to the HtmlUnit folks, but the closer I can get to where this object is created the better. Is there a way to determine the equivalent of a stack-trace to determine where the call to this event handler was made? Thanks. rodney
|
Administrator
|
On Mar 25, 2008, at 3:35 PM, Rodney Gitzel wrote:
> I want to report this to the HtmlUnit folks, but the closer I can > get to > where this object is created the better. Is there a way to > determine the > equivalent of a stack-trace to determine where the call to this event > handler was made? Install Firebug if you don't already have it installed, and use console.trace(). That will be give you a nice "stack trace" for the location where you put the console.trace(). More here: http://www.getfirebug.com/console.html Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Sweet! Didn't know about that call. And... there wasn't much of a stack trace: the event handler was the only thing in it! So it's the browser kicking off the event directly, not any OPS code. Which suggests that HtmlUnit isn't correctly dealing with this kind of event.
I'm not much familiar with the Javascript event model. I know about 'onclick' and the like, but I don't understand the way it's being done here, presumably the events are attached at run-time? I looked for where this is done, but didn't find much. Is there a name for this kind of event handler handling, something I could tell the HtmlUnit folks so that they would go "aha!... we do/don't support that"? And is there a specific place in the OPS code I could look to see how the handlers are attached? Thanks. rodney
|
Administrator
|
Rodney,
On Mar 26, 2008, at 3:36 PM, Rodney Gitzel wrote: > I'm not much familiar with the Javascript event model. I know about > 'onclick' and the like, but I don't understand the way it's being > done here, > presumably the events are attached at run-time? I looked for where > this is > done, but didn't find much. Exactly: when the page first loads, there is some code in xforms.js that registers event listeners on a number of events. You will find it under "ORBEON.xforms.Init = {". For non-IE (more standards-compliant) browsers, this is done by registering just one event handler on the window object: window.addEventListener("change", ORBEON.xforms.Events.change, true); For IE, we need to register one event handler for each form element. The function that does this is invoked with: ORBEON.xforms.Init.registerListenersOnFormElements(); Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Progress! I've been able to trace through that init code, and I've found two roadblocks.
First, in ORBEON.xforms.Server.fireEvents(), window.setTimeout() is used to delay processing of the event. But according to my tracing, setTimeout() under HtmlUnit is not doing anything, or at least is not executing the provided function. So I commented out that block and replaced it with just ORBEON.xforms.Server.executeNextRequest(false); NOW HtmlUnit gets further. I can trace to the point where the Yahoo code sends the asynchronous request to /ops/xforms-server, and the request looks reasonable: <!DOCTYPE xxforms:event-request [<!ENTITY nbsp " ">]> <xxforms:event-request xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"> <xxforms:static-state>pers:8472AC0C-1B4F-AB2B-F678-66740B5C00E7</xxforms:static-state> <xxforms:dynamic-state>pers:55323B98-6FC7-38E1-31DC-D78EB41AE0F5</xxforms:dynamic-state> <xxforms:action> <xxforms:event name="xxforms-value-change-with-focus-change" source-control-id="xforms-element-3">xyz</xxforms:event> </xxforms:action> </xxforms:event-request> But nothing comes back. Or rather, the HtmlUnit page object isn't updated. So roadblock #2 is I still don't get the right answer. I'm going to talk to the HtmlUnit folks about setTimeout(), and also about the AjaxController capability they have for ensuring the test code waits for asynchronous requests. rodney |
Administrator
|
Rodney,
On Thu, Mar 27, 2008 at 2:39 PM, Rodney Gitzel <[hidden email]> wrote: > Progress! I've been able to trace through that init code, and I've found two > roadblocks. Good to hear that! > First, in ORBEON.xforms.Server.fireEvents(), window.setTimeout() is used to > delay processing of the event. For HtmlUnit, I imagine setTimeout() is a weird animal. We use it to introduce a small delay, either to get around bugs or "different implementations" in browsers (often related to event ordering), or to avoid sending multiple requests to the server while we could have waited just a little bit and sent one request with all the events. So in most of the cases, I think HtmlUnit could as well run the code right away, without waiting for the specified delay. But in many applications, setTimeout() is used to refresh the UI from time to time if something changed on the server. In those cases if you don't wait for the specified amount of time, you end up in an infinite loop. So I can understand why HtmlUnit just skips those calls to setTimeout(). Maybe what you could do is introduce a wrapper to setTimeout. In xforms.js that wrapper would be called instead of setTimeout, and it would either run the function directly if the user agent is HtmlUnit, or call the regular setTimeout otherwise. > NOW HtmlUnit gets further. I can trace to the point where the Yahoo code > sends the asynchronous request to /ops/xforms-server, and the request looks > reasonable: > > <!DOCTYPE xxforms:event-request [<!ENTITY nbsp " ">]> > <xxforms:event-request xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"> > > <xxforms:static-state>pers:8472AC0C-1B4F-AB2B-F678-66740B5C00E7</xxforms:static-state> > > <xxforms:dynamic-state>pers:55323B98-6FC7-38E1-31DC-D78EB41AE0F5</xxforms:dynamic-state> > <xxforms:action> > <xxforms:event name="xxforms-value-change-with-focus-change" > source-control-id="xforms-element-3">xyz</xxforms:event> > </xxforms:action> > </xxforms:event-request> > > But nothing comes back. Or rather, the HtmlUnit page object isn't updated. doesn't update? That makes a big difference :). Maybe tcpmon can tell. You'll let us know what your findings are! Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Alas, those problems were pretty much all red herrings, or were problems in v1.14 that had since been fixed. Or were the result of me just commenting too much stuff out! Oops... But I got passed them.
HtmlUnit 2.0 was released this week, yay! But it still has issues. Simply hitting the "xforms-hello" app triggers a seeming deadlock in the Javascript-handling code. See this thread for more info. I'll keep working with the HtmlUnit folks... Cheers. rodney |
Administrator
|
Thanks for the update Rodney!
-Erik On Apr 11, 2008, at 10:30 AM, Rodney Gitzel wrote: > > Alas, those problems were pretty much all red herrings, or were > problems in > v1.14 that had since been fixed. Or were the result of me just > commenting > too much stuff out! Oops... But I got passed them. > > HtmlUnit 2.0 was released this week, yay! But it still has > issues. Simply > hitting the "xforms-hello" app triggers a seeming deadlock in the > Javascript-handling code. See > http://www.nabble.com/SVN-2821---TransformerException-looking-for-stylesheet...-to16504442.html#a16576041 > this thread for more info. > > I'll keep working with the HtmlUnit folks... > > Cheers. > > rodney > > > -- > View this message in context: http://www.nabble.com/Javascript-error-when-using-HtmlUnit-tp16153154p16628169.html > Sent from the ObjectWeb OPS - Users mailing list archive at > Nabble.com. > > > -- > You receive this message as a subscriber of the [hidden email] > mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Free forum by Nabble | Edit this page |