Tue, 24 Sep 2013 16:12:06 -0700
8016328: Regression : Javadoc i18n regression caused by fix for 8012375
Reviewed-by: jjg
1 /*
2 * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
24 /*
25 * @test
26 * @bug 4665566 4855876 7025314 8012375 8015997 8016328
27 * @summary Verify that the output has the right javascript.
28 * @author jamieh
29 * @library ../lib/
30 * @build JavadocTester
31 * @build TestJavascript
32 * @run main TestJavascript
33 */
35 public class TestJavascript extends JavadocTester {
37 //Test information.
38 private static final String BUG_ID = "4665566-4855876-8012375";
40 //Javadoc arguments.
41 private static final String[] ARGS = new String[] {
42 "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg", SRC_DIR + FS + "TestJavascript.java"
43 };
45 //Input for string search tests.
46 private static final String[][] TEST = {
47 {BUG_ID + FS + "pkg" + FS + "C.html",
48 "<a href=\"../index.html?pkg/C.html\" target=\"_top\">Frames</a>"},
49 {BUG_ID + FS + "TestJavascript.html",
50 "<a href=\"index.html?TestJavascript.html\" target=\"_top\">Frames</a>"},
51 {BUG_ID + FS + "index.html",
52 "<script type=\"text/javascript\">" + NL +
53 " targetPage = \"\" + window.location.search;" + NL +
54 " if (targetPage != \"\" && targetPage != \"undefined\")" + NL +
55 " targetPage = targetPage.substring(1);" + NL +
56 " if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + NL +
57 " targetPage = \"undefined\";" + NL +
58 " function validURL(url) {" + NL +
59 " try {" + NL +
60 " url = decodeURIComponent(url);" + NL +
61 " }" + NL +
62 " catch (error) {" + NL +
63 " return false;" + NL +
64 " }" + NL +
65 " var pos = url.indexOf(\".html\");" + NL +
66 " if (pos == -1 || pos != url.length - 5)" + NL +
67 " return false;" + NL +
68 " var allowNumber = false;" + NL +
69 " var allowSep = false;" + NL +
70 " var seenDot = false;" + NL +
71 " for (var i = 0; i < url.length - 5; i++) {" + NL +
72 " var ch = url.charAt(i);" + NL +
73 " if ('a' <= ch && ch <= 'z' ||" + NL +
74 " 'A' <= ch && ch <= 'Z' ||" + NL +
75 " ch == '$' ||" + NL +
76 " ch == '_' ||" + NL +
77 " ch.charCodeAt(0) > 127) {" + NL +
78 " allowNumber = true;" + NL +
79 " allowSep = true;" + NL +
80 " } else if ('0' <= ch && ch <= '9'" + NL +
81 " || ch == '-') {" + NL +
82 " if (!allowNumber)" + NL +
83 " return false;" + NL +
84 " } else if (ch == '/' || ch == '.') {" + NL +
85 " if (!allowSep)" + NL +
86 " return false;" + NL +
87 " allowNumber = false;" + NL +
88 " allowSep = false;" + NL +
89 " if (ch == '.')" + NL +
90 " seenDot = true;" + NL +
91 " if (ch == '/' && seenDot)" + NL +
92 " return false;" + NL +
93 " } else {" + NL +
94 " return false;" + NL +
95 " }" + NL +
96 " }" + NL +
97 " return true;" + NL +
98 " }" + NL +
99 " function loadFrames() {" + NL +
100 " if (targetPage != \"\" && targetPage != \"undefined\")" + NL +
101 " top.classFrame.location = top.targetPage;" + NL +
102 " }" + NL +
103 "</script>"},
105 //Make sure title javascript only runs if is-external is not true
106 {BUG_ID + FS + "pkg" + FS + "C.html",
107 " if (location.href.indexOf('is-external=true') == -1) {" + NL +
108 " parent.document.title=\"C\";" + NL +
109 " }"},
110 };
112 private static final String[][] NEGATED_TEST = NO_TEST;
114 /**
115 * The entry point of the test.
116 * @param args the array of command line arguments.
117 */
118 public static void main(String[] args) {
119 TestJavascript tester = new TestJavascript();
120 run(tester, ARGS, TEST, NEGATED_TEST);
121 tester.printSummary();
122 }
124 /**
125 * {@inheritDoc}
126 */
127 public String getBugId() {
128 return BUG_ID;
129 }
131 /**
132 * {@inheritDoc}
133 */
134 public String getBugName() {
135 return getClass().getName();
136 }
137 }