From da3d8bee3c4fe5c097b8e83b75396c65caac0418 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 1 Jan 2015 11:26:17 +0200 Subject: Only split CssLayout styles at the first : character (#15490) Change-Id: Ifa5f3d3d583d6d32a50b69b3b59b141829293b37 --- .../client/ui/csslayout/CssLayoutConnector.java | 2 +- .../vaadin/tests/layouts/CssLayoutAbsoluteUrl.java | 38 +++++++++++++++++++++ .../tests/layouts/CssLayoutAbsoluteUrlTest.java | 39 ++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/layouts/CssLayoutAbsoluteUrl.java create mode 100644 uitest/src/com/vaadin/tests/layouts/CssLayoutAbsoluteUrlTest.java diff --git a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java index 16c80cfa15..a0ef1fbb3e 100644 --- a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java @@ -102,7 +102,7 @@ public class CssLayoutConnector extends AbstractLayoutConnector { // as it is added directly to the child component? String[] cssRules = css.split(";"); for (String cssRule : cssRules) { - String parts[] = cssRule.split(":"); + String parts[] = cssRule.split(":", 2); if (parts.length == 2) { style.setProperty(makeCamelCase(parts[0].trim()), parts[1].trim()); diff --git a/uitest/src/com/vaadin/tests/layouts/CssLayoutAbsoluteUrl.java b/uitest/src/com/vaadin/tests/layouts/CssLayoutAbsoluteUrl.java new file mode 100644 index 0000000000..e5430a09af --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/CssLayoutAbsoluteUrl.java @@ -0,0 +1,38 @@ +/* + * 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.layouts; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Component; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.Label; + +public class CssLayoutAbsoluteUrl extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Label label = new Label("Hello"); + label.setId("myLabel"); + addComponent(new CssLayout(label) { + @Override + protected String getCss(Component c) { + return "color: blue; background-image: url(\"about:blank\");"; + } + }); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/CssLayoutAbsoluteUrlTest.java b/uitest/src/com/vaadin/tests/layouts/CssLayoutAbsoluteUrlTest.java new file mode 100644 index 0000000000..1821acdbfa --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/CssLayoutAbsoluteUrlTest.java @@ -0,0 +1,39 @@ +/* + * 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.layouts; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class CssLayoutAbsoluteUrlTest extends SingleBrowserTest { + @Test + public void testAboutBlankStyle() { + openTestURL(); + + WebElement myLabel = findElement(By.id("myLabel")); + + String backgroundImage = myLabel.getCssValue("background-image"); + + // Not testing string equality since some browsers return the style with + // quotes around the url argument and some without quotes. + Assert.assertTrue(backgroundImage + " does not contain 'about:blank'", + backgroundImage.contains("about:blank")); + } +} -- cgit v1.2.3