aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@gmail.com>2017-08-11 11:09:58 +0300
committerGitHub <noreply@github.com>2017-08-11 11:09:58 +0300
commit9a491b040d5c9d11e227acfdecfa867e5d7cf7d2 (patch)
tree7d65901005f9a8159533838e33b9442491f8cb98 /uitest
parente9316021b415e59120a186a649604bf8ecffc513 (diff)
downloadvaadin-framework-9a491b040d5c9d11e227acfdecfa867e5d7cf7d2.tar.gz
vaadin-framework-9a491b040d5c9d11e227acfdecfa867e5d7cf7d2.zip
Make CurrentTimeMillisTest more stable (#9812)
Sometimes Chrome reports 1ms for very short times to thwart timing attacks, and sometimes Firefox seems to report 0ms. Make the test accept these special cases. Add support for PhantomJS 2 which does support high res time.
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/test/java/com/vaadin/tests/CurrentTimeMillisTest.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/CurrentTimeMillisTest.java b/uitest/src/test/java/com/vaadin/tests/CurrentTimeMillisTest.java
index b703a3b2a5..2bfa1f9ad4 100644
--- a/uitest/src/test/java/com/vaadin/tests/CurrentTimeMillisTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/CurrentTimeMillisTest.java
@@ -40,8 +40,9 @@ public class CurrentTimeMillisTest extends MultiBrowserTest {
setDebug(true);
openTestURL();
- boolean highResTimeSupported = !BrowserUtil
- .isPhantomJS(getDesiredCapabilities())
+ boolean phantomJs1 = BrowserUtil.isPhantomJS(getDesiredCapabilities())
+ && "1".equals(getDesiredCapabilities().getVersion());
+ boolean highResTimeSupported = !phantomJs1
&& !BrowserUtil.isSafari(getDesiredCapabilities());
String time = getJsonParsingTime();
@@ -51,13 +52,15 @@ public class CurrentTimeMillisTest extends MultiBrowserTest {
time = time.substring(0, time.length() - 2);
}
if (highResTimeSupported) {
- if (BrowserUtil.isChrome(getDesiredCapabilities())) {
+ if (BrowserUtil.isChrome(getDesiredCapabilities())
+ || BrowserUtil.isFirefox(getDesiredCapabilities())) {
// Chrome (version 33 at least) sometimes doesn't use high res
- // time if number of ms is less then 1
+ // time for very short times
Assert.assertTrue(
"High resolution time is not used in "
+ "JSON parsing mesurement. Time=" + time,
- time.equals("0") || time.indexOf('.') > 0);
+ time.equals("0") || time.equals("1")
+ || time.indexOf('.') > 0);
} else {
Assert.assertTrue(
"High resolution time is not used in "