diff --git a/impl/src/main/java/com/sun/faces/renderkit/html_basic/ButtonRenderer.java b/impl/src/main/java/com/sun/faces/renderkit/html_basic/ButtonRenderer.java index b2c2b4bf16..e851f26c04 100644 --- a/impl/src/main/java/com/sun/faces/renderkit/html_basic/ButtonRenderer.java +++ b/impl/src/main/java/com/sun/faces/renderkit/html_basic/ButtonRenderer.java @@ -171,29 +171,17 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce */ private static boolean wasClicked(FacesContext context, UIComponent component, String clientId) { - // Was our command the one that caused this submission? - // we don' have to worry about getting the value from request parameter - // because we just need to know if this command caused the submission. We - // can get the command name by calling currentValue. This way we can - // get around the IE bug. - if (clientId == null) { clientId = component.getClientId(context); } if (context.getPartialViewContext().isAjaxRequest()) { - return BEHAVIOR_SOURCE_PARAM.getValue(context).equals(clientId); + return RenderKitUtils.isPartialOrBehaviorAction(context, clientId); } else { Map requestParameterMap = context.getExternalContext().getRequestParameterMap(); if (requestParameterMap.get(clientId) == null) { - - // Check to see whether we've got an action event - // as a result of a partial/behavior postback. - if (RenderKitUtils.isPartialOrBehaviorAction(context, clientId)) { - return true; - } - + // Check to see whether we've got an action event from button of type="image" StringBuilder builder = new StringBuilder(clientId); String xValue = builder.append(".x").toString(); builder.setLength(clientId.length()); diff --git a/impl/src/main/java/com/sun/faces/util/HtmlUtils.java b/impl/src/main/java/com/sun/faces/util/HtmlUtils.java index 8018751faf..3bec9047a3 100644 --- a/impl/src/main/java/com/sun/faces/util/HtmlUtils.java +++ b/impl/src/main/java/com/sun/faces/util/HtmlUtils.java @@ -128,6 +128,10 @@ private static int writeTextChar(Writer out, boolean escapeUnicode, boolean esca // UNICODE entities: encode as needed nextIndex = _writeDecRef(out, buff, buffIndex, buffLength, ch); } else { + if (forXml && !isAllowedXmlCharacter(ch)) { + return buffIndex; + } + nextIndex = addToBuffer(out, buff, buffIndex, buffLength, ch); } } diff --git a/pom.xml b/pom.xml index 0d585b72ed..5f2ddaa5b1 100644 --- a/pom.xml +++ b/pom.xml @@ -51,6 +51,7 @@ impl action rest + test diff --git a/test/base/pom.xml b/test/base/pom.xml new file mode 100644 index 0000000000..0b19f63add --- /dev/null +++ b/test/base/pom.xml @@ -0,0 +1,60 @@ + + + + 4.0.0 + + + org.eclipse.mojarra.test + pom + 4.0.9-SNAPSHOT + + + base + jar + + Mojarra ${project.version} - INTEGRATION TESTS - ${project.artifactId} + + + + org.junit.jupiter + junit-jupiter + 5.10.3 + + + org.jboss.arquillian.junit5 + arquillian-junit5-container + 1.9.1.Final + + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven + 3.3.0 + + + org.seleniumhq.selenium + selenium-java + 4.23.0 + + + io.github.bonigarcia + webdrivermanager + 5.9.2 + + + diff --git a/test/base/src/main/java/org/eclipse/mojarra/test/base/BaseIT.java b/test/base/src/main/java/org/eclipse/mojarra/test/base/BaseIT.java new file mode 100644 index 0000000000..a4cc379052 --- /dev/null +++ b/test/base/src/main/java/org/eclipse/mojarra/test/base/BaseIT.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) Contributors to the Eclipse Foundation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-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: GPL-2.0 with Classpath-exception-2.0 which + * is available at https://openjdk.java.net/legal/gplv2+ce.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 or Apache-2.0 + */ +package org.eclipse.mojarra.test.base; + +import static java.lang.System.getProperty; +import static java.time.Duration.ofSeconds; +import static org.jboss.shrinkwrap.api.ShrinkWrap.create; + +import java.io.File; +import java.net.URL; +import java.util.UUID; +import java.util.function.BooleanSupplier; +import java.util.logging.Level; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.importer.ZipImporter; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.junit.jupiter.api.extension.ExtendWith; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.WebDriverWait; + +import io.github.bonigarcia.wdm.WebDriverManager; + +@ExtendWith(ArquillianExtension.class) +@TestInstance(Lifecycle.PER_CLASS) +public abstract class BaseIT { + + private WebDriver browser; + + @ArquillianResource + private URL baseURL; + + @Deployment(testable = false) + public static WebArchive createDeployment() { + String warFileName = getProperty("war.file.name") + ".war"; + return create(ZipImporter.class, warFileName) + .importFrom(new File("target/" + warFileName)) + .as(WebArchive.class); + } + + @BeforeAll + public void setup() { + String arquillianBrowser = System.getProperty("arquillian.browser"); + + switch (arquillianBrowser) { + case "chrome": + WebDriverManager.chromedriver().setup(); + ChromeDriver chrome = new ChromeDriver(new ChromeOptions().addArguments("--no-sandbox", "--headless")); + chrome.setLogLevel(Level.INFO); + browser = chrome; + break; + default: + throw new UnsupportedOperationException("arquillian.browser='" + arquillianBrowser + "' is not yet supported"); + } + + PageFactory.initElements(browser, this); + } + + @AfterAll + public void teardown() { + browser.quit(); + } + + protected void open(String resource) { + browser.get(baseURL + resource); + } + + protected String getPageSource() { + return browser.getPageSource(); + } + + protected void guardAjax(Runnable action) { + String uuid = UUID.randomUUID().toString(); + executeScript("window.$ajax = true; faces.ajax.addOnEvent(data => { if (data.status == 'complete') window.$ajax = '" + uuid + "'; })"); + action.run(); + waitUntil(() -> executeScript("return window.$ajax == '" + uuid + "' || (!window.$ajax && document.readyState == 'complete');")); + } + + @SuppressWarnings("unchecked") + private T executeScript(String script) { + return (T) ((JavascriptExecutor) browser).executeScript(script); + } + + private void waitUntil(BooleanSupplier predicate) { + new WebDriverWait(browser, ofSeconds(5)).until($ -> predicate.getAsBoolean()); + } +} diff --git a/test/issue5460/pom.xml b/test/issue5460/pom.xml new file mode 100644 index 0000000000..50c4f35a6c --- /dev/null +++ b/test/issue5460/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + + + org.eclipse.mojarra.test + pom + 4.0.9-SNAPSHOT + + + issue5460 + war + + Mojarra ${project.version} - INTEGRATION TESTS - ${project.artifactId} + + + + org.eclipse.mojarra.test + base + ${project.version} + test + + + diff --git a/test/issue5460/src/main/java/org/eclipse/mojarra/test/issue5460/Issue5460Bean.java b/test/issue5460/src/main/java/org/eclipse/mojarra/test/issue5460/Issue5460Bean.java new file mode 100644 index 0000000000..c06fc082fe --- /dev/null +++ b/test/issue5460/src/main/java/org/eclipse/mojarra/test/issue5460/Issue5460Bean.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) Contributors to the Eclipse Foundation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-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: GPL-2.0 with Classpath-exception-2.0 which + * is available at https://openjdk.java.net/legal/gplv2+ce.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 or Apache-2.0 + */ +package org.eclipse.mojarra.test.issue5460; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Named; + +@Named +@RequestScoped +public class Issue5460Bean { + + private String cc1; + private String cc2; + private String cc3; + private String cc4; + private String cc5; + private String cc6; + + public String getCc1() { + return cc1; + } + + public void setCc1(String cc1) { + this.cc1 = cc1; + } + + public String getCc2() { + return cc2; + } + + public void setCc2(String cc2) { + this.cc2 = cc2; + } + + public String getCc3() { + return cc3; + } + + public void setCc3(String cc3) { + this.cc3 = cc3; + } + + public String getCc4() { + return cc4; + } + + public void setCc4(String cc4) { + this.cc4 = cc4; + } + + public String getCc5() { + return cc5; + } + + public void setCc5(String cc5) { + this.cc5 = cc5; + } + + public String getCc6() { + return cc6; + } + + public void setCc6(String cc6) { + this.cc6 = cc6; + } +} diff --git a/test/issue5460/src/main/java/org/eclipse/mojarra/test/issue5460/Issue5460Component.java b/test/issue5460/src/main/java/org/eclipse/mojarra/test/issue5460/Issue5460Component.java new file mode 100644 index 0000000000..e60626463e --- /dev/null +++ b/test/issue5460/src/main/java/org/eclipse/mojarra/test/issue5460/Issue5460Component.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) Contributors to the Eclipse Foundation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-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: GPL-2.0 with Classpath-exception-2.0 which + * is available at https://openjdk.java.net/legal/gplv2+ce.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 or Apache-2.0 + */ +package org.eclipse.mojarra.test.issue5460; + +import jakarta.faces.component.FacesComponent; +import jakarta.faces.component.NamingContainer; +import jakarta.faces.component.UIInput; +import jakarta.faces.component.UINamingContainer; +import jakarta.faces.context.FacesContext; + +@FacesComponent("issue5460Component") +public class Issue5460Component extends UIInput implements NamingContainer { + + @Override + public String getFamily() { + return UINamingContainer.COMPONENT_FAMILY; + } + + @Override + public void decode(FacesContext context) { + Object value = getValue(); + setSubmittedValue(value == null ? "" : value); + super.decode(context); + } + + public String getAttributeResults() { + return getAttributes().get("required") + " " + getAttributes().get("styleClass"); + } +} diff --git a/test/issue5460/src/main/webapp/WEB-INF/web.xml b/test/issue5460/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..8784690178 --- /dev/null +++ b/test/issue5460/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,34 @@ + + + + + facesServlet + jakarta.faces.webapp.FacesServlet + 1 + + + facesServlet + *.xhtml + + \ No newline at end of file diff --git a/test/issue5460/src/main/webapp/issue5460.xhtml b/test/issue5460/src/main/webapp/issue5460.xhtml new file mode 100644 index 0000000000..756955e4a6 --- /dev/null +++ b/test/issue5460/src/main/webapp/issue5460.xhtml @@ -0,0 +1,55 @@ + + + + + issue5460 + + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + +
+
+
+ diff --git a/test/issue5460/src/main/webapp/resources/components/component.xhtml b/test/issue5460/src/main/webapp/resources/components/component.xhtml new file mode 100644 index 0000000000..6bd6f08e63 --- /dev/null +++ b/test/issue5460/src/main/webapp/resources/components/component.xhtml @@ -0,0 +1,42 @@ + + + + + + + + + + +
+ + + + + + +
+
+
diff --git a/test/issue5460/src/test/java/org/eclipse/mojarra/test/issue5460/Issue5460IT.java b/test/issue5460/src/test/java/org/eclipse/mojarra/test/issue5460/Issue5460IT.java new file mode 100644 index 0000000000..410a202281 --- /dev/null +++ b/test/issue5460/src/test/java/org/eclipse/mojarra/test/issue5460/Issue5460IT.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) Contributors to the Eclipse Foundation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-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: GPL-2.0 with Classpath-exception-2.0 which + * is available at https://openjdk.java.net/legal/gplv2+ce.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 or Apache-2.0 + */ +package org.eclipse.mojarra.test.issue5460; + +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.eclipse.mojarra.test.base.BaseIT; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +class Issue5460IT extends BaseIT { + + @FindBy(id = "form:cc1:required") + private WebElement cc1required; + + @FindBy(id = "form:cc1:valid") + private WebElement cc1valid; + + @FindBy(id = "form:cc1:message") + private WebElement cc1message; + + @FindBy(id = "form:cc1:attributeResults") + private WebElement cc1attributeResults; + + @FindBy(id = "form:cc2:required") + private WebElement cc2required; + + @FindBy(id = "form:cc2:valid") + private WebElement cc2valid; + + @FindBy(id = "form:cc2:message") + private WebElement cc2message; + + @FindBy(id = "form:cc2:attributeResults") + private WebElement cc2attributeResults; + + @FindBy(id = "form:cc3:required") + private WebElement cc3required; + + @FindBy(id = "form:cc3:valid") + private WebElement cc3valid; + + @FindBy(id = "form:cc3:message") + private WebElement cc3message; + + @FindBy(id = "form:cc3:attributeResults") + private WebElement cc3attributeResults; + + @FindBy(id = "form:cc4:required") + private WebElement cc4required; + + @FindBy(id = "form:cc4:valid") + private WebElement cc4valid; + + @FindBy(id = "form:cc4:message") + private WebElement cc4message; + + @FindBy(id = "form:cc4:attributeResults") + private WebElement cc4attributeResults; + + @FindBy(id = "form:cc5:required") + private WebElement cc5required; + + @FindBy(id = "form:cc5:valid") + private WebElement cc5valid; + + @FindBy(id = "form:cc5:message") + private WebElement cc5message; + + @FindBy(id = "form:cc5:attributeResults") + private WebElement cc5attributeResults; + + @FindBy(id = "form:cc6:required") + private WebElement cc6required; + + @FindBy(id = "form:cc6:valid") + private WebElement cc6valid; + + @FindBy(id = "form:cc6:message") + private WebElement cc6message; + + @FindBy(id = "form:cc6:attributeResults") + private WebElement cc6attributeResults; + + @FindBy(id = "form:submit") + private WebElement submit; + + /** + * https://github.com/eclipse-ee4j/mojarra/issues/5460 + * https://github.com/eclipse-ee4j/mojarra/issues/5417 + */ + @Test + void test() { + open("issue5460.xhtml"); + + assertAll( + () -> assertEquals("false", cc1required.getText()), () -> assertEquals("true", cc1valid.getText()), + () -> assertEquals("false defaultClass", cc1attributeResults.getText()), + () -> assertEquals("", cc1message.getText()), () -> assertEquals("false", cc2required.getText()), + () -> assertEquals("true", cc2valid.getText()), + () -> assertEquals("false randomClass", cc2attributeResults.getText()), + () -> assertEquals("", cc2message.getText()), () -> assertEquals("true", cc3required.getText()), + () -> assertEquals("true", cc3valid.getText()), + () -> assertEquals("true defaultClass", cc3attributeResults.getText()), + () -> assertEquals("", cc3message.getText()), () -> assertEquals("true", cc4required.getText()), + () -> assertEquals("true", cc4valid.getText()), + () -> assertEquals("true randomClass", cc4attributeResults.getText()), + () -> assertEquals("", cc4message.getText()), () -> assertEquals("true", cc5required.getText()), + () -> assertEquals("true", cc5valid.getText()), + () -> assertEquals("true defaultClass", cc5attributeResults.getText()), + () -> assertEquals("", cc5message.getText()), () -> assertEquals("true", cc6required.getText()), + () -> assertEquals("true", cc6valid.getText()), + () -> assertEquals("true randomClass", cc6attributeResults.getText()), + () -> assertEquals("", cc6message.getText()) + ); + + guardAjax(submit::click); + + assertAll( + () -> assertEquals("false", cc1required.getText()), () -> assertEquals("true", cc1valid.getText()), + () -> assertEquals("false defaultClass", cc1attributeResults.getText()), + () -> assertEquals("", cc1message.getText()), () -> assertEquals("false", cc2required.getText()), + () -> assertEquals("true", cc2valid.getText()), + () -> assertEquals("false randomClass", cc2attributeResults.getText()), + () -> assertEquals("", cc2message.getText()), () -> assertEquals("true", cc3required.getText()), + () -> assertEquals("false", cc3valid.getText()), + () -> assertEquals("true defaultClass", cc3attributeResults.getText()), + () -> assertEquals("form:cc3: Validation Error: Value is required.", cc3message.getText()), + () -> assertEquals("true", cc4required.getText()), () -> assertEquals("false", cc4valid.getText()), + () -> assertEquals("true randomClass", cc4attributeResults.getText()), + () -> assertEquals("form:cc4: Validation Error: Value is required.", cc4message.getText()), + () -> assertEquals("true", cc5required.getText()), () -> assertEquals("false", cc5valid.getText()), + () -> assertEquals("true defaultClass", cc5attributeResults.getText()), + () -> assertEquals("form:cc5: Validation Error: Value is required.", cc5message.getText()), + () -> assertEquals("true", cc6required.getText()), () -> assertEquals("false", cc6valid.getText()), + () -> assertEquals("true randomClass", cc6attributeResults.getText()), + () -> assertEquals("form:cc6: Validation Error: Value is required.", cc6message.getText()) + ); + } +} diff --git a/test/issue5464/pom.xml b/test/issue5464/pom.xml new file mode 100644 index 0000000000..086548c0f5 --- /dev/null +++ b/test/issue5464/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + + + org.eclipse.mojarra.test + pom + 4.0.9-SNAPSHOT + + + issue5464 + war + + Mojarra ${project.version} - INTEGRATION TESTS - ${project.artifactId} + + + + org.eclipse.mojarra.test + base + ${project.version} + test + + + diff --git a/test/issue5464/src/main/java/org/eclipse/mojarra/test/issue5464/Issue5464Bean.java b/test/issue5464/src/main/java/org/eclipse/mojarra/test/issue5464/Issue5464Bean.java new file mode 100644 index 0000000000..e112d31356 --- /dev/null +++ b/test/issue5464/src/main/java/org/eclipse/mojarra/test/issue5464/Issue5464Bean.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) Contributors to the Eclipse Foundation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-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: GPL-2.0 with Classpath-exception-2.0 which + * is available at https://openjdk.java.net/legal/gplv2+ce.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 or Apache-2.0 + */ +package org.eclipse.mojarra.test.issue5464; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Named; + +@Named +@RequestScoped +public class Issue5464Bean { + + private String input; + private String output; + + public void submit() { + output = "Result: " + input; + } + + public String getInput() { + return input; + } + + public void setInput(String input) { + this.input = input; + } + + public String getOutput() { + return output; + } +} diff --git a/test/issue5464/src/main/webapp/WEB-INF/web.xml b/test/issue5464/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..8784690178 --- /dev/null +++ b/test/issue5464/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,34 @@ + + + + + facesServlet + jakarta.faces.webapp.FacesServlet + 1 + + + facesServlet + *.xhtml + + \ No newline at end of file diff --git a/test/issue5464/src/main/webapp/issue5464.xhtml b/test/issue5464/src/main/webapp/issue5464.xhtml new file mode 100644 index 0000000000..cd60f8927c --- /dev/null +++ b/test/issue5464/src/main/webapp/issue5464.xhtml @@ -0,0 +1,42 @@ + + + + + issue5464 + + + +
+ +
+
+ + + +
+
+ +
+
+
+ diff --git a/test/issue5464/src/test/java/org/eclipse/mojarra/test/issue5464/Issue5464IT.java b/test/issue5464/src/test/java/org/eclipse/mojarra/test/issue5464/Issue5464IT.java new file mode 100644 index 0000000000..a53d5c4cd2 --- /dev/null +++ b/test/issue5464/src/test/java/org/eclipse/mojarra/test/issue5464/Issue5464IT.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) Contributors to the Eclipse Foundation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-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: GPL-2.0 with Classpath-exception-2.0 which + * is available at https://openjdk.java.net/legal/gplv2+ce.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 or Apache-2.0 + */ +package org.eclipse.mojarra.test.issue5464; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.eclipse.mojarra.test.base.BaseIT; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +class Issue5464IT extends BaseIT { + + @FindBy(id = "form:input") + private WebElement input; + + @FindBy(id = "form:submit") + private WebElement submit; + + @FindBy(id = "form:output") + private WebElement output; + + /** + * https://github.com/eclipse-ee4j/mojarra/issues/5464 + */ + @Test + void testFFFE() { + open("issue5464.xhtml"); + input.sendKeys("f\uFFFEoo"); + guardAjax(submit::click); + assertEquals("Result: foo", output.getText()); + } + + /** + * https://github.com/eclipse-ee4j/mojarra/issues/4516 + */ + @Test + void test000C() { + open("issue5464.xhtml"); + input.sendKeys("f\u000Coo"); + guardAjax(submit::click); + assertEquals("Result: foo", output.getText()); + } +} diff --git a/test/issue5488/pom.xml b/test/issue5488/pom.xml new file mode 100644 index 0000000000..8709a85197 --- /dev/null +++ b/test/issue5488/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + + + org.eclipse.mojarra.test + pom + 4.0.9-SNAPSHOT + + + issue5488 + war + + Mojarra ${project.version} - INTEGRATION TESTS - ${project.artifactId} + + + + org.eclipse.mojarra.test + base + ${project.version} + test + + + diff --git a/test/issue5488/src/main/java/org/eclipse/mojarra/test/issue5488/Issue5488Bean.java b/test/issue5488/src/main/java/org/eclipse/mojarra/test/issue5488/Issue5488Bean.java new file mode 100644 index 0000000000..d81d9dd42e --- /dev/null +++ b/test/issue5488/src/main/java/org/eclipse/mojarra/test/issue5488/Issue5488Bean.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) Contributors to the Eclipse Foundation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-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: GPL-2.0 with Classpath-exception-2.0 which + * is available at https://openjdk.java.net/legal/gplv2+ce.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 or Apache-2.0 + */ +package org.eclipse.mojarra.test.issue5488; + +import static jakarta.faces.component.UIComponent.getCurrentComponent; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.faces.application.FacesMessage; +import jakarta.faces.context.FacesContext; +import jakarta.inject.Named; + +@Named +@RequestScoped +public class Issue5488Bean { + + public void listener() { + addInvokedMessage("listener"); + } + + public void action() { + addInvokedMessage("action"); + } + + private static void addInvokedMessage(String methodName) { + FacesContext context = FacesContext.getCurrentInstance(); + context.addMessage(null, new FacesMessage(methodName + " invoked on " + getCurrentComponent(context).getClientId(context))); + } +} diff --git a/test/issue5488/src/main/webapp/WEB-INF/web.xml b/test/issue5488/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..8784690178 --- /dev/null +++ b/test/issue5488/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,34 @@ + + + + + facesServlet + jakarta.faces.webapp.FacesServlet + 1 + + + facesServlet + *.xhtml + + \ No newline at end of file diff --git a/test/issue5488/src/main/webapp/issue5488.xhtml b/test/issue5488/src/main/webapp/issue5488.xhtml new file mode 100644 index 0000000000..1b33c3c1a4 --- /dev/null +++ b/test/issue5488/src/main/webapp/issue5488.xhtml @@ -0,0 +1,54 @@ + + + + + issue5488 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/issue5488/src/test/java/org/eclipse/mojarra/test/issue5488/Issue5488IT.java b/test/issue5488/src/test/java/org/eclipse/mojarra/test/issue5488/Issue5488IT.java new file mode 100644 index 0000000000..5706e5e0cf --- /dev/null +++ b/test/issue5488/src/test/java/org/eclipse/mojarra/test/issue5488/Issue5488IT.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) Contributors to the Eclipse Foundation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-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: GPL-2.0 with Classpath-exception-2.0 which + * is available at https://openjdk.java.net/legal/gplv2+ce.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 or Apache-2.0 + */ +package org.eclipse.mojarra.test.issue5488; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.eclipse.mojarra.test.base.BaseIT; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +class Issue5488IT extends BaseIT { + + @FindBy(id = "form1:input") + private WebElement form1input; + + @FindBy(id = "form1:button") + private WebElement form1button; + + @FindBy(id = "form1:messages") + private WebElement form1messages; + + @FindBy(id = "form2:input") + private WebElement form2input; + + @FindBy(id = "form2:link") + private WebElement form2link; + + @FindBy(id = "form2:messages") + private WebElement form2messages; + + @FindBy(id = "form3:button1") + private WebElement form3button1; + + @FindBy(id = "form3:button2") + private WebElement form3button2; + + @FindBy(id = "form3:messages") + private WebElement form3messages; + + /** + * https://github.com/eclipse-ee4j/mojarra/issues/5488 + */ + @Test + void testCommandButtonBlurred() { + open("issue5488.xhtml"); + form1input.sendKeys(Keys.TAB); + guardAjax(() -> form1button.sendKeys(Keys.TAB)); + + var messages = form1messages.getText(); + assertEquals("listener invoked on form1:button", messages); // and thus not action invoked as well + } + + /** + * https://github.com/eclipse-ee4j/mojarra/issues/5488 + */ + @Test + void testCommandButtonClicked() { + open("issue5488.xhtml"); + guardAjax(form1button::click); + assertEquals("action invoked on form1:button", form1messages.getText()); // and thus not listener invoked as well + } + + /** + * https://github.com/eclipse-ee4j/mojarra/issues/5488 + */ + @Test + void testCommandLinkBlurred() { + open("issue5488.xhtml"); + form2input.sendKeys(Keys.TAB); + guardAjax(() -> form2link.sendKeys(Keys.TAB)); + assertEquals("listener invoked on form2:link", form2messages.getText()); // and thus not action invoked as well + } + + /** + * https://github.com/eclipse-ee4j/mojarra/issues/5488 + */ + @Test + void testCommandLinkClicked() { + open("issue5488.xhtml"); + guardAjax(form2link::click); + assertEquals("action invoked on form2:link", form2messages.getText()); // and thus not listener invoked as well + } + + /** + * https://github.com/eclipse-ee4j/mojarra/issues/3355 + */ + @Test + void testPlainButton1() { + open("issue5488.xhtml"); + guardAjax(form3button1::click); + assertEquals("listener invoked on form3:button1", form3messages.getText()); // and thus not on form3:button2 as well + } + + /** + * https://github.com/eclipse-ee4j/mojarra/issues/3355 + */ + @Test + void testPlainButton2() { + open("issue5488.xhtml"); + guardAjax(form3button2::click); + assertEquals("listener invoked on form3:button2", form3messages.getText()); // and thus not on form3:button1 as well + } +} diff --git a/test/pom.xml b/test/pom.xml new file mode 100644 index 0000000000..5c4dc262c4 --- /dev/null +++ b/test/pom.xml @@ -0,0 +1,197 @@ + + + + 4.0.0 + + + org.glassfish + mojarra-parent + 4.0.9-SNAPSHOT + + + org.eclipse.mojarra.test + pom + pom + + Mojarra ${project.version} - INTEGRATION TESTS + + + base + issue5460 + issue5464 + issue5488 + + + + 7.0.16 + chrome + + + + + jakarta.platform + jakarta.jakartaee-web-api + 10.0.0 + provided + + + org.junit.jupiter + junit-jupiter + 5.10.3 + test + + + org.jboss.arquillian.junit5 + arquillian-junit5-container + 1.8.0.Final + test + + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven + 3.3.0 + test + + + org.seleniumhq.selenium + selenium-java + 4.23.0 + test + + + io.github.bonigarcia + webdrivermanager + 5.9.2 + test + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.4.0 + + false + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.7.1 + + ${project.build.directory} + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.3.1 + + + + integration-test + verify + + + + + + ${arquillian.browser} + ${project.build.finalName} + + + + + + + + + glassfish + + true + + + + org.omnifaces.arquillian + arquillian-glassfish-server-managed + 1.4 + test + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack-glassfish + process-test-classes + + unpack + + + + + org.glassfish.main.distributions + glassfish + ${glassfish.version} + zip + + + + + + update-mojarra + process-test-classes + + copy + + + + + org.glassfish + jakarta.faces + ${project.version} + jar + true + ${project.build.directory}/glassfish7/glassfish/modules + jakarta.faces.jar + + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + ${project.build.directory}/glassfish7 + + + + + + + +