You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by so...@apache.org on 2019/10/31 10:37:10 UTC

[wicket] branch master updated (0ba3ce0 -> 8f3421a)

This is an automated email from the ASF dual-hosted git repository.

solomax pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git.


    from 0ba3ce0  WICKET-6708 Made lowercase conversion local insentive, as did for WICKET-6614
     new b10e68a  [WICKET-6712] time zone is determined in browser
     new 31de443  Accidental copy/paste is removed
     new 8f3421a  Tests are improved, js calls are guarded

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../markup/html/pages/wicket-browser-info.js       |  5 +++
 .../wicket/protocol/http/ClientProperties.java     | 38 ++++++++++++++++------
 .../wicket/protocol/http/ClientPropertiesTest.java | 28 +++++++++++++++-
 3 files changed, 60 insertions(+), 11 deletions(-)


[wicket] 02/03: Accidental copy/paste is removed

Posted by so...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git

commit 31de4438b13cec9fcbb2b3b12045a2b9aa7f21f9
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Tue Oct 29 22:01:51 2019 +0700

    Accidental copy/paste is removed
---
 .../main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js | 1 -
 1 file changed, 1 deletion(-)

diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js b/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
index 07e8bb5..2118296 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
@@ -57,7 +57,6 @@
 					info.screenWidth = window.screen.width;
 					info.screenHeight = window.screen.height;
 					info.screenColorDepth = window.screen.colorDepth;
-					info.utcOffset = (new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0).getTimezoneOffset() / -60);
 				}
 				var jsTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
 				info.jsTimeZone = jsTimeZone ? jsTimeZone : null;;


[wicket] 03/03: Tests are improved, js calls are guarded

Posted by so...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git

commit 8f3421aceadaecc8dbe86ae40c83713461818f86
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Wed Oct 30 13:41:55 2019 +0700

    Tests are improved, js calls are guarded
---
 .../org/apache/wicket/markup/html/pages/wicket-browser-info.js     | 7 +++++--
 .../java/org/apache/wicket/protocol/http/ClientPropertiesTest.java | 2 --
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js b/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
index 2118296..10b0bcc 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
@@ -58,8 +58,11 @@
 					info.screenHeight = window.screen.height;
 					info.screenColorDepth = window.screen.colorDepth;
 				}
-				var jsTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
-				info.jsTimeZone = jsTimeZone ? jsTimeZone : null;;
+				if (Intl && typeof(Intl.DateTimeFormat) === 'function' &&
+						typeof(Intl.DateTimeFormat().resolvedOptions) === 'function') {
+					var jsTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
+					info.jsTimeZone = jsTimeZone ? jsTimeZone : null;
+				}
 				info.utcOffset = (new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0).getTimezoneOffset() / -60);
 				info.utcDSTOffset = (new Date(new Date().getFullYear(), 6, 1, 0, 0, 0, 0).getTimezoneOffset() / -60);
 				info.browserWidth =  window.innerWidth || document.body.offsetWidth;
diff --git a/wicket-core/src/test/java/org/apache/wicket/protocol/http/ClientPropertiesTest.java b/wicket-core/src/test/java/org/apache/wicket/protocol/http/ClientPropertiesTest.java
index f9057b4..1078973 100644
--- a/wicket-core/src/test/java/org/apache/wicket/protocol/http/ClientPropertiesTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/protocol/http/ClientPropertiesTest.java
@@ -157,8 +157,6 @@ class ClientPropertiesTest
 	void timezoneJsPositive()
 	{
 		ClientProperties props = new ClientProperties();
-		props.setUtcOffset("11");
-		props.setUtcDSTOffset("10");
 		props.setJsTimeZone("Asia/Novosibirsk");
 
 		assertEquals(TimeZone.getTimeZone("Asia/Novosibirsk"), props.getTimeZone());


[wicket] 01/03: [WICKET-6712] time zone is determined in browser

Posted by so...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git

commit b10e68a70dcede5c5a0ef0f1dd0fa3a3720b13d5
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Tue Oct 29 21:59:44 2019 +0700

    [WICKET-6712] time zone is determined in browser
---
 .../markup/html/pages/wicket-browser-info.js       |  3 ++
 .../wicket/protocol/http/ClientProperties.java     | 38 ++++++++++++++++------
 .../wicket/protocol/http/ClientPropertiesTest.java | 30 ++++++++++++++++-
 3 files changed, 60 insertions(+), 11 deletions(-)

diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js b/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
index cd0da94..07e8bb5 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
@@ -57,7 +57,10 @@
 					info.screenWidth = window.screen.width;
 					info.screenHeight = window.screen.height;
 					info.screenColorDepth = window.screen.colorDepth;
+					info.utcOffset = (new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0).getTimezoneOffset() / -60);
 				}
+				var jsTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
+				info.jsTimeZone = jsTimeZone ? jsTimeZone : null;;
 				info.utcOffset = (new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0).getTimezoneOffset() / -60);
 				info.utcDSTOffset = (new Date(new Date().getFullYear(), 6, 1, 0, 0, 0, 0).getTimezoneOffset() / -60);
 				info.browserWidth =  window.innerWidth || document.body.offsetWidth;
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java
index ff200a1..c16aa1e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java
@@ -38,17 +38,17 @@ import org.apache.wicket.util.string.AppendingStringBuffer;
  * <p>
  * A convenient way of letting Wicket do a sneaky redirect to {@link BrowserInfoPage} (and back
  * again) is to put this in your Application's init method:
