Skip to content
Permalink
Browse files
8253696: WebEngine refuses to load local "file:///" CSS stylesheets w…
…hen using JDK 15

Reviewed-by: kcr
  • Loading branch information
arun-Joseph committed Oct 6, 2020
1 parent 5b42b64 commit 15e52d8f7c0611a2effe3f7e3cb1d3d6e2b1bddd
@@ -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
@@ -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();
@@ -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
@@ -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
@@ -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>

0 comments on commit 15e52d8

Please sign in to comment.