JDK-8200416 : HTMLEditor: The "style" attribute of the "body" tag is removed when text is added.
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 8u172,10,openjfx11
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: x86_64
  • Submitted: 2018-03-28
  • Updated: 2018-06-13
  • Resolved: 2018-04-16
Related Reports
Duplicate :  
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_172-ea"
Java(TM) SE Runtime Environment (build 1.8.0_172-ea-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b03, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
macOS 10.12.6

A DESCRIPTION OF THE PROBLEM :
Load this into an HTMLEditor:

<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="font-family: san-serif" contenteditable="true">
<p>Test</p>

</body></html>

Then move the cursor behind "Test", press return and type "Test" again. In Java 1.8.0_172 you will get this:

<html dir="ltr"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body contenteditable="true">
<p style="font-family: san-serif;">Test</p><p><font face="Lucida Grande">Test</font></p>

</body></html>

In Java 1.8.0_112 you will get this:

<html dir="ltr"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="font-family: san-serif" contenteditable="true">
<p>Test</p><p><font face="Lucida Grande">Test</font></p>

</body></html>


As you can see Java 1.8.0_172 now removes the style from the body tag which influences how future text is displayed. It has added a style attribute to the existing <p> tag but if the program adds another <p> tag later, it makes a difference. In earlier Java versions, i.e. in 1.8.0_112 the body's style attribute was not modified. I think that was the correct behaviour.

REGRESSION.  Last worked in version 8u151

ADDITIONAL REGRESSION INFORMATION: 
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Please see the "Description" above. 


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The body's style attribute should not be modified.
ACTUAL -
The body's style attribute is modified when just typing some text.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

public class Controller implements Initializable {
    public HTMLEditor htmlEditor;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        htmlEditor.setHtmlText("<html>\n" +
                "<head>\n" +
                "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n" +
                "</head>\n" +
                "<body style=\"font-family: san-serif\">\n" +
                "<p>Test</p>\n" +
                "</body>\n" +
                "</html>");
    }

    public void onPrintConsole(ActionEvent actionEvent) {
        System.out.println(htmlEditor.getHtmlText());
    }
}



and


public class Controller implements Initializable {
    public HTMLEditor htmlEditor;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        htmlEditor.setHtmlText("<html>\n" +
                "<head>\n" +
                "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n" +
                "</head>\n" +
                "<body style=\"font-family: san-serif\">\n" +
                "<p>Test</p>\n" +
                "</body>\n" +
                "</html>");
    }

    public void onPrintConsole(ActionEvent actionEvent) {
        System.out.println(htmlEditor.getHtmlText());
    }
}

---------- END SOURCE ----------


Comments
[~kcr] This issue is reproducible in latest 8u-dev build.
05-04-2018

Issue is reproducible in both Windows 10 and macOS 10.13.3. Its a regression introduced in 8u172-ea+01 but fixed in later versions Windows 10, 64-bit JDK results -------------------------------- 8u161-b12 : Pass 8u162-b12 : Pass 8u171-b11 : Pass 8u172-b01 : Fail <-- regression 8u172-b03 : Fail 8u172-b11 : Fail 9.0.4 : Pass 10+46 : Pass 11-ea+06 : Pass ----------------------------- Steps to reproduce: 1. Ran test case and move cursor to beginning of 'Test' and press Enter. 2. Move cursor to above line and type 'Test' 3. Click 'Print to console' and see logs on terminal
29-03-2018

Can you test with the latest 8u-dev build?
29-03-2018