author | jjg |
Fri, 18 Apr 2014 17:25:43 -0700 | |
changeset 24065 | fc4022e50129 |
parent 23971 | f5ff1f5a8dee |
child 24071 | b0845717434e |
permissions | -rw-r--r-- |
10 | 1 |
/* |
23971 | 2 |
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* @test |
|
20614 | 26 |
* @bug 4665566 4855876 7025314 8012375 8015997 8016328 8024756 |
10 | 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 |
*/ |
|
34 |
||
35 |
public class TestJavascript extends JavadocTester { |
|
36 |
||
37 |
//Test information. |
|
18398 | 38 |
private static final String BUG_ID = "4665566-4855876-8012375"; |
10 | 39 |
|
40 |
//Javadoc arguments. |
|
41 |
private static final String[] ARGS = new String[] { |
|
23971 | 42 |
"-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg", SRC_DIR + |
43 |
"/TestJavascript.java" |
|
10 | 44 |
}; |
45 |
||
46 |
//Input for string search tests. |
|
47 |
private static final String[][] TEST = { |
|
23971 | 48 |
{BUG_ID + "/pkg/C.html", |
9067
c0b85430843d
7025314: NLS: translatability violation on standard.properties
bpatel
parents:
7681
diff
changeset
|
49 |
"<a href=\"../index.html?pkg/C.html\" target=\"_top\">Frames</a>"}, |
23971 | 50 |
{BUG_ID + "/TestJavascript.html", |
9067
c0b85430843d
7025314: NLS: translatability violation on standard.properties
bpatel
parents:
7681
diff
changeset
|
51 |
"<a href=\"index.html?TestJavascript.html\" target=\"_top\">Frames</a>"}, |
23971 | 52 |
{BUG_ID + "/index.html", |
53 |
"<script type=\"text/javascript\">\n" + |
|
54 |
" targetPage = \"\" + window.location.search;\n" + |
|
55 |
" if (targetPage != \"\" && targetPage != \"undefined\")\n" + |
|
56 |
" targetPage = targetPage.substring(1);\n" + |
|
57 |
" if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))\n" + |
|
58 |
" targetPage = \"undefined\";\n" + |
|
59 |
" function validURL(url) {\n" + |
|
60 |
" try {\n" + |
|
61 |
" url = decodeURIComponent(url);\n" + |
|
62 |
" }\n" + |
|
63 |
" catch (error) {\n" + |
|
64 |
" return false;\n" + |
|
65 |
" }\n" + |
|
66 |
" var pos = url.indexOf(\".html\");\n" + |
|
67 |
" if (pos == -1 || pos != url.length - 5)\n" + |
|
68 |
" return false;\n" + |
|
69 |
" var allowNumber = false;\n" + |
|
70 |
" var allowSep = false;\n" + |
|
71 |
" var seenDot = false;\n" + |
|
72 |
" for (var i = 0; i < url.length - 5; i++) {\n" + |
|
73 |
" var ch = url.charAt(i);\n" + |
|
74 |
" if ('a' <= ch && ch <= 'z' ||\n" + |
|
75 |
" 'A' <= ch && ch <= 'Z' ||\n" + |
|
76 |
" ch == '$' ||\n" + |
|
77 |
" ch == '_' ||\n" + |
|
78 |
" ch.charCodeAt(0) > 127) {\n" + |
|
79 |
" allowNumber = true;\n" + |
|
80 |
" allowSep = true;\n" + |
|
81 |
" } else if ('0' <= ch && ch <= '9'\n" + |
|
82 |
" || ch == '-') {\n" + |
|
83 |
" if (!allowNumber)\n" + |
|
84 |
" return false;\n" + |
|
85 |
" } else if (ch == '/' || ch == '.') {\n" + |
|
86 |
" if (!allowSep)\n" + |
|
87 |
" return false;\n" + |
|
88 |
" allowNumber = false;\n" + |
|
89 |
" allowSep = false;\n" + |
|
90 |
" if (ch == '.')\n" + |
|
91 |
" seenDot = true;\n" + |
|
92 |
" if (ch == '/' && seenDot)\n" + |
|
93 |
" return false;\n" + |
|
94 |
" } else {\n" + |
|
95 |
" return false;\n" + |
|
96 |
" }\n" + |
|
97 |
" }\n" + |
|
98 |
" return true;\n" + |
|
99 |
" }\n" + |
|
100 |
" function loadFrames() {\n" + |
|
101 |
" if (targetPage != \"\" && targetPage != \"undefined\")\n" + |
|
102 |
" top.classFrame.location = top.targetPage;\n" + |
|
103 |
" }\n" + |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
104 |
"</script>"}, |
10 | 105 |
|
106 |
//Make sure title javascript only runs if is-external is not true |
|
23971 | 107 |
{BUG_ID + "/pkg/C.html", |
108 |
" try {\n" + |
|
109 |
" if (location.href.indexOf('is-external=true') == -1) {\n" + |
|
110 |
" parent.document.title=\"C\";\n" + |
|
111 |
" }\n" + |
|
112 |
" }\n" + |
|
113 |
" catch(err) {\n" + |
|
20614 | 114 |
" }"}, |
10 | 115 |
}; |
116 |
||
117 |
private static final String[][] NEGATED_TEST = NO_TEST; |
|
118 |
||
119 |
/** |
|
120 |
* The entry point of the test. |
|
121 |
* @param args the array of command line arguments. |
|
122 |
*/ |
|
123 |
public static void main(String[] args) { |
|
124 |
TestJavascript tester = new TestJavascript(); |
|
24065
fc4022e50129
8041150: Avoid silly use of static methods in JavadocTester
jjg
parents:
23971
diff
changeset
|
125 |
tester.run(ARGS, TEST, NEGATED_TEST); |
10 | 126 |
tester.printSummary(); |
127 |
} |
|
128 |
||
129 |
/** |
|
130 |
* {@inheritDoc} |
|
131 |
*/ |
|
132 |
public String getBugId() { |
|
133 |
return BUG_ID; |
|
134 |
} |
|
135 |
||
136 |
/** |
|
137 |
* {@inheritDoc} |
|
138 |
*/ |
|
139 |
public String getBugName() { |
|
140 |
return getClass().getName(); |
|
141 |
} |
|
142 |
} |