Skip to content

Commit

Permalink
8253696: WebEngine refuses to load local "file:///" CSS stylesheets w…
Browse files Browse the repository at this point in the history
…hen using JDK 15

Reviewed-by: kcr
  • Loading branch information
arun-joseph committed Oct 6, 2020
1 parent 5b42b64 commit 15e52d8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -867,13 +867,15 @@ private static long extractContentLength(URLConnection c) {
*/
private static String extractHeaders(URLConnection c) {
StringBuilder sb = new StringBuilder();
Map<String, List<String>> headers = c.getHeaderFields();
for (Map.Entry<String, List<String>> entry: headers.entrySet()) {
String key = entry.getKey();
List<String> values = entry.getValue();
for (String value : values) {
sb.append(key != null ? key : "");
sb.append(':').append(value).append('\n');
if (c instanceof HttpURLConnection) {
Map<String, List<String>> headers = c.getHeaderFields();
for (Map.Entry<String, List<String>> entry: headers.entrySet()) {
String key = entry.getKey();
List<String> values = entry.getValue();
for (String value : values) {
sb.append(key != null ? key : "");
sb.append(':').append(value).append('\n');
}
}
}
return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -192,6 +192,16 @@ private void testLoadEmpty(String url) {
assertNotNull("Document is null", webEngine.getDocument());
}

@Test public void testLoadLocalCSS() {
load(new File("src/test/resources/test/html/dom.html"));
submit(() -> {
assertEquals("Font weight should be bold", "bold", (String) getEngine().executeScript(
"window.getComputedStyle(document.getElementById('p3')).getPropertyValue('font-weight')"));
assertEquals("font style should be italic", "italic", (String) getEngine().executeScript(
"window.getComputedStyle(document.getElementById('p3')).getPropertyValue('font-style')"));
});
}

/**
* @test
* @bug 8140501
Expand Down
3 changes: 3 additions & 0 deletions modules/javafx.web/src/test/resources/test/html/dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<p id="p1">Things <b>do</b> change</p>
<p id="p2">Again <i>and</i> again</p>

<!-- used by testLoadLocalCSS -->
<p id="p3" class="head2">Sample Text</p>

<!-- used by testNodeTypes -->
<p id="showcase-paragraph">
text<!--comment--><span class="spanclass">spantext</span></p>
Expand Down

0 comments on commit 15e52d8

Please sign in to comment.