diff options
author | Mikael Grankvist <mgrankvi@vaadin.com> | 2014-06-19 09:31:19 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2014-06-26 12:04:25 +0000 |
commit | a685cc8a595509c707aa692d32b1daa2fea4ca57 (patch) | |
tree | d6151a0c838df8386bd360e66ddc1996615515a8 /uitest | |
parent | 1b73b00b2875c5eafa3c641b77f5d9efc2f7d929 (diff) | |
download | vaadin-framework-a685cc8a595509c707aa692d32b1daa2fea4ca57.tar.gz vaadin-framework-a685cc8a595509c707aa692d32b1daa2fea4ca57.zip |
IE11 now uses synchronous loading of script instead of async with preloading. (#13956)
Change-Id: Ia61d672a55f69326b37420305f0108f2d7443b70
Diffstat (limited to 'uitest')
5 files changed, 154 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java index d94518ca9c..e6e54a57a6 100644 --- a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java +++ b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java @@ -142,6 +142,7 @@ public class DevelopmentServerLauncher { assignDefault(serverArgs, "webroot", "WebContent"); assignDefault(serverArgs, "httpPort", "" + serverPort); assignDefault(serverArgs, "context", ""); + assignDefault(serverArgs, "slowdown", "/run/APP/PUBLISHED/js_label.js"); int port = serverPort; try { diff --git a/uitest/src/com/vaadin/tests/components/javascriptcomponent/JavaScriptPreloading.java b/uitest/src/com/vaadin/tests/components/javascriptcomponent/JavaScriptPreloading.java new file mode 100644 index 0000000000..e4fd3fec68 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/javascriptcomponent/JavaScriptPreloading.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.javascriptcomponent; + +import com.vaadin.annotations.JavaScript; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.JavaScriptComponentState; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.AbstractJavaScriptComponent; + +public class IEJavaScriptPreloading extends AbstractTestUI { + + public static class JsLabelState extends JavaScriptComponentState { + public String xhtml; + } + + @JavaScript({ "js_label.js", "wholly_different.js" }) + public class JsLabel extends AbstractJavaScriptComponent { + + public JsLabel(final String xhtml) { + getState().xhtml = xhtml; + } + + @Override + protected JsLabelState getState() { + return (JsLabelState) super.getState(); + } + } + + private final Log log = new Log(5); + + @Override + protected void setup(VaadinRequest request) { + addComponent(log); + + final JsLabel c = new JsLabel("Hello World!"); + c.setId("js-component"); + addComponent(c); + } + + @Override + protected String getTestDescription() { + return "Loading javascript component with multiple sourcefiles should not break IE11"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(13956); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/javascriptcomponent/JavaScriptPreloadingTest.java b/uitest/src/com/vaadin/tests/components/javascriptcomponent/JavaScriptPreloadingTest.java new file mode 100644 index 0000000000..a9e7a1bca7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/javascriptcomponent/JavaScriptPreloadingTest.java @@ -0,0 +1,74 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.javascriptcomponent; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.Alert; +import org.openqa.selenium.TimeoutException; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class JavaScriptPreloadingTest extends MultiBrowserTest { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.tb3.MultiBrowserTest#getBrowsersToTest() + */ + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + List<DesiredCapabilities> browsers = super.getBrowsersToTest(); + browsers.remove(Browser.PHANTOMJS.getDesiredCapabilities()); + return browsers; + } + + @Test + public void scriptsShouldPreloadAndExecuteInCorrectOrder() + throws InterruptedException { + openTestURL(); + + try { + new WebDriverWait(driver, 10).until(ExpectedConditions + .alertIsPresent()); + Alert alert = driver.switchTo().alert(); + assertEquals("First", alert.getText()); + alert.accept(); + + new WebDriverWait(driver, 10).until(ExpectedConditions + .alertIsPresent()); + alert = driver.switchTo().alert(); + assertEquals("Second", alert.getText()); + alert.accept(); + + } catch (TimeoutException te) { + fail("@Javascript widget loading halted."); + } + + } +} diff --git a/uitest/src/com/vaadin/tests/components/javascriptcomponent/js_label.js b/uitest/src/com/vaadin/tests/components/javascriptcomponent/js_label.js new file mode 100755 index 0000000000..c4900daa81 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/javascriptcomponent/js_label.js @@ -0,0 +1,11 @@ +window.com_vaadin_tests_components_javascriptcomponent_JavaScriptPreloading_JsLabel = function() { + var e = this.getElement(); + + (function() { + e.innerHTML = "Widget executed javascript"; + })(); +}; + +(function() { + window.alert("First"); +})(); diff --git a/uitest/src/com/vaadin/tests/components/javascriptcomponent/wholly_different.js b/uitest/src/com/vaadin/tests/components/javascriptcomponent/wholly_different.js new file mode 100755 index 0000000000..f22ef13a76 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/javascriptcomponent/wholly_different.js @@ -0,0 +1,3 @@ +(function() { + window.alert("Second"); +})(); |