- * 
+ *
  * <pre>
  * getRequestCycleSettings().setGatherExtendedBrowserInfo(true);
  * </pre>
- * 
+ *
  * </p>
- * 
+ *
  * WARNING: Be sure you think about the dangers of depending on information you pull from the client
  * too much. They may be easily spoofed or inaccurate in other ways, and properties like window and
  * browser size are all too easy to be used naively.
- * 
+ *
  * @see BrowserInfoPage
  * @author Frank Bille (frankbille)
  */
@@ -72,6 +72,7 @@ public class ClientProperties implements IClusterable
 	private int screenWidth = -1;
 	private String utcDSTOffset;
 	private String utcOffset;
+	private String jsTimeZone;
 	private String hostname;
 
 	private boolean javaScriptEnabled;
@@ -185,11 +186,19 @@ public class ClientProperties implements IClusterable
 
 	/**
 	 * Get the client's time zone if that could be detected.
-	 * 
+	 *
 	 * @return The client's time zone
 	 */
 	public TimeZone getTimeZone()
 	{
+		if (timeZone == null && jsTimeZone != null)
+		{
+			TimeZone temptimeZone = TimeZone.getTimeZone(jsTimeZone);
+			if (jsTimeZone.equals(temptimeZone.getID()))
+			{
+				timeZone = temptimeZone;
+			}
+		}
 		if (timeZone == null)
 		{
 			String utc = getUtcOffset();
@@ -331,7 +340,7 @@ public class ClientProperties implements IClusterable
 
 	/**
 	 * Flag indicating support of JavaScript in the browser.
-	 * 
+	 *
 	 * @return True if JavaScript is enabled
 	 */
 	public boolean isJavaScriptEnabled() {
@@ -339,8 +348,8 @@ public class ClientProperties implements IClusterable
 	}
 
 	/**
-	 * 
-	 * 
+	 *
+	 *
 	 * @return The client's navigator.cookieEnabled property.
 	 */
 	public boolean isNavigatorCookieEnabled()
@@ -498,7 +507,7 @@ public class ClientProperties implements IClusterable
 
 	/**
 	 * Sets time zone.
-	 * 
+	 *
 	 * @param timeZone
 	 */
 	public void setTimeZone(TimeZone timeZone)
@@ -525,6 +534,14 @@ public class ClientProperties implements IClusterable
 	}
 
 	/**
+	 * @param jsTimeZone
+	 */
+	public void setJsTimeZone(String jsTimeZone)
+	{
+		this.jsTimeZone = jsTimeZone;
+	}
+
+	/**
 	 * @param javaScriptEnabled
 	 *            is JavaScript supported in the browser
 	 */
@@ -591,7 +608,7 @@ public class ClientProperties implements IClusterable
 
 	/**
 	 * Read parameters.
-	 * 
+	 *
 	 * @param parameters
 	 *            parameters sent from browser
 	 */
@@ -610,6 +627,7 @@ public class ClientProperties implements IClusterable
 		setScreenColorDepth(parameters.getParameterValue("screenColorDepth").toInt(-1));
 		setUtcOffset(parameters.getParameterValue("utcOffset").toString(null));
 		setUtcDSTOffset(parameters.getParameterValue("utcDSTOffset").toString(null));
+		setJsTimeZone(parameters.getParameterValue("jsTimeZone").toString(null));
 		setBrowserWidth(parameters.getParameterValue("browserWidth").toInt(-1));
 		setBrowserHeight(parameters.getParameterValue("browserHeight").toInt(-1));
 		setHostname(parameters.getParameterValue("hostname").toString("N/A"));
diff --git a/wicket-core/src/test/java/org/apache/wicket/protocol/http/ClientPropertiesTest.java b/wicket-core/src/test/java/org/apache/wicket/protocol/http/ClientPropertiesTest.java
index f42785b..f9057b4 100644
--- a/wicket-core/src/test/java/org/apache/wicket/protocol/http/ClientPropertiesTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/protocol/http/ClientPropertiesTest.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
 
 /**
  * Tests for ClientProperties that failed on Mac OS X Java platform.
- * 
+ *
  * @author Martijn Dashorst
  */
 class ClientPropertiesTest
@@ -149,4 +149,32 @@ class ClientPropertiesTest
 
 		assertEquals(TimeZone.getTimeZone("AET"), props.getTimeZone());
 	}
+
+	/**
+	 * jsTimeZone "positive" test
+	 */
+	@Test
+	void timezoneJsPositive()
+	{
+		ClientProperties props = new ClientProperties();
+		props.setUtcOffset("11");
+		props.setUtcDSTOffset("10");
+		props.setJsTimeZone("Asia/Novosibirsk");
+
+		assertEquals(TimeZone.getTimeZone("Asia/Novosibirsk"), props.getTimeZone());
+	}
+
+	/**
+	 * jsTimeZone "negative" test
+	 */
+	@Test
+	void timezoneJsNegative()
+	{
+		ClientProperties props = new ClientProperties();
+		props.setUtcOffset("11");
+		props.setUtcDSTOffset("10");
+		props.setJsTimeZone("aaa");
+
+		assertEquals(TimeZone.getTimeZone("AET"), props.getTimeZone());
+	}
 }