diff --git a/test/jdk/javax/swing/text/html/FrameView/4463014/bug4463014.java b/test/jdk/javax/swing/text/html/FrameView/4463014/bug4463014.java new file mode 100644 index 00000000000..4b7199c9017 --- /dev/null +++ b/test/jdk/javax/swing/text/html/FrameView/4463014/bug4463014.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2005, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 4463014 + * @summary Tests if JEditorPane updates the correct frame when using
+ * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4463014 + */ + +import java.io.File; +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.text.html.HTMLEditorKit; + +public class bug4463014 { + + static final String INSTRUCTIONS = """ + The test window displays an HTML frameset with a frame + on the left and another to the right. + Follow the instructions displayed in the left frame to perform testing. + The test PASSES only if the test behaves as per instructions. + """; + + static JFrame createUI() { + JFrame frame = new JFrame("bug4463014"); + JEditorPane jep = new JEditorPane(); + jep.setEditorKit(new HTMLEditorKit()); + jep.setEditable(false); + + try { + File file = new File(System.getProperty("test.src", "."), "frameset.html"); + System.out.println(file.toURL()); + jep.setPage(file.toURL()); + } catch (Exception e) { + } + + frame.add(jep); + frame.setSize(500,500); + return frame; + } + + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4463014::createUI) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/javax/swing/text/html/FrameView/4463014/frame1.html b/test/jdk/javax/swing/text/html/FrameView/4463014/frame1.html new file mode 100644 index 00000000000..833bc1f6352 --- /dev/null +++ b/test/jdk/javax/swing/text/html/FrameView/4463014/frame1.html @@ -0,0 +1,9 @@ + + +Push the Submit query button + +
+ +
+ + diff --git a/test/jdk/javax/swing/text/html/FrameView/4463014/frame2.html b/test/jdk/javax/swing/text/html/FrameView/4463014/frame2.html new file mode 100644 index 00000000000..5bc6dba57fc --- /dev/null +++ b/test/jdk/javax/swing/text/html/FrameView/4463014/frame2.html @@ -0,0 +1,4 @@ + + + + diff --git a/test/jdk/javax/swing/text/html/FrameView/4463014/frameresult.html b/test/jdk/javax/swing/text/html/FrameView/4463014/frameresult.html new file mode 100644 index 00000000000..a31045833b5 --- /dev/null +++ b/test/jdk/javax/swing/text/html/FrameView/4463014/frameresult.html @@ -0,0 +1,7 @@ + + +If you see this text in the RIGHT frame the test PASSED. +

