Skip to content

Commit

Permalink
updated and use gwt-dom
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHossfeld committed May 18, 2018
1 parent 3b675f0 commit 7a4c843
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 92 deletions.
81 changes: 24 additions & 57 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.gwtproject</groupId>
<artifactId>gwt-safecss</artifactId>
<packaging>gwt-lib</packaging>
<version>1.0-SNAPSHOT</version>
<name>GWT Safe CSS</name>

<properties>
<!-- Convenience property to set the GWT version -->
<gwt.version>2.8.2</gwt.version>

<dom.version>1.0-SNAPSHOT</dom.version>
<safehtml.version>1.0-SNAPSHOT</safehtml.version>

<guava.version>25.0-jre</guava.version>
<junit.version>4.11</junit.version>

<!-- GWT 2.8 requires 1.8 -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- CI -->
<vertispan.snapshot.repo.id>vertispan-snapshot-repository</vertispan.snapshot.repo.id>
<vertispan.snapshot.repo.name>Vertispan Snapshot Repository</vertispan.snapshot.repo.name>
<vertispan.snapshot.repo.url>https://repo.vertispan.com/gwt-snapshot/</vertispan.snapshot.repo.url>
<vertispan.snapshot.repo.url>https://repo.vertispan.com/gwt-snapshot/
</vertispan.snapshot.repo.url>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
Expand All @@ -43,7 +44,7 @@
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.gwtproject.dom</groupId>
Expand All @@ -65,7 +66,7 @@
<artifactId>guava-gwt</artifactId>
<version>${guava.version}</version>
</dependency>

<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
Expand All @@ -74,7 +75,7 @@
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
</dependency>

<!-- only for test -->
<dependency>
<groupId>junit</groupId>
Expand All @@ -95,7 +96,7 @@
<target>${maven.compiler.target}</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand All @@ -116,28 +117,7 @@
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<excludes>
<exclude>**/client/*.java</exclude>
</excludes>
<excludedGroups>
org.gwtproject.safecss.SafeCssGwtSuite
</excludedGroups>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>


<plugin>
<!--
The integration-test phase runs after regular test phase (but before verify/install).
Expand All @@ -151,41 +131,28 @@
<include>**/*.class</include>
</includes>
<groups>
org.gwtproject.typedarrays.shared.IntegrationTest
org.gwtproject.safecss.shared.IntegrationTest
</groups>
</configuration>
</plugin>

<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0-rc-9</version>
<extensions>true</extensions>
<configuration>
<moduleName>org.gwtproject.safecss.SafeCss</moduleName>
<!--
Because we expressly disable asserts in tests to avoid a compiler bug, we also must run surefire manually
on the JRE tests
-->
<includes>
<include>**/SafeCssGwtSuite.java</include>
</includes>

<!-- disable JVM asserts, but enable JS asserts for tests -->
<enableAssertions>false</enableAssertions>
<testArgs>
<testArg>-checkAssertions</testArg>
</testArgs>
</configuration>
</configuration>
</plugin>
</plugins>
</build>

<distributionManagement>
<snapshotRepository>
<repositories>
<repository>
<id>${vertispan.snapshot.repo.id}</id>
<name>${vertispan.snapshot.repo.name}</name>
<url>${vertispan.snapshot.repo.url}</url>
</snapshotRepository>
</distributionManagement>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;

import org.gwtproject.safehtml.shared.annotations.GwtIncompatible;
import org.gwtproject.safecss.shared.annotations.GwtIncompatible;

