From 2aed5ad3e57cd8aa9875965d17eeb76e09dae13c Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 14 Aug 2020 20:22:07 +0000 Subject: [PATCH] 8240969: WebView does not allow to load style sheet in modularized applications Reviewed-by: kcr, ajoseph --- .../src/main/java/javafx/scene/web/WebEngine.java | 3 ++- .../test/javafx/scene/web/MiscellaneousTest.java | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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 7a443542a1b..0edd69e480a 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 @@ -499,7 +499,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 @@ -562,6 +562,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 18b30a8be6c..97da1611a27 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 @@ -472,4 +472,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 + } + }); + } }