test/com/sun/javadoc/testWindowTitle/TestWindowTitle.java

Mon, 23 Jan 2017 17:03:12 -0800

author
asaha
date
Mon, 23 Jan 2017 17:03:12 -0800
changeset 3376
26c9abc6c440
parent 2319
bd5898d93742
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Merge

bpatel@2119 1 /*
bpatel@2319 2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
bpatel@2119 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bpatel@2119 4 *
bpatel@2119 5 * This code is free software; you can redistribute it and/or modify it
bpatel@2119 6 * under the terms of the GNU General Public License version 2 only, as
bpatel@2119 7 * published by the Free Software Foundation.
bpatel@2119 8 *
bpatel@2119 9 * This code is distributed in the hope that it will be useful, but WITHOUT
bpatel@2119 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bpatel@2119 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bpatel@2119 12 * version 2 for more details (a copy is included in the LICENSE file that
bpatel@2119 13 * accompanied this code).
bpatel@2119 14 *
bpatel@2119 15 * You should have received a copy of the GNU General Public License version
bpatel@2119 16 * 2 along with this work; if not, write to the Free Software Foundation,
bpatel@2119 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bpatel@2119 18 *
bpatel@2119 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bpatel@2119 20 * or visit www.oracle.com if you need additional information or have any
bpatel@2119 21 * questions.
bpatel@2119 22 */
bpatel@2119 23
bpatel@2119 24 /*
bpatel@2119 25 * @test
bpatel@2319 26 * @bug 8016675 8026736
bpatel@2119 27 * @summary Test for window title.
bpatel@2119 28 * @author Bhavesh Patel
bpatel@2119 29 * @library ../lib/
bpatel@2119 30 * @build JavadocTester TestWindowTitle
bpatel@2119 31 * @run main TestWindowTitle
bpatel@2119 32 */
bpatel@2119 33
bpatel@2119 34 public class TestWindowTitle extends JavadocTester {
bpatel@2119 35
bpatel@2119 36 private static final String BUG_ID = "8016675";
bpatel@2319 37 //Window title with JavaScript special characters.
bpatel@2319 38 private static final String TITLE_JS_CHARS =
bpatel@2119 39 "Testing \"Window 'Title'\" with a \\ backslash and a / " +
bpatel@2119 40 "forward slash and a \u00e8 unicode char also a tab and also a " +
bpatel@2119 41 "\t special character another \u0002 unicode)";
bpatel@2319 42 private static final String[] ARGS_JS_CHARS = new String[]{
bpatel@2319 43 "-d", BUG_ID + "-1", "-windowtitle", TITLE_JS_CHARS, "-sourcepath", SRC_DIR, "p1", "p2"
bpatel@2319 44 };
bpatel@2319 45 private static final String[][] TEST_JS_CHARS = {
bpatel@2319 46 {BUG_ID + "-1" + FS + "overview-summary.html",
bpatel@2119 47 "parent.document.title=\"Overview (Testing \\\"Window \\\'Title\\\'\\\" " +
bpatel@2119 48 "with a \\\\ backslash and a / forward slash and a \\u00E8 unicode char " +
bpatel@2119 49 "also a tab and also a \\t special character another \\u0002 unicode))\";"
bpatel@2119 50 },
bpatel@2119 51 };
bpatel@2319 52 private static final String[][] NEG_TEST_JS_CHARS = {
bpatel@2319 53 {BUG_ID + "-1" + FS + "overview-summary.html",
bpatel@2119 54 "parent.document.title=\"Overview (Testing \"Window \'Title\'\" " +
bpatel@2119 55 "with a \\ backslash and a / forward slash and a \u00E8 unicode char " +
bpatel@2119 56 "also a tab and also a \t special character another \u0002 unicode))\";"
bpatel@2319 57 }
bpatel@2319 58 };
bpatel@2319 59
bpatel@2319 60 //Window title with a script tag.
bpatel@2319 61 private static final String TITLE_SCRIPT_TAG =
bpatel@2319 62 "Testing script tag in title </title><script>alert(\"Should not pop up\")</script>.";
bpatel@2319 63 private static final String[] ARGS_SCRIPT_TAG = new String[]{
bpatel@2319 64 "-d", BUG_ID + "-2", "-windowtitle", TITLE_SCRIPT_TAG, "-sourcepath", SRC_DIR, "p1", "p2"
bpatel@2319 65 };
bpatel@2319 66 private static final String[][] TEST_SCRIPT_TAG = {
bpatel@2319 67 {BUG_ID + "-2" + FS + "overview-summary.html",
bpatel@2319 68 "parent.document.title=\"Overview (Testing script tag in title alert" +
bpatel@2319 69 "(\\\"Should not pop up\\\").)\";"
bpatel@2119 70 },
bpatel@2319 71 {BUG_ID + "-2" + FS + "p2" + FS + "C2.html",
bpatel@2319 72 "parent.document.title=\"C2 (Testing script tag in title alert" +
bpatel@2319 73 "(\\\"Should not pop up\\\").)\";"
bpatel@2319 74 }
bpatel@2119 75 };
bpatel@2319 76 private static final String[][] NEG_TEST_SCRIPT_TAG = {
bpatel@2319 77 {BUG_ID + "-2" + FS + "overview-summary.html",
bpatel@2319 78 "parent.document.title=\"Overview (Testing script tag in title </title><script>" +
bpatel@2319 79 "alert(\\\"Should not pop up\\\")</script>.)\";"
bpatel@2319 80 },
bpatel@2319 81 {BUG_ID + "-2" + FS + "p2" + FS + "C2.html",
bpatel@2319 82 "parent.document.title=\"C2 (Testing script tag in title </title><script>" +
bpatel@2319 83 "alert(\\\"Should not pop up\\\")</script>.)\";"
bpatel@2319 84 }
bpatel@2319 85 };
bpatel@2319 86
bpatel@2319 87 //Window title with other HTML tags.
bpatel@2319 88 private static final String TITLE_HTML_TAGS =
bpatel@2319 89 "Testing another <p>HTML</p> tag. Another <h1>tag</h1>. A " +
bpatel@2319 90 "<span id=\"testTag\">tag with attributes</span>. <script and </p are not tags.";
bpatel@2319 91 private static final String[] ARGS_HTML_TAGS = new String[]{
bpatel@2319 92 "-d", BUG_ID + "-3", "-windowtitle", TITLE_HTML_TAGS, "-sourcepath", SRC_DIR, "p1", "p2"
bpatel@2319 93 };
bpatel@2319 94 private static final String[][] TEST_HTML_TAGS = {
bpatel@2319 95 {BUG_ID + "-3" + FS + "overview-summary.html",
bpatel@2319 96 "parent.document.title=\"Overview (Testing another HTML tag. Another tag. A " +
bpatel@2319 97 "tag with attributes. <script and </p are not tags.)\";"
bpatel@2319 98 }
bpatel@2319 99 };
bpatel@2319 100 private static final String[][] NEG_TEST_HTML_TAGS = {
bpatel@2319 101 {BUG_ID + "-3" + FS + "overview-summary.html",
bpatel@2319 102 "parent.document.title=\"Overview (Testing another <p>HTML</p> tag. Another " +
bpatel@2319 103 "<h1>tag</h1>. A <span id=\"testTag\">tag with attributes</span>. <script and " +
bpatel@2319 104 "</p are not tags.)\";"
bpatel@2319 105 }
bpatel@2319 106 };
bpatel@2319 107
bpatel@2319 108 //Window title using entities.
bpatel@2319 109 private static final String TITLE_HTML_ENTITIES =
bpatel@2319 110 "Testing entities &lt;script&gt;alert(\"Should not pop up\")&lt;/script&gt;.";
bpatel@2319 111 private static final String[] ARGS_HTML_ENTITIES = new String[]{
bpatel@2319 112 "-d", BUG_ID + "-4", "-windowtitle", TITLE_HTML_ENTITIES, "-sourcepath", SRC_DIR, "p1", "p2"
bpatel@2319 113 };
bpatel@2319 114 private static final String[][] TEST_HTML_ENTITIES = {
bpatel@2319 115 {BUG_ID + "-4" + FS + "overview-summary.html",
bpatel@2319 116 "parent.document.title=\"Overview (Testing entities &lt;script&gt;alert(\\\"Should " +
bpatel@2319 117 "not pop up\\\")&lt;/script&gt;.)\";"
bpatel@2319 118 }
bpatel@2319 119 };
bpatel@2319 120 private static final String[][] NEG_TEST_HTML_ENTITIES = {
bpatel@2319 121 {BUG_ID + "-4" + FS + "overview-summary.html",
bpatel@2319 122 "parent.document.title=\"Overview (Testing entities alert(\\\"Should not pop up\\\").)\";"
bpatel@2319 123 }
bpatel@2319 124 };
bpatel@2319 125
bpatel@2319 126 //Window title with just empty HTML tags.
bpatel@2319 127 private static final String TITLE_EMPTY_TAGS =
bpatel@2319 128 "</title><script></script>";
bpatel@2319 129 private static final String[] ARGS_EMPTY_TAGS = new String[]{
bpatel@2319 130 "-d", BUG_ID + "-5", "-windowtitle", TITLE_EMPTY_TAGS, "-sourcepath", SRC_DIR, "p1", "p2"
bpatel@2319 131 };
bpatel@2319 132 private static final String[][] TEST_EMPTY_TAGS = {
bpatel@2319 133 {BUG_ID + "-5" + FS + "overview-summary.html",
bpatel@2319 134 "parent.document.title=\"Overview\";"
bpatel@2319 135 }
bpatel@2319 136 };
bpatel@2319 137 private static final String[][] NEG_TEST_EMPTY_TAGS = {
bpatel@2319 138 {BUG_ID + "-5" + FS + "overview-summary.html",
bpatel@2319 139 "parent.document.title=\"Overview (</title><script></script>)\";"
bpatel@2319 140 }
bpatel@2319 141 };
bpatel@2319 142
bpatel@2319 143 //Window title with unicode characters.
bpatel@2319 144 private static final String TITLE_UNICODE_CHARS =
bpatel@2319 145 "Testing unicode \u003cscript\u003ealert(\"Should not pop up\")\u003c/script\u003e.";
bpatel@2319 146 private static final String[] ARGS_UNICODE_CHARS = new String[]{
bpatel@2319 147 "-d", BUG_ID + "-6", "-windowtitle", TITLE_UNICODE_CHARS, "-sourcepath", SRC_DIR, "p1", "p2"
bpatel@2319 148 };
bpatel@2319 149 private static final String[][] TEST_UNICODE_CHARS = {
bpatel@2319 150 {BUG_ID + "-6" + FS + "overview-summary.html",
bpatel@2319 151 "parent.document.title=\"Overview (Testing unicode alert(\\\"Should " +
bpatel@2319 152 "not pop up\\\").)\";"
bpatel@2319 153 }
bpatel@2319 154 };
bpatel@2319 155 private static final String[][] NEG_TEST_UNICODE_CHARS = {
bpatel@2319 156 {BUG_ID + "-6" + FS + "overview-summary.html",
bpatel@2319 157 "parent.document.title=\"Overview (Testing unicode <script>alert(\\\"Should not pop up\\\")" +
bpatel@2319 158 "</script>.)\";"
bpatel@2319 159 }
bpatel@2319 160 };
bpatel@2319 161
bpatel@2319 162 //An empty window title.
bpatel@2319 163 private static final String TITLE_EMPTY =
bpatel@2319 164 "";
bpatel@2319 165 private static final String[] ARGS_EMPTY_TITLE = new String[]{
bpatel@2319 166 "-d", BUG_ID + "-7", "-windowtitle", TITLE_EMPTY, "-sourcepath", SRC_DIR, "p1", "p2"
bpatel@2319 167 };
bpatel@2319 168 private static final String[][] TEST_EMPTY = {
bpatel@2319 169 {BUG_ID + "-7" + FS + "overview-summary.html",
bpatel@2319 170 "parent.document.title=\"Overview\";"
bpatel@2319 171 }
bpatel@2319 172 };
bpatel@2319 173
bpatel@2319 174 //Test doctitle.
bpatel@2319 175 private static final String[] ARGS_DOCTITLE = new String[]{
bpatel@2319 176 "-d", BUG_ID + "-8", "-doctitle", TITLE_JS_CHARS, "-sourcepath", SRC_DIR, "p1", "p2"
bpatel@2319 177 };
bpatel@2319 178 private static final String[][] NEG_TEST_DOCTITLE = {
bpatel@2319 179 {BUG_ID + "-8" + FS + "overview-summary.html",
bpatel@2319 180 "parent.document.title=\"Overview (Testing \\\"Window \\\'Title\\\'\\\" " +
bpatel@2319 181 "with a \\\\ backslash and a / forward slash and a \\u00E8 unicode char " +
bpatel@2319 182 "also a tab and also a \\t special character another \\u0002 unicode)\";"
bpatel@2319 183 },
bpatel@2119 184 };
bpatel@2119 185
bpatel@2119 186 /**
bpatel@2119 187 * The entry point of the test.
bpatel@2119 188 * @param args the array of command line arguments.
bpatel@2119 189 */
bpatel@2119 190 public static void main(String[] args) {
bpatel@2119 191 TestWindowTitle tester = new TestWindowTitle();
bpatel@2319 192 run(tester, ARGS_JS_CHARS, TEST_JS_CHARS, NEG_TEST_JS_CHARS);
bpatel@2319 193 run(tester, ARGS_SCRIPT_TAG, TEST_SCRIPT_TAG, NEG_TEST_SCRIPT_TAG);
bpatel@2319 194 run(tester, ARGS_HTML_TAGS, TEST_HTML_TAGS, NEG_TEST_HTML_TAGS);
bpatel@2319 195 run(tester, ARGS_HTML_ENTITIES, TEST_HTML_ENTITIES, NEG_TEST_HTML_ENTITIES);
bpatel@2319 196 run(tester, ARGS_EMPTY_TAGS, TEST_EMPTY_TAGS, NEG_TEST_EMPTY_TAGS);
bpatel@2319 197 run(tester, ARGS_UNICODE_CHARS, TEST_UNICODE_CHARS, NEG_TEST_UNICODE_CHARS);
bpatel@2319 198 run(tester, ARGS_EMPTY_TITLE, TEST_EMPTY, NO_TEST);
bpatel@2319 199 run(tester, ARGS_DOCTITLE, NO_TEST, NEG_TEST_DOCTITLE);
bpatel@2119 200 tester.printSummary();
bpatel@2119 201 }
bpatel@2119 202
bpatel@2119 203 /**
bpatel@2119 204 * {@inheritDoc}
bpatel@2119 205 */
bpatel@2119 206 public String getBugId() {
bpatel@2119 207 return BUG_ID;
bpatel@2119 208 }
bpatel@2119 209
bpatel@2119 210 /**
bpatel@2119 211 * {@inheritDoc}
bpatel@2119 212 */
bpatel@2119 213 public String getBugName() {
bpatel@2119 214 return getClass().getName();
bpatel@2119 215 }
bpatel@2119 216 }

mercurial