author | bpatel |
Fri, 03 May 2013 08:52:33 -0700 | |
changeset 18398 | 1935600c6f34 |
parent 9067 | c0b85430843d |
child 18404 | a5aaa0341fec |
permissions | -rw-r--r-- |
10 | 1 |
/* |
18398 | 2 |
* Copyright (c) 2004, 2013, 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 |
|
18398 | 26 |
* @bug 4665566 4855876 7025314 8012375 |
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[] { |
|
42 |
"-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg", SRC_DIR + FS + "TestJavascript.java" |
|
43 |
}; |
|
44 |
||
45 |
//Input for string search tests. |
|
46 |
private static final String[][] TEST = { |
|
47 |
{BUG_ID + FS + "pkg" + FS + "C.html", |
|
9067
c0b85430843d
7025314: NLS: translatability violation on standard.properties
bpatel
parents:
7681
diff
changeset
|
48 |
"<a href=\"../index.html?pkg/C.html\" target=\"_top\">Frames</a>"}, |
10 | 49 |
{BUG_ID + FS + "TestJavascript.html", |
9067
c0b85430843d
7025314: NLS: translatability violation on standard.properties
bpatel
parents:
7681
diff
changeset
|
50 |
"<a href=\"index.html?TestJavascript.html\" target=\"_top\">Frames</a>"}, |
10 | 51 |
{BUG_ID + FS + "index.html", |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
52 |
"<script type=\"text/javascript\">" + NL + |
10 | 53 |
" targetPage = \"\" + window.location.search;" + NL + |
54 |
" if (targetPage != \"\" && targetPage != \"undefined\")" + NL + |
|
55 |
" targetPage = targetPage.substring(1);" + NL + |
|
18398 | 56 |
" if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + NL + |
10 | 57 |
" targetPage = \"undefined\";" + NL + |
18398 | 58 |
" function validURL(url) {" + NL + |
59 |
" if (!(url.indexOf(\".html\") == url.length - 5))" + NL + |
|
60 |
" return false;" + NL + |
|
61 |
" var allowNumber = false;" + NL + |
|
62 |
" var allowSep = false;" + NL + |
|
63 |
" var seenDot = false;" + NL + |
|
64 |
" for (var i = 0; i < url.length - 5; i++) {" + NL + |
|
65 |
" var ch = url.charAt(i);" + NL + |
|
66 |
" if ('a' <= ch && ch <= 'z' ||" + NL + |
|
67 |
" 'A' <= ch && ch <= 'Z' ||" + NL + |
|
68 |
" ch == '$' ||" + NL + |
|
69 |
" ch == '_') {" + NL + |
|
70 |
" allowNumber = true;" + NL + |
|
71 |
" allowSep = true;" + NL + |
|
72 |
" } else if ('0' <= ch && ch <= '9'" + NL + |
|
73 |
" || ch == '-') {" + NL + |
|
74 |
" if (!allowNumber)" + NL + |
|
75 |
" return false;" + NL + |
|
76 |
" } else if (ch == '/' || ch == '.') {" + NL + |
|
77 |
" if (!allowSep)" + NL + |
|
78 |
" return false;" + NL + |
|
79 |
" allowNumber = false;" + NL + |
|
80 |
" allowSep = false;" + NL + |
|
81 |
" if (ch == '.')" + NL + |
|
82 |
" seenDot = true;" + NL + |
|
83 |
" if (ch == '/' && seenDot)" + NL + |
|
84 |
" return false;" + NL + |
|
85 |
" } else {" + NL + |
|
86 |
" return false;" + NL + |
|
87 |
" }" + NL + |
|
88 |
" }" + NL + |
|
89 |
" return true;" + NL + |
|
90 |
" }" + NL + |
|
10 | 91 |
" function loadFrames() {" + NL + |
92 |
" if (targetPage != \"\" && targetPage != \"undefined\")" + NL + |
|
93 |
" top.classFrame.location = top.targetPage;" + NL + |
|
94 |
" }" + NL + |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
95 |
"</script>"}, |
10 | 96 |
|
97 |
//Make sure title javascript only runs if is-external is not true |
|
98 |
{BUG_ID + FS + "pkg" + FS + "C.html", |
|
99 |
" if (location.href.indexOf('is-external=true') == -1) {" + NL + |
|
100 |
" parent.document.title=\"C\";" + NL + |
|
101 |
" }"}, |
|
102 |
}; |
|
103 |
||
104 |
private static final String[][] NEGATED_TEST = NO_TEST; |
|
105 |
||
106 |
/** |
|
107 |
* The entry point of the test. |
|
108 |
* @param args the array of command line arguments. |
|
109 |
*/ |
|
110 |
public static void main(String[] args) { |
|
111 |
TestJavascript tester = new TestJavascript(); |
|
112 |
run(tester, ARGS, TEST, NEGATED_TEST); |
|
113 |
tester.printSummary(); |
|
114 |
} |
|
115 |
||
116 |
/** |
|
117 |
* {@inheritDoc} |
|
118 |
*/ |
|
119 |
public String getBugId() { |
|
120 |
return BUG_ID; |
|
121 |
} |
|
122 |
||
123 |
/** |
|
124 |
* {@inheritDoc} |
|
125 |
*/ |
|
126 |
public String getBugName() { |
|
127 |
return getClass().getName(); |
|
128 |
} |
|
129 |
} |