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 */
23
24 /*
25 * @test
26 * @bug 4665566 4855876 8012375 8015998
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.
38 private static final String BUG_ID = "4665566-4855876-8012375";
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",
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 " var pos = url.indexOf(\".html\");" + NL +
60 " if (pos == -1 || pos != url.length - 5)" + NL +
61 " return false;" + NL +
62 " var allowNumber = false;" + NL +
63 " var allowSep = false;" + NL +
64 " var seenDot = false;" + NL +
65 " for (var i = 0; i < url.length - 5; i++) {" + NL +
66 " var ch = url.charAt(i);" + NL +
67 " if ('a' <= ch && ch <= 'z' ||" + NL +
68 " 'A' <= ch && ch <= 'Z' ||" + NL +
69 " ch == '$' ||" + NL +
70 " ch == '_') {" + NL +
71 " allowNumber = true;" + NL +
72 " allowSep = true;" + NL +
73 " } else if ('0' <= ch && ch <= '9'" + NL +
74 " || ch == '-') {" + NL +
75 " if (!allowNumber)" + NL +
76 " return false;" + NL +
77 " } else if (ch == '/' || ch == '.') {" + NL +
80 " allowNumber = false;" + NL +
81 " allowSep = false;" + NL +
82 " if (ch == '.')" + NL +
83 " seenDot = true;" + NL +
84 " if (ch == '/' && seenDot)" + NL +
85 " return false;" + NL +
86 " } else {" + NL +
87 " return false;" + NL +
88 " }" + NL +
89 " }" + NL +
90 " return true;" + NL +
91 " }" + NL +
92 " function loadFrames() {" + NL +
93 " if (targetPage != \"\" && targetPage != \"undefined\")" + NL +
94 " top.classFrame.location = top.targetPage;" + NL +
95 " }" + NL +
96 "</script>"},
97
98 //Make sure title javascript only runs if is-external is not true
99 {BUG_ID + FS + "pkg" + FS + "C.html",
100 " if (location.href.indexOf('is-external=true') == -1) {" + NL +
101 " parent.document.title=\"C\";" + NL +
102 " }"},
103 };
104
105 private static final String[][] NEGATED_TEST = NO_TEST;
106
107 /**
108 * The entry point of the test.
109 * @param args the array of command line arguments.
110 */
111 public static void main(String[] args) {
112 TestJavascript tester = new TestJavascript();
113 run(tester, ARGS, TEST, NEGATED_TEST);
114 tester.printSummary();
115 }
116
117 /**
118 * {@inheritDoc}
119 */
120 public String getBugId() {
121 return BUG_ID;
|
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 */
23
24 /*
25 * @test
26 * @bug 4665566 4855876 8012375 8015998 8024756 8151921
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.
38 private static final String BUG_ID = "4665566-4855876-8012375";
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",
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 " tmpTargetPage = \"\" + window.location.search;" + NL +
54 " if (tmpTargetPage != \"\" && tmpTargetPage != \"undefined\")" + NL +
55 " tmpTargetPage = tmpTargetPage.substring(1);" + NL +
56 " if (tmpTargetPage.indexOf(\":\") != -1 || (tmpTargetPage != \"\" && !validURL(tmpTargetPage)))" + NL +
57 " tmpTargetPage = \"undefined\";" + NL +
58 " targetPage = tmpTargetPage;" + NL +
59 " function validURL(url) {" + NL +
60 " var pos = url.indexOf(\".html\");" + NL +
61 " if (pos == -1 || pos != url.length - 5)" + NL +
62 " return false;" + NL +
63 " var allowNumber = false;" + NL +
64 " var allowSep = false;" + NL +
65 " var seenDot = false;" + NL +
66 " for (var i = 0; i < url.length - 5; i++) {" + NL +
67 " var ch = url.charAt(i);" + NL +
68 " if ('a' <= ch && ch <= 'z' ||" + NL +
69 " 'A' <= ch && ch <= 'Z' ||" + NL +
70 " ch == '$' ||" + NL +
71 " ch == '_') {" + NL +
72 " allowNumber = true;" + NL +
73 " allowSep = true;" + NL +
74 " } else if ('0' <= ch && ch <= '9'" + NL +
75 " || ch == '-') {" + NL +
76 " if (!allowNumber)" + NL +
77 " return false;" + NL +
78 " } else if (ch == '/' || ch == '.') {" + NL +
81 " allowNumber = false;" + NL +
82 " allowSep = false;" + NL +
83 " if (ch == '.')" + NL +
84 " seenDot = true;" + NL +
85 " if (ch == '/' && seenDot)" + NL +
86 " return false;" + NL +
87 " } else {" + NL +
88 " return false;" + NL +
89 " }" + NL +
90 " }" + NL +
91 " return true;" + NL +
92 " }" + NL +
93 " function loadFrames() {" + NL +
94 " if (targetPage != \"\" && targetPage != \"undefined\")" + NL +
95 " top.classFrame.location = top.targetPage;" + NL +
96 " }" + NL +
97 "</script>"},
98
99 //Make sure title javascript only runs if is-external is not true
100 {BUG_ID + FS + "pkg" + FS + "C.html",
101 " try {" + NL +
102 " if (location.href.indexOf('is-external=true') == -1) {" + NL +
103 " parent.document.title=\"C\";" + NL +
104 " }" + NL +
105 " }" + NL +
106 " catch(err) {" + NL +
107 " }"},
108 };
109
110 private static final String[][] NEGATED_TEST = NO_TEST;
111
112 /**
113 * The entry point of the test.
114 * @param args the array of command line arguments.
115 */
116 public static void main(String[] args) {
117 TestJavascript tester = new TestJavascript();
118 run(tester, ARGS, TEST, NEGATED_TEST);
119 tester.printSummary();
120 }
121
122 /**
123 * {@inheritDoc}
124 */
125 public String getBugId() {
126 return BUG_ID;
|