diff --git a/modules/javafx.web/src/main/java/javafx/scene/web/WebEngine.java b/modules/javafx.web/src/main/java/javafx/scene/web/WebEngine.java index bb2f583a6a0..cd9a0cd4031 100644 --- a/modules/javafx.web/src/main/java/javafx/scene/web/WebEngine.java +++ b/modules/javafx.web/src/main/java/javafx/scene/web/WebEngine.java @@ -491,7 +491,7 @@ public final BooleanProperty javaScriptEnabledProperty() { * Location of the user stylesheet as a string URL. * *

This should be a local URL, i.e. either {@code 'data:'}, - * {@code 'file:'}, or {@code 'jar:'}. Remote URLs are not allowed + * {@code 'file:'}, {@code 'jar:'}, or {@code 'jrt:'}. Remote URLs are not allowed * for security reasons. * * @defaultValue null @@ -554,6 +554,7 @@ public final StringProperty userStyleSheetLocationProperty() { dataUrl = url; } else if (url.startsWith("file:") || url.startsWith("jar:") || + url.startsWith("jrt:") || url.startsWith("data:")) { try { diff --git a/modules/javafx.web/src/test/java/test/javafx/scene/web/MiscellaneousTest.java b/modules/javafx.web/src/test/java/test/javafx/scene/web/MiscellaneousTest.java index 4b69810cd86..3e3ca2b3429 100644 --- a/modules/javafx.web/src/test/java/test/javafx/scene/web/MiscellaneousTest.java +++ b/modules/javafx.web/src/test/java/test/javafx/scene/web/MiscellaneousTest.java @@ -473,4 +473,18 @@ void waitForCompletion() { assertNull(getEngine().executeScript("window.xmlDoc.body")); }); } + + @Test public void jrtCssFileIsNotRejected() { + submit(() -> { + try { + getEngine().setUserStyleSheetLocation("jrt:/javafx.web/html/imported-styles.css"); + } catch (IllegalArgumentException e) { + // A jrt file is supposed to be a valid argument + throw new AssertionError(e); + } catch (RuntimeException e) { + // The css file cannot be loaded in the tests (since they are not modularized). + // We thus simply ignore this exception here + } + }); + } }