[ 
https://issues.apache.org/jira/browse/MYFACES-4498?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17637817#comment-17637817
 ] 

Werner Punz edited comment on MYFACES-4498 at 11/23/22 3:04 PM:
----------------------------------------------------------------

Error is reproducible with following unit test
{code:java}
it("head replacement must work 
(https://issues.apache.org/jira/browse/MYFACES-4498 and TCK Issue 4345IT)", 
function(done) {

  DQ.byId("cmd_complex_resource2").click();
  this.respond(XmlResponses.HEAD_REPLACE);
  let headHTML = document.head.innerHTML;          
  
expect(headHTML.indexOf("href=\"../../../xhrCore/fixtures/addedViewHead2.css\"")).not.eq(-1);
        expect(DQ$("head 
link[rel='stylesheet'][href='../../../xhrCore/fixtures/addedViewHead2.css']").length).to.eq(1);

  // failing now, no script elements in the html head after respond!!!
  
expect(headHTML.indexOf("../../../xhrCore/fixtures/addedViewHead3.js")).not.eq(-1);
})

static HEAD_REPLACE = `
<partial-response id="j_id__v_0">
<changes>
<update id="jakarta.faces.ViewHead">
    <![CDATA[
    <head>
        <script type="text/javascript" 
src="../../../xhrCore/fixtures/addedViewHead3.js"></script>
        <link rel="stylesheet" 
href="../../../xhrCore/fixtures/addedViewHead2.css"></link>
        <script type="text/javascript">
            setTimeout(() => 
document.getElementById('resource_area_1').innerHTML = 'booga', 1000);
        </script>
    </head>    
    ]]>
</update>
</changes>
</partial-response>
`
{code}


was (Author: werpu):
Error is reproducible with following unit test
{code:java}
it("head replacement must work 
(https://issues.apache.org/jira/browse/MYFACES-4498 and TCK Issue 4345IT)", 
function(done) {

  DQ.byId("cmd_complex_resource2").click();
  this.respond(XmlResponses.HEAD_REPLACE);
  let headHTML = document.head.innerHTML;          
  
expect(headHTML.indexOf("href=\"../../../xhrCore/fixtures/addedViewHead2.css\"")).not.eq(-1);
        expect(DQ$("head 
link[rel='stylesheet'][href='../../../xhrCore/fixtures/addedViewHead2.css']").length).to.eq(1);

    // failing now, no script elements in the html head after respond!!!
  
expect(headHTML.indexOf("../../../xhrCore/fixtures/addedViewHead3.js")).not.eq(-1);
})

static HEAD_REPLACE = `
<partial-response id="j_id__v_0">
<changes>
<update id="jakarta.faces.ViewHead">
    <![CDATA[
    <head>
        <script type="text/javascript" 
src="../../../xhrCore/fixtures/addedViewHead3.js"></script>
        <link rel="stylesheet" 
href="../../../xhrCore/fixtures/addedViewHead2.css"></link>
        <script type="text/javascript">
            setTimeout(() => 
document.getElementById('resource_area_1').innerHTML = 'booga', 1000);
        </script>
    </head>    
    ]]>
</update>
</changes>
</partial-response>
`
{code}

> TCK: Issue 4345 : Head Element Not Updated As Expected via Ajax Call
> --------------------------------------------------------------------
>
>                 Key: MYFACES-4498
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4498
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 4.0.0-RC2
>            Reporter: Volodymyr Siedlecki
>            Assignee: Werner Punz
>            Priority: Major
>         Attachments: test-faces22-ajax.war
>
>
> Test Code: 
> [https://github.com/jakartaee/faces/blob/4.0.1/tck/faces22/ajax/src/test/java/ee/jakarta/tck/faces/test/servlet30/ajax/Issue4345IT.java#L47]
> [https://github.com/jakartaee/faces/blob/4.0.1/tck/faces22/ajax/src/main/webapp/issue4345result.xhtml]
>  
> [https://github.com/jakartaee/faces/blob/4.0.1/tck/faces22/ajax/src/test/java/ee/jakarta/tck/faces/test/servlet30/ajax/Issue4345IT.java#L47]
> This test was created for ensure HTML is only escaped twice ([Issue 
> 4345|https://github.com/eclipse-ee4j/mojarra/issues/4345). However, MyFaces 
> is encountering two problems with this test.
> Firstly, here is the Ajax response and the updated HTML: 
> {code:java}
> <?xml version="1.0" encoding="UTF-8"?>
> <partial-response id="j_id__v_0">
>    <changes>
>       <update id="jakarta.faces.ViewRoot">
>          <![CDATA[<!--
>             Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights 
> reserved.
>             
>             This program and the accompanying materials are made available 
> under the
>             terms of the Eclipse Public License v. 2.0, which is available at
>             http://www.eclipse.org/legal/epl-2.0.
>             
>             This Source Code may also be made available under the following 
> Secondary
>             Licenses when the conditions for such availability set forth in 
> the
>             Eclipse Public License v. 2.0 are satisfied: GNU General Public 
> License,
>             version 2 with the GNU Classpath Exception, which is available at
>             https://www.gnu.org/software/classpath/license.html.
>             
>             SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH 
> Classpath-exception-2.0
>             
>             --><!DOCTYPE html>
>             <html xmlns="http://www.w3.org/1999/xhtml";><head>
>                 <!-- h:outputStylesheet does not support params in the URL, 
> so generate a similar link manually. -->
>                 <!--<h:outputStylesheet 
> name="issue4345.css?firstParam=1&amp;secondParam=2" />-->
>                 <link type="text/css" rel="stylesheet" 
> href="/test-faces22-ajax/jakarta.faces.resource/issue4345.css.xhtml?firstParam=1&amp;secondParam=2"
>  /><script type="text/javascript" 
> src="/test-faces22-ajax/jakarta.faces.resource/issue4345.js.xhtml?firstParam=1&amp;secondParam=2"></script></head><body></body>
>             </html>]]>
>       </update>
>       <update id="j_id__v_0:jakarta.faces.ViewState:1">
>          <![CDATA[ZmY2MjMxN2MxYTY3OTg1MTAwMDAwMDA0]]>
>       </update>
>    </changes>
> </partial-response> {code}
> The HTML is then set as : 
> {code:java}
> <html xmlns="http://www.w3.org/1999/xhtml";>
>    <head>
>       <style rel="stylesheet" type="text/css">@import 
> url('/test-faces22-ajax/jakarta.faces.resource/issue4345.css.xhtml?firstParam=1&secondParam=2');</style>
>    </head>
>    <body></body>
> </html>
>  {code}
> 1) We change from a link (type/css ) to a style tag that imports the URL? 
> Should that occur?  The JavaScript in issue4345result.xhtml specifically 
> looks for a link element. 
> 2) The script tags *are not appended* to the head element, but I do see 
> network requests for them. Additionally, the scripts do run (confirmed by the 
> console: "issue4345.js loaded." ). 
> This fails on both the RC2 scripts and the new TypeScript code. 
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to