You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Michael Concini (JIRA)" <de...@myfaces.apache.org> on 2010/06/09 17:29:14 UTC
[jira] Created: (MYFACES-2748) NPE in htmlunit when testing ajax
rendering
NPE in htmlunit when testing ajax rendering
-------------------------------------------
Key: MYFACES-2748
URL: https://issues.apache.org/jira/browse/MYFACES-2748
Project: MyFaces Core
Issue Type: Bug
Components: JSR-314
Affects Versions: 2.0.1-SNAPSHOT
Reporter: Michael Concini
When attempting to run some simple ajax tests using htmlunit, we're seeing some NPEs when running in the default (IE) client mode. As before with MYFACES-2745 this looks like its a bug in htmlunit, however these test cases had been passing on the MyFaces 2.0.0 release so something that is going on with the new javascript must be triggering the bug. I've validated in IE8, Firefox 3.6 and Chrome that this is being rendered properly in a live browser session as well as that it works if you initialize the htmlunit with new WebClient(BrowserVersion.FIREFOX_3).
Here's a simple example of a failing case. Its just executes an increment action on a counter var and uses f:ajax to re-render an outputText field.
<h:form id="form1" prependId="false">
<h:outputText id="out1" value="#{incrementdecrement.value}"/>
<br/>
<h:commandButton id="button1" value="Count" action="#{incrementdecrement.increment}" >
<f:ajax render="out1" disabled="false" />
</h:commandButton>
<br/>
</h:form>
After doing some debugging, htmlunit doesn't seem to be handling the partial page update. Instead of updating the span value for "out1", it is actually removing it from the idMap for the page. So if you try to validate the value of "out1" has been incremented, you'll get an NPE since the element is no longer on the idMap.
WebClient webClient = new WebClient();
HtmlPage page = (HtmlPage) webClient.getPage ("http://localhost:8080/JSF20AJAXTag/DisabledFalse.jsf");
String buttonId = "button1";
doClick(page,buttonId);
Assert.assertEquals( "1", page.getElementById ("out1").getTextContent());
The NPE is coming from trying to execute getTextContent() when page.getElementById("out1") is returning null.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (MYFACES-2748) NPE in htmlunit when
testing ajax rendering
Posted by "Werner Punz (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/MYFACES-2748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877108#action_12877108 ]
Werner Punz edited comment on MYFACES-2748 at 6/9/10 11:41 AM:
---------------------------------------------------------------
Ok this is an issue Leonardo discovered yesterday. The reason is, I slightly changed the dom replacement code for 2.0.1 so that the lifecycle behavior is absolutely identical over all browsers (before it was suboptimal in certainb browsers by keeping the elements double)
The problem here is some IE6 fixup code which enforces that all script tags are properly evaled (which ie6 swallows under certain tag combinations). The main issue there is that HTMLUnit by masking itself as IE runs into this fixup code for IE6 which then returns a null element, and triggers this issue.
We will fix this issue probably tomorrow (given my workload and timeframe) maybe earlier if Leonard is able to do a quick fix before me.
was (Author: werpu):
Ok this is an issue Leonardo discovered yesterday. The reason is, I slightly changed the dom replacement code for 2.0.1 so that the lifecycle behavior is absolutely identical over all browsers (before it was suboptimal in certainb browsers by keeping the elements double)
The problem here is some IE6 fixup code which enforces that all script tags are properly evaled (which ie swallows under certain conditions). The main issue there is that HTMLUnit by maskint itself as IE runs into this fixup code for IE6 which then returns a null element, and triggers this issue.
We will fix this issue probably tomorrow (given my workload and timeframe) maybe earlier if Leonard is able to do a quick fix before me.
> NPE in htmlunit when testing ajax rendering
> -------------------------------------------
>
> Key: MYFACES-2748
> URL: https://issues.apache.org/jira/browse/MYFACES-2748
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-314
> Affects Versions: 2.0.1-SNAPSHOT
> Reporter: Michael Concini
>
> When attempting to run some simple ajax tests using htmlunit, we're seeing some NPEs when running in the default (IE) client mode. As before with MYFACES-2745 this looks like its a bug in htmlunit, however these test cases had been passing on the MyFaces 2.0.0 release so something that is going on with the new javascript must be triggering the bug. I've validated in IE8, Firefox 3.6 and Chrome that this is being rendered properly in a live browser session as well as that it works if you initialize the htmlunit with new WebClient(BrowserVersion.FIREFOX_3).
> Here's a simple example of a failing case. Its just executes an increment action on a counter var and uses f:ajax to re-render an outputText field.
> <h:form id="form1" prependId="false">
> <h:outputText id="out1" value="#{incrementdecrement.value}"/>
> <br/>
> <h:commandButton id="button1" value="Count" action="#{incrementdecrement.increment}" >
> <f:ajax render="out1" disabled="false" />
> </h:commandButton>
> <br/>
> </h:form>
> After doing some debugging, htmlunit doesn't seem to be handling the partial page update. Instead of updating the span value for "out1", it is actually removing it from the idMap for the page. So if you try to validate the value of "out1" has been incremented, you'll get an NPE since the element is no longer on the idMap.
> WebClient webClient = new WebClient();
> HtmlPage page = (HtmlPage) webClient.getPage ("http://localhost:8080/JSF20AJAXTag/DisabledFalse.jsf");
> String buttonId = "button1";
> doClick(page,buttonId);
>
> Assert.assertEquals( "1", page.getElementById ("out1").getTextContent());
> The NPE is coming from trying to execute getTextContent() when page.getElementById("out1") is returning null.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MYFACES-2748) NPE in htmlunit when testing ajax
rendering
Posted by "Werner Punz (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/MYFACES-2748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877108#action_12877108 ]
Werner Punz commented on MYFACES-2748:
--------------------------------------
Ok this is an issue Leonardo discovered yesterday. The reason is, I slightly changed the dom replacement code for 2.0.1 so that the lifecycle behavior is absolutely identical over all browsers (before it was suboptimal in certainb browsers by keeping the elements double)
The problem here is some IE6 fixup code which enforces that all script tags are properly evaled (which ie swallows under certain conditions). The main issue there is that HTMLUnit by maskint itself as IE runs into this fixup code for IE6 which then returns a null element, and triggers this issue.
We will fix this issue probably tomorrow (given my workload and timeframe) maybe earlier if Leonard is able to do a quick fix before me.
> NPE in htmlunit when testing ajax rendering
> -------------------------------------------
>
> Key: MYFACES-2748
> URL: https://issues.apache.org/jira/browse/MYFACES-2748
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-314
> Affects Versions: 2.0.1-SNAPSHOT
> Reporter: Michael Concini
>
> When attempting to run some simple ajax tests using htmlunit, we're seeing some NPEs when running in the default (IE) client mode. As before with MYFACES-2745 this looks like its a bug in htmlunit, however these test cases had been passing on the MyFaces 2.0.0 release so something that is going on with the new javascript must be triggering the bug. I've validated in IE8, Firefox 3.6 and Chrome that this is being rendered properly in a live browser session as well as that it works if you initialize the htmlunit with new WebClient(BrowserVersion.FIREFOX_3).
> Here's a simple example of a failing case. Its just executes an increment action on a counter var and uses f:ajax to re-render an outputText field.
> <h:form id="form1" prependId="false">
> <h:outputText id="out1" value="#{incrementdecrement.value}"/>
> <br/>
> <h:commandButton id="button1" value="Count" action="#{incrementdecrement.increment}" >
> <f:ajax render="out1" disabled="false" />
> </h:commandButton>
> <br/>
> </h:form>
> After doing some debugging, htmlunit doesn't seem to be handling the partial page update. Instead of updating the span value for "out1", it is actually removing it from the idMap for the page. So if you try to validate the value of "out1" has been incremented, you'll get an NPE since the element is no longer on the idMap.
> WebClient webClient = new WebClient();
> HtmlPage page = (HtmlPage) webClient.getPage ("http://localhost:8080/JSF20AJAXTag/DisabledFalse.jsf");
> String buttonId = "button1";
> doClick(page,buttonId);
>
> Assert.assertEquals( "1", page.getElementById ("out1").getTextContent());
> The NPE is coming from trying to execute getTextContent() when page.getElementById("out1") is returning null.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (MYFACES-2748) NPE in htmlunit when testing ajax
rendering
Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/MYFACES-2748?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Leonardo Uribe resolved MYFACES-2748.
-------------------------------------
Assignee: Leonardo Uribe
Fix Version/s: 2.0.1
Resolution: Fixed
The problem with this issue is that IE 6 create this node hierarchy:
table -> tbody -> td ->content
but htmlunit does not (which is right). The solution proposed by Werner is calculate how far the algorithm should go into the nodes before replace, to prevent the problem with htmlunit or other browsers that are non w3c compliant.
Thanks to Werner for its help in solve this one.
> NPE in htmlunit when testing ajax rendering
> -------------------------------------------
>
> Key: MYFACES-2748
> URL: https://issues.apache.org/jira/browse/MYFACES-2748
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-314
> Affects Versions: 2.0.1-SNAPSHOT
> Reporter: Michael Concini
> Assignee: Leonardo Uribe
> Fix For: 2.0.1
>
>
> When attempting to run some simple ajax tests using htmlunit, we're seeing some NPEs when running in the default (IE) client mode. As before with MYFACES-2745 this looks like its a bug in htmlunit, however these test cases had been passing on the MyFaces 2.0.0 release so something that is going on with the new javascript must be triggering the bug. I've validated in IE8, Firefox 3.6 and Chrome that this is being rendered properly in a live browser session as well as that it works if you initialize the htmlunit with new WebClient(BrowserVersion.FIREFOX_3).
> Here's a simple example of a failing case. Its just executes an increment action on a counter var and uses f:ajax to re-render an outputText field.
> <h:form id="form1" prependId="false">
> <h:outputText id="out1" value="#{incrementdecrement.value}"/>
> <br/>
> <h:commandButton id="button1" value="Count" action="#{incrementdecrement.increment}" >
> <f:ajax render="out1" disabled="false" />
> </h:commandButton>
> <br/>
> </h:form>
> After doing some debugging, htmlunit doesn't seem to be handling the partial page update. Instead of updating the span value for "out1", it is actually removing it from the idMap for the page. So if you try to validate the value of "out1" has been incremented, you'll get an NPE since the element is no longer on the idMap.
> WebClient webClient = new WebClient();
> HtmlPage page = (HtmlPage) webClient.getPage ("http://localhost:8080/JSF20AJAXTag/DisabledFalse.jsf");
> String buttonId = "button1";
> doClick(page,buttonId);
>
> Assert.assertEquals( "1", page.getElementById ("out1").getTextContent());
> The NPE is coming from trying to execute getTextContent() when page.getElementById("out1") is returning null.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MYFACES-2748) NPE in htmlunit when testing ajax
rendering
Posted by "Werner Punz (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/MYFACES-2748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877368#action_12877368 ]
Werner Punz commented on MYFACES-2748:
--------------------------------------
A last comment on this issue, this bug only affected IE and only did so for the IE simulation of html unit.
The root cause of this bug was following IE bug http://blogs.perl.org/users/clinton_gormley/2010/02/forcing-ie-to-accept-script-tags-in-innerhtml.html
This bug only can occur in certain corner cases and afair also 2.0.0 was affected which did not use innerHTML but used fragments instead (I moved over to innerHTML because it is well supported in IE and faster and provided a lifecycle which was closer to the contextual ranges we have for more W3C compliant browsers.
The reason why we did not stumble over it was simply that we had no testing cases which triggered it, my cross form submit testing revealed it, because it only happens in certain dom combinations which are relatively rare and probably should not occur at existing usecases.
However the problem with the proposed approach from clinton_gormley is that the wrapping in forms does not work out for certain corner cases which have forms embedded so I moved over to a table based approach, which then broke in htmlUnit (I have to investigate if the deep scan can be eliminited by adding more elements, but that is not the scope of 2.0.1 anymore)
The good thing is since the entire operation of replacement is encapsulated into a single outerHTML replacement method, we always can relatively swiftly switch to a different approach.
(one of the advantages of the code cleanup I did of between 2.0.0 - 2.0.1 the code is way more maintainable and structured)
> NPE in htmlunit when testing ajax rendering
> -------------------------------------------
>
> Key: MYFACES-2748
> URL: https://issues.apache.org/jira/browse/MYFACES-2748
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-314
> Affects Versions: 2.0.1-SNAPSHOT
> Reporter: Michael Concini
> Assignee: Leonardo Uribe
> Fix For: 2.0.1
>
>
> When attempting to run some simple ajax tests using htmlunit, we're seeing some NPEs when running in the default (IE) client mode. As before with MYFACES-2745 this looks like its a bug in htmlunit, however these test cases had been passing on the MyFaces 2.0.0 release so something that is going on with the new javascript must be triggering the bug. I've validated in IE8, Firefox 3.6 and Chrome that this is being rendered properly in a live browser session as well as that it works if you initialize the htmlunit with new WebClient(BrowserVersion.FIREFOX_3).
> Here's a simple example of a failing case. Its just executes an increment action on a counter var and uses f:ajax to re-render an outputText field.
> <h:form id="form1" prependId="false">
> <h:outputText id="out1" value="#{incrementdecrement.value}"/>
> <br/>
> <h:commandButton id="button1" value="Count" action="#{incrementdecrement.increment}" >
> <f:ajax render="out1" disabled="false" />
> </h:commandButton>
> <br/>
> </h:form>
> After doing some debugging, htmlunit doesn't seem to be handling the partial page update. Instead of updating the span value for "out1", it is actually removing it from the idMap for the page. So if you try to validate the value of "out1" has been incremented, you'll get an NPE since the element is no longer on the idMap.
> WebClient webClient = new WebClient();
> HtmlPage page = (HtmlPage) webClient.getPage ("http://localhost:8080/JSF20AJAXTag/DisabledFalse.jsf");
> String buttonId = "button1";
> doClick(page,buttonId);
>
> Assert.assertEquals( "1", page.getElementById ("out1").getTextContent());
> The NPE is coming from trying to execute getTextContent() when page.getElementById("out1") is returning null.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.