Skip to content

Commit 2aed5ad

Browse files
tobiasdiezkevinrushforth
authored andcommitted
8240969: WebView does not allow to load style sheet in modularized applications
Reviewed-by: kcr, ajoseph
1 parent 1c54e61 commit 2aed5ad

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

modules/javafx.web/src/main/java/javafx/scene/web/WebEngine.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ public final BooleanProperty javaScriptEnabledProperty() {
499499
* Location of the user stylesheet as a string URL.
500500
*
501501
* <p>This should be a local URL, i.e. either {@code 'data:'},
502-
* {@code 'file:'}, or {@code 'jar:'}. Remote URLs are not allowed
502+
* {@code 'file:'}, {@code 'jar:'}, or {@code 'jrt:'}. Remote URLs are not allowed
503503
* for security reasons.
504504
*
505505
* @defaultValue null
@@ -562,6 +562,7 @@ public final StringProperty userStyleSheetLocationProperty() {
562562
dataUrl = url;
563563
} else if (url.startsWith("file:") ||
564564
url.startsWith("jar:") ||
565+
url.startsWith("jrt:") ||
565566
url.startsWith("data:"))
566567
{
567568
try {

modules/javafx.web/src/test/java/test/javafx/scene/web/MiscellaneousTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,4 +472,18 @@ void waitForCompletion() {
472472
assertNull(getEngine().executeScript("window.xmlDoc.body"));
473473
});
474474
}
475+
476+
@Test public void jrtCssFileIsNotRejected() {
477+
submit(() -> {
478+
try {
479+
getEngine().setUserStyleSheetLocation("jrt:/javafx.web/html/imported-styles.css");
480+
} catch (IllegalArgumentException e) {
481+
// A jrt file is supposed to be a valid argument
482+
throw new AssertionError(e);
483+
} catch (RuntimeException e) {
484+
// The css file cannot be loaded in the tests (since they are not modularized).
485+
// We thus simply ignore this exception here
486+
}
487+
});
488+
}
475489
}

0 commit comments

Comments
 (0)