If you see this text in the LEFT frame the test FAILED. + + + diff --git a/test/jdk/javax/swing/text/html/FrameView/4463014/frameset.html b/test/jdk/javax/swing/text/html/FrameView/4463014/frameset.html new file mode 100644 index 00000000000..1e7f8298d62 --- /dev/null +++ b/test/jdk/javax/swing/text/html/FrameView/4463014/frameset.html @@ -0,0 +1,11 @@ + + + + Manual test for bug 4463014 + + + + + + + \ No newline at end of file diff --git a/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4102068.java b/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4102068.java new file mode 100644 index 00000000000..39dd1d53925 --- /dev/null +++ b/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4102068.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 4102068 + * @summary Tests HTML editor JEditorPane change mouse icon over the link + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4102068 + */ + +import java.awt.Cursor; +import javax.swing.JFrame; +import javax.swing.JTextPane; +import javax.swing.text.html.HTMLEditorKit; + +public class bug4102068 { + + static final String INSTRUCTIONS = """ + The test window contains an HTML frame containing a string with one hyperlink. + Move the mouse pointer over this hyperlink. + If the pointer over the hyperlink became a HAND cursor then the test PASSES, + otherwise the test FAILS. + """; + + static JFrame createUI() { + + JFrame frame = new JFrame("bug4102068"); + JTextPane ep = new JTextPane(); + ep.setContentType("text/html"); + HTMLEditorKit ek = new HTMLEditorKit(); + ep.setEditorKit(ek); + ep.setText("Here is a HyperLink Cursor Test"); + ek.setDefaultCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + Cursor ct = ek.getDefaultCursor(); + ek.setLinkCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + Cursor cl = ek.getLinkCursor(); + if (ct.getType() != Cursor.DEFAULT_CURSOR || cl.getType() != Cursor.HAND_CURSOR) { + throw new RuntimeException("Error with cursor settings..."); + } + ep.setEditable(false); + + frame.add(ep); + frame.setSize(300, 300); + return frame; + } + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4102068::createUI) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4198022.java b/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4198022.java new file mode 100644 index 00000000000..2d26ace2131 --- /dev/null +++ b/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4198022.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 4198022 + * @summary Tests if HTML tags , and are supported in JEditorPane + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4198022 + */ + +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.text.html.HTMLEditorKit; + +public class bug4198022 { + + static final String INSTRUCTIONS = """ + There are two "lines" of text in the displayed HTML window + The first line/string contains and HTML elements. + The word "subscript" should be subscripted (placed lower than the word "Testing"), + and the word "superscript" should be superscripted (placed higher than "Testing"). + If instead these words are placed on the same level then the test FAILS. + + The second line/string contains a sentence marked with tag. + It should be presented as one long line without breaks. + It is OK for the line to extend past the end of the window and not be all visible. + If the line is broken up so you see multiple lines the test FAILS. + + If all behaves as expected, the test PASSES. + """; + + static JFrame createUI() { + + JFrame frame = new JFrame("bug4198022"); + JEditorPane ep = new JEditorPane(); + HTMLEditorKit ek = new HTMLEditorKit(); + ep.setEditorKit(ek); + ep.setText( + "Testing subscript and superscript.
" + + "
This text is intended to be presented as a single line without " + + "any word wrapping, regardless of whether it fits the viewable area of " + + "the editor pane or not."); + + ep.setEditable(false); + + frame.add(ep); + frame.setSize(500, 300); + return frame; + } + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(bug4198022::createUI) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4245401.java b/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4245401.java new file mode 100644 index 00000000000..1f9bc7da914 --- /dev/null +++ b/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4245401.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 4245401 + * @summary Tests that JTextPane with HTMLEditorKit handles the HEAD tag properly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4245401 + */ + +import java.io.StringReader; +import javax.swing.JFrame; +import javax.swing.JTextPane; +import javax.swing.text.html.HTMLDocument; +import javax.swing.text.html.HTMLEditorKit; + +public class bug4245401 { + + static final String INSTRUCTIONS = """ + Place the cursor before the "H" in the word "HTML" + Then press and . + If an extra HEAD tag appear, the test FAILS, otherwise it PASSES. + """; + + static JFrame createUI() { + + JFrame frame = new JFrame("bug4245401"); + JTextPane ep = new JTextPane(); + ep.setEditable(true); + ep.setContentType("text/html"); + HTMLEditorKit kit = (HTMLEditorKit) ep.getEditorKit(); + ep.setEditorKit(kit); + HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument(); + ep.setDocument(doc); + + try { + String text = "HTML Test... Test is a test..."; + kit.read(new StringReader(text), doc, 0); + } catch (Exception e) { + throw new RuntimeException(e); + } + + frame.add(ep); + frame.setSize(300, 300); + return frame; + } + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4245401::createUI) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/javax/swing/text/html/StyleSheet/bug4619595.java b/test/jdk/javax/swing/text/html/StyleSheet/bug4619595.java new file mode 100644 index 00000000000..2d99d867cdd --- /dev/null +++ b/test/jdk/javax/swing/text/html/StyleSheet/bug4619595.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2003, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 4619595 + * @summary Tests that embedded list items do not inherit the 'value' + * property from their parent list item + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4619595 + */ + +import javax.swing.JEditorPane; +import javax.swing.JFrame; + +public class bug4619595 { + + static final String INSTRUCTIONS = """ + The test window contains numbered lists. + Look at the three indented/embedded list items (the ones that are bold). + If they are not numbered 1, 2 and 3, then press FAIL. + + Below the lists there should also be a line saying: "The quick brown fox". + If you don't see this, press FAIL. + + If all is as expected, PASS the test. + """; + + final static String HTML = "" + + "

  1. Let's start
  2. Look @ inner list" + + "
    1. Inner list starts
    2. Second inner item" + + "
    3. Inner list ends
    " + + "
  3. That's all
" + + "

The quick brown fox

" + + " "; + + static JFrame createUI() { + + JFrame frame = new JFrame("bug4619595"); + JEditorPane pane = new JEditorPane(); + pane.setContentType("text/html"); + pane.setText(HTML); + frame.add(pane); + frame.setSize(400, 400); + return frame; + } + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4619595::createUI) + .build() + .awaitAndCheck(); + } +}