aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/test
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2021-11-16 13:41:22 +0200
committerGitHub <noreply@github.com>2021-11-16 13:41:22 +0200
commit0195c63e0bde8f84b8544477507cbdd25ad22952 (patch)
treeec260ee80078aca76cead81767abfcf633cfba38 /server/src/test
parenta243a8ad2b9bdd49e155e921f7889133c41e6c99 (diff)
downloadvaadin-framework-0195c63e0bde8f84b8544477507cbdd25ad22952.tar.gz
vaadin-framework-0195c63e0bde8f84b8544477507cbdd25ad22952.zip
fix: Check if injected CSS String is already in the list of injected styles (#12479)
* Check if injected CSS String is already in the list of injected styles * Change to package for unit testing * Unit test * Add missing imports
Diffstat (limited to 'server/src/test')
-rw-r--r--server/src/test/java/com/vaadin/server/PageTest.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/server/src/test/java/com/vaadin/server/PageTest.java b/server/src/test/java/com/vaadin/server/PageTest.java
index adb9e93227..5ac4c5be14 100644
--- a/server/src/test/java/com/vaadin/server/PageTest.java
+++ b/server/src/test/java/com/vaadin/server/PageTest.java
@@ -1,7 +1,10 @@
package com.vaadin.server;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import java.io.Writer;
+
import org.easymock.EasyMock;
import org.junit.Test;
@@ -45,6 +48,27 @@ public class PageTest {
page.getState(false).hasResizeListeners);
}
+ @Test
+ public void cssStringInjectedTwice() throws PaintException {
+ TestPage page = new TestPage(EasyMock.createMock(UI.class),
+ EasyMock.createMock(PageState.class));
+ JsonPaintTarget paintTarget = new JsonPaintTarget(
+ EasyMock.createMock(LegacyCommunicationManager.class),
+ EasyMock.createMock(Writer.class), true);
+
+ page.getStyles().add(".my-style { color: red; }");
+ assertEquals(page.getStyles().pendingInjections.size(), 1);
+ page.paintContent(paintTarget);
+ assertEquals(page.getStyles().pendingInjections.size(), 0);
+ assertEquals(page.getStyles().injectedStyles.size(), 1);
+
+ page.getStyles().add(".my-style { color: red; }");
+ assertEquals(page.getStyles().pendingInjections.size(), 0);
+ page.paintContent(paintTarget);
+ assertEquals(page.getStyles().pendingInjections.size(), 0);
+ assertEquals(page.getStyles().injectedStyles.size(), 1);
+ }
+
private static class TestPage extends Page {
public TestPage(UI uI, PageState state) {