import java.util.HashMap;
import java.util.Stack;
Expand Down Expand Up @@ -250,7 +250,7 @@ public static String isValidStyleValue(String value) {
*/
@GwtIncompatible
public static void maybeCheckValidStyleName(String name) {
if (isClient() || forceCheck) {
if (forceCheck) {
String errorText = isValidStyleName(name);
Preconditions.checkArgument(errorText == null, errorText);
} else {
Expand All @@ -267,7 +267,7 @@ public static void maybeCheckValidStyleName(String name) {
*/
@GwtIncompatible
public static void maybeCheckValidStyleValue(String value) {
if (isClient() || forceCheck) {
if (forceCheck) {
String errorText = isValidStyleValue(value);
Preconditions.checkArgument(errorText == null, errorText);
} else {
Expand Down Expand Up @@ -296,13 +296,4 @@ public static void setForceCheckValidStyle(boolean check) {
static void setForceCheckValidStyleFromProperty() {
forceCheck = System.getProperty(FORCE_CHECK_VALID_STYLES) != null;
}

@GwtIncompatible
private static boolean isClient() {
if (System.getProperty("superdevmode") == null) {
return false;
}
return System.getProperty("superdevmode").equals("on") || System.getProperty("superdevmode")
.equals("off");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.gwtproject.safecss.shared;

import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.client.GWTTestCase;

/**
Expand All @@ -31,7 +32,7 @@ public String getModuleName() {
}

public void testIsValidStyleName() {
if (isProdMode()) {
if (GWT.isProdMode()) {
// isValidStyleName always returns true in prod mode.
return;
}
Expand All @@ -50,7 +51,7 @@ public void testIsValidStyleName() {
}

public void testIsValidStyleValue() {
if (isProdMode()) {
if (GWT.isProdMode()) {
// isValidStyleValue always returns true in prod mode.
return;
}
Expand All @@ -69,7 +70,7 @@ public void testIsValidStyleValue() {
}

public void testMaybeCheckValidStyleName() {
if (isProdMode()) {
if (GWT.isProdMode()) {
/*
* SafeStylesHostedModeUtilsJvm.maybeCheckValidStyleName is a no-op in prod
* mode.
Expand Down Expand Up @@ -110,7 +111,7 @@ public void testMaybeCheckValidStyleName() {
}

public void testMaybeCheckValidStyleValue() {
if (isProdMode()) {
if (GWT.isProdMode()) {
/*
* SafeStylesHostedModeUtilsJvm.maybeCheckValidStyleValue is a no-op in prod
* mode.
Expand Down Expand Up @@ -149,9 +150,4 @@ public void testMaybeCheckValidStyleValue() {
}
}
}

private boolean isProdMode() {
return System.getProperty("superdevmode") != null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.gwtproject.safecss.shared;

import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.client.GWTTestCase;
import org.gwtproject.dom.client.Style.Clear;
import org.gwtproject.dom.client.Style.Display;
Expand Down Expand Up @@ -186,7 +187,7 @@ public void testFromTrustedNameAndValue() {
}

public void testFromTrustedNameAndValueInvalidName() {
if (!isClientMode()) {
if (GWT.isProdMode()) {
// fromTrustedNameAndValue only catches errors in dev mode.
return;
}
Expand All @@ -209,7 +210,7 @@ public void testFromTrustedNameAndValueInvalidName() {
}

public void testFromTrustedNameAndValueInvalidValue() {
if (!isClientMode()) {
if (GWT.isProdMode()) {
// fromTrustedNameAndValue only catches errors in dev mode.
return;
}
Expand All @@ -232,7 +233,7 @@ public void testFromTrustedNameAndValueInvalidValue() {
}

public void testFromTrustedNameAndValueValidName() {
if (!isClientMode()) {
if (GWT.isProdMode()) {
// fromTrustedNameAndValue only catches errors in dev mode.
return;
}
Expand All @@ -248,7 +249,7 @@ public void testFromTrustedNameAndValueValidName() {
}

public void testFromTrustedNameAndValueValidValue() {
if (isClientMode()) {
if (GWT.isProdMode()) {
// fromTrustedNameAndValue only catches errors in dev mode.
return;
}
Expand All @@ -271,10 +272,10 @@ private void assertEquals(String cssValue, SafeStyles safeStyles) {
assertEquals(cssValue, safeStyles.asString());
}

private boolean isClientMode() {
if (System.getProperty("superdevmode") == null) {
return false;
}
return System.getProperty("superdevmode").equals("on") || System.getProperty("superdevmode").equals("off");
}
// private boolean isClientMode() {
// if (System.getProperty("superdevmode") == null) {
// return false;
// }
// return System.getProperty("superdevmode").equals("on") || System.getProperty("superdevmode").equals("off");
// }
}
11 changes: 11 additions & 0 deletions src/test/java/org/gwtproject/safecss/shared/IntegrationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.gwtproject.safecss.shared;

/**
* Used to configure test executions that should come after regular tests.
*
* Note that we don't put the GWTTestCases in here because we want to run after them, so we can peak
* at the compiled output without having to bother with a second compilation.
*/
public interface IntegrationTest {

}
8 changes: 4 additions & 4 deletions src/test/resources/org/gwtproject/safecss/SafeCssTest.gwt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<!-- SafeCss - facilities for avoiding XSS attacks -->
<!-- -->
<module>
<inherits name="org.gwtproject.safecss.SafeCss"/>
<inherits name="org.gwtproject.dom.DOM"/>
<source path="shared"/>
<inherits name="org.gwtproject.safecss.SafeCss"/>
<inherits name="org.gwtproject.dom.DOM"/>

<source path="shared"/>
</module>

0 comments on commit 7a4c843

Please sign in to comment.