Skip to content

Commit

Permalink
ZK-5546: Websocket endpoint doesn't trigger timeout-uri redirect afte…
Browse files Browse the repository at this point in the history
…r desktop timeout
  • Loading branch information
jumperchen authored and rebecca0201 committed Oct 7, 2024
1 parent 83fc72b commit aa99a6d
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions zkdoc/release-note
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ZK 10.1.0
ZK-5798: Client MVVM: Content missing in Include
ZK-5799: Javascript error when using Pdfviewer in Client MVVM
ZK-5801: Client MVVM: switching apply template causing javascript error
ZK-5546: Websocket endpoint doesn't trigger timeout-uri redirect after desktop timeout

* Upgrade Notes
+ Remove Htmls.encodeJavaScript(), Strings.encodeJavaScript(), Strings.escape() with Strings.ESCAPE_JAVASCRIPT, and replace them with OWASP Java Encoder APIs instead.
Expand Down
12 changes: 12 additions & 0 deletions zktest/src/main/webapp/test2/B101-ZK-5546-zk.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<zk>
<listener>
<listener-class>org.zkoss.zkmax.au.websocket.WebSocketWebAppInit</listener-class>
</listener>

<session-config>
<max-desktops-per-session>1</max-desktops-per-session>
<automatic-timeout/>
<timeout-uri>/timeout.zul</timeout-uri>
</session-config>
</zk>
33 changes: 33 additions & 0 deletions zktest/src/main/webapp/test2/B101-ZK-5546.zul
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
B101-ZK-5546.zul
Purpose:
Description:
History:
2024/10/7, Created by jumperchen
Copyright (C) 2024 Potix Corporation. All Rights Reserved.
-->
<zk>
<label multiline="true"><![CDATA[
1. Add the following configuration to zk.xml
<listener>
<listener-class&amp;amp;gt;org.zkoss.zkmax.au.websocket.WebSocketWebAppInit</listener-class&amp;amp;gt;
</listener>
<session-config>
<max-desktops-per-session>1</max-desktops-per-session>
<automatic-timeout/>
<timeout-uri>/timeout.zul</timeout-uri>
</session-config>
2. Open a browser tab to visit this page.
3. Open another browser tab to visit this page.
4. Make an action in the first tab (click a button, etc) with an event listener
]]></label>
<button label="Click me to test" onClick='Clients.log("Test")'/>
</zk>
1 change: 1 addition & 0 deletions zktest/src/main/webapp/test2/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3149,6 +3149,7 @@ B90-ZK-4431.zul=A,E,Multislider
##zats##B101-ZK-5798.zul=A,E,ClientMVVM,Include
##zats##B101-ZK-5799.zul=A,E,ClientMVVM,pdfviewer,zonejs
##manually##B101-ZK-5801.zul=A,E,ClientMVVM,Apply
##zats##B101-ZK-5546.zul=A,E,Websocket,Session,Timeout

##
# Features - 3.0.x version
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* B101_ZK_5546Test.java
Purpose:
Description:
History:
2:15 PM 2024/10/7, Created by jumperchen
Copyright (C) 2024 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.zktest.zats.test2;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openqa.selenium.WindowType;

import org.zkoss.test.webdriver.ExternalZkXml;
import org.zkoss.test.webdriver.ForkJVMTestOnly;
import org.zkoss.test.webdriver.WebDriverTestCase;

/**
* @author jumperchen
*/
@ForkJVMTestOnly
public class B101_ZK_5546Test extends WebDriverTestCase {
@RegisterExtension
public static final ExternalZkXml CONFIG = new ExternalZkXml(B101_ZK_5546Test.class);

@Test
public void test() {
connect();
waitResponse();
driver.switchTo().newWindow(WindowType.TAB);
driver.get(getAddress() + "/test2/B101-ZK-5546.zul");
Object[] windowHandles = driver.getWindowHandles().toArray();
driver.switchTo().window((String) windowHandles[0]);
click(jq("@button"));
waitResponse();
assertThat(driver.getCurrentUrl(), endsWith("timeout.zul"));
}
}

0 comments on commit aa99a6d

Please sign in to comment.