# HG changeset patch # User bpatel # Date 1389653215 28800 # Node ID a244cc40ae0b29028ff8503ee516cb5f9e3db6e3 # Parent 7f3b353383901845ff7541a96622813d86b56247 8026736: Enhance Javadoc pages Reviewed-by: jjg diff -r 7f3b35338390 -r a244cc40ae0b src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java --- a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Thu Jan 09 07:59:42 2014 -0800 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Mon Jan 13 14:46:55 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -235,7 +235,7 @@ } else if (opt.equals("-doctitle")) { doctitle = os[1]; } else if (opt.equals("-windowtitle")) { - windowtitle = os[1]; + windowtitle = os[1].replaceAll("\\<.*?>", ""); } else if (opt.equals("-top")) { top = os[1]; } else if (opt.equals("-bottom")) { diff -r 7f3b35338390 -r a244cc40ae0b test/com/sun/javadoc/testWindowTitle/TestWindowTitle.java --- a/test/com/sun/javadoc/testWindowTitle/TestWindowTitle.java Thu Jan 09 07:59:42 2014 -0800 +++ b/test/com/sun/javadoc/testWindowTitle/TestWindowTitle.java Mon Jan 13 14:46:55 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8016675 + * @bug 8016675 8026736 * @summary Test for window title. * @author Bhavesh Patel * @library ../lib/ @@ -34,26 +34,153 @@ public class TestWindowTitle extends JavadocTester { private static final String BUG_ID = "8016675"; - private static final String WIN_TITLE = + //Window title with JavaScript special characters. + private static final String TITLE_JS_CHARS = "Testing \"Window 'Title'\" with a \\ backslash and a / " + "forward slash and a \u00e8 unicode char also a tab and also a " + "\t special character another \u0002 unicode)"; - private static final String[][] TEST = { - {BUG_ID + FS + "overview-summary.html", + private static final String[] ARGS_JS_CHARS = new String[]{ + "-d", BUG_ID + "-1", "-windowtitle", TITLE_JS_CHARS, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] TEST_JS_CHARS = { + {BUG_ID + "-1" + FS + "overview-summary.html", "parent.document.title=\"Overview (Testing \\\"Window \\\'Title\\\'\\\" " + "with a \\\\ backslash and a / forward slash and a \\u00E8 unicode char " + "also a tab and also a \\t special character another \\u0002 unicode))\";" }, }; - private static final String[][] NEG_TEST = { - {BUG_ID + FS + "overview-summary.html", + private static final String[][] NEG_TEST_JS_CHARS = { + {BUG_ID + "-1" + FS + "overview-summary.html", "parent.document.title=\"Overview (Testing \"Window \'Title\'\" " + "with a \\ backslash and a / forward slash and a \u00E8 unicode char " + "also a tab and also a \t special character another \u0002 unicode))\";" + } + }; + + //Window title with a script tag. + private static final String TITLE_SCRIPT_TAG = + "Testing script tag in title ."; + private static final String[] ARGS_SCRIPT_TAG = new String[]{ + "-d", BUG_ID + "-2", "-windowtitle", TITLE_SCRIPT_TAG, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] TEST_SCRIPT_TAG = { + {BUG_ID + "-2" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing script tag in title alert" + + "(\\\"Should not pop up\\\").)\";" }, + {BUG_ID + "-2" + FS + "p2" + FS + "C2.html", + "parent.document.title=\"C2 (Testing script tag in title alert" + + "(\\\"Should not pop up\\\").)\";" + } + }; + private static final String[][] NEG_TEST_SCRIPT_TAG = { + {BUG_ID + "-2" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing script tag in title .)\";" + }, + {BUG_ID + "-2" + FS + "p2" + FS + "C2.html", + "parent.document.title=\"C2 (Testing script tag in title .)\";" + } + }; + + //Window title with other HTML tags. + private static final String TITLE_HTML_TAGS = + "Testing another

HTML

tag. Another

tag

. A " + + "tag with attributes. "; + private static final String[] ARGS_EMPTY_TAGS = new String[]{ + "-d", BUG_ID + "-5", "-windowtitle", TITLE_EMPTY_TAGS, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] TEST_EMPTY_TAGS = { + {BUG_ID + "-5" + FS + "overview-summary.html", + "parent.document.title=\"Overview\";" + } + }; + private static final String[][] NEG_TEST_EMPTY_TAGS = { + {BUG_ID + "-5" + FS + "overview-summary.html", + "parent.document.title=\"Overview ()\";" + } + }; + + //Window title with unicode characters. + private static final String TITLE_UNICODE_CHARS = + "Testing unicode \u003cscript\u003ealert(\"Should not pop up\")\u003c/script\u003e."; + private static final String[] ARGS_UNICODE_CHARS = new String[]{ + "-d", BUG_ID + "-6", "-windowtitle", TITLE_UNICODE_CHARS, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] TEST_UNICODE_CHARS = { + {BUG_ID + "-6" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing unicode alert(\\\"Should " + + "not pop up\\\").)\";" + } + }; + private static final String[][] NEG_TEST_UNICODE_CHARS = { + {BUG_ID + "-6" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing unicode .)\";" + } + }; + + //An empty window title. + private static final String TITLE_EMPTY = + ""; + private static final String[] ARGS_EMPTY_TITLE = new String[]{ + "-d", BUG_ID + "-7", "-windowtitle", TITLE_EMPTY, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] TEST_EMPTY = { + {BUG_ID + "-7" + FS + "overview-summary.html", + "parent.document.title=\"Overview\";" + } + }; + + //Test doctitle. + private static final String[] ARGS_DOCTITLE = new String[]{ + "-d", BUG_ID + "-8", "-doctitle", TITLE_JS_CHARS, "-sourcepath", SRC_DIR, "p1", "p2" + }; + private static final String[][] NEG_TEST_DOCTITLE = { + {BUG_ID + "-8" + FS + "overview-summary.html", + "parent.document.title=\"Overview (Testing \\\"Window \\\'Title\\\'\\\" " + + "with a \\\\ backslash and a / forward slash and a \\u00E8 unicode char " + + "also a tab and also a \\t special character another \\u0002 unicode)\";" + }, }; /** @@ -62,7 +189,14 @@ */ public static void main(String[] args) { TestWindowTitle tester = new TestWindowTitle(); - run(tester, ARGS, TEST, NEG_TEST); + run(tester, ARGS_JS_CHARS, TEST_JS_CHARS, NEG_TEST_JS_CHARS); + run(tester, ARGS_SCRIPT_TAG, TEST_SCRIPT_TAG, NEG_TEST_SCRIPT_TAG); + run(tester, ARGS_HTML_TAGS, TEST_HTML_TAGS, NEG_TEST_HTML_TAGS); + run(tester, ARGS_HTML_ENTITIES, TEST_HTML_ENTITIES, NEG_TEST_HTML_ENTITIES); + run(tester, ARGS_EMPTY_TAGS, TEST_EMPTY_TAGS, NEG_TEST_EMPTY_TAGS); + run(tester, ARGS_UNICODE_CHARS, TEST_UNICODE_CHARS, NEG_TEST_UNICODE_CHARS); + run(tester, ARGS_EMPTY_TITLE, TEST_EMPTY, NO_TEST); + run(tester, ARGS_DOCTITLE, NO_TEST, NEG_TEST_DOCTITLE); tester.printSummary(); }