Details
-
Bug
-
Resolution: Fixed
-
P3
-
jfx15, jfx16
-
generic
-
generic
-
Verified
Description
ADDITIONAL SYSTEM INFORMATION :
Any OS. OpenJDK 15 with JavaFX 15.
A DESCRIPTION OF THE PROBLEM :
WebView can load local, "file:///", HTML page but when such page is styled by a local, "file:///", CSS stylesheet, this CSS stylesheet is not loaded. The error message is:
Did not parse stylesheet at 'file:///home/.../red.css' because non CSS MIME types are not allowed in strict mode.[file:///home/.../page.html:0]
There is no such problem with HTML pages/CSS stylesheets having a "http://" or "https://" URL (because the web server returns a valid MIME type for all the files it serves ???).
This is a regression. It used to work fine with any previous version of JavaFX, including 14.0.2.
REGRESSION : Last worked in version 14.0.2
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Compile attached SimpleBrowser.java:
javac SimpleBrowser.java
2) Save this HTML snippet to file "page.html":
---
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title>A page</title>
<link rel="stylesheet" href="red.css" type="text/css" />
</head>
<body>
<p>If CSS stylesheet "<code>./red.css</code>" is successfully loaded,
this paragraph should contain some <strong>RED</strong> text.</p>
</body>
</html>
---
3) Save this CSS snippet to file "red.css":
---
p {
color: red;
}
---
4) Run using OpenJDK 15+ JavaFX 15 on any OS:
java SimpleBrowser page.html
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
"page.html" displayed by SimpleBrowser contains some red text and no error is reported.
ACTUAL -
"page.html" displayed by SimpleBrowser contains some black text.
This error is reported:
Did not parse stylesheet at 'file:///home/.../red.css' because non CSS MIME types are not allowed in strict mode.[file:///home/.../page.html:0]
---------- BEGIN SOURCE ----------
import java.io.File;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class SimpleBrowser extends Application {
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Usage: java SimpleBrowser HTML_file_or_URL");
System.exit(1);
}
launch(args);
}
public void start(Stage primaryStage) {
primaryStage.setTitle("JavaFX SimpleBrowser");
WebView webView = new WebView();
com.sun.javafx.webkit.WebConsoleListener.setDefaultListener(
(aWebView, message, lineNumber, sourceId) ->
System.err.println("WebConsoleListener: " + message +
"[" + aWebView.getEngine().getLocation() +
":" + lineNumber + "]"));
String location = getParameters().getRaw().get(0);
if (location.indexOf(":/") < 0) {
File file = new File(location);
if (file.isFile()) {
location = file.toURI().toASCIIString();
}
}
webView.getEngine().load(location);
VBox vBox = new VBox(webView);
Scene scene = new Scene(vBox, 960, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround.
FREQUENCY : always
Any OS. OpenJDK 15 with JavaFX 15.
A DESCRIPTION OF THE PROBLEM :
WebView can load local, "file:///", HTML page but when such page is styled by a local, "file:///", CSS stylesheet, this CSS stylesheet is not loaded. The error message is:
Did not parse stylesheet at 'file:///home/.../red.css' because non CSS MIME types are not allowed in strict mode.[file:///home/.../page.html:0]
There is no such problem with HTML pages/CSS stylesheets having a "http://" or "https://" URL (because the web server returns a valid MIME type for all the files it serves ???).
This is a regression. It used to work fine with any previous version of JavaFX, including 14.0.2.
REGRESSION : Last worked in version 14.0.2
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Compile attached SimpleBrowser.java:
javac SimpleBrowser.java
2) Save this HTML snippet to file "page.html":
---
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title>A page</title>
<link rel="stylesheet" href="red.css" type="text/css" />
</head>
<body>
<p>If CSS stylesheet "<code>./red.css</code>" is successfully loaded,
this paragraph should contain some <strong>RED</strong> text.</p>
</body>
</html>
---
3) Save this CSS snippet to file "red.css":
---
p {
color: red;
}
---
4) Run using OpenJDK 15+ JavaFX 15 on any OS:
java SimpleBrowser page.html
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
"page.html" displayed by SimpleBrowser contains some red text and no error is reported.
ACTUAL -
"page.html" displayed by SimpleBrowser contains some black text.
This error is reported:
Did not parse stylesheet at 'file:///home/.../red.css' because non CSS MIME types are not allowed in strict mode.[file:///home/.../page.html:0]
---------- BEGIN SOURCE ----------
import java.io.File;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class SimpleBrowser extends Application {
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Usage: java SimpleBrowser HTML_file_or_URL");
System.exit(1);
}
launch(args);
}
public void start(Stage primaryStage) {
primaryStage.setTitle("JavaFX SimpleBrowser");
WebView webView = new WebView();
com.sun.javafx.webkit.WebConsoleListener.setDefaultListener(
(aWebView, message, lineNumber, sourceId) ->
System.err.println("WebConsoleListener: " + message +
"[" + aWebView.getEngine().getLocation() +
":" + lineNumber + "]"));
String location = getParameters().getRaw().get(0);
if (location.indexOf(":/") < 0) {
File file = new File(location);
if (file.isFile()) {
location = file.toURI().toASCIIString();
}
}
webView.getEngine().load(location);
VBox vBox = new VBox(webView);
Scene scene = new Scene(vBox, 960, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround.
FREQUENCY : always
Attachments
Issue Links
- relates to
-
JDK-8241389 URLConnection::getHeaderFields returns result inconsistent with getHeaderField/Key for FileURLConnection, FtpURLConnection
- Closed