8012375: Improve Javadoc framing

Reviewed-by: mduigou, jlaskey
This commit is contained in:
Bhavesh Patel 2013-05-03 08:52:33 -07:00
parent 09a04066fd
commit 64831179a9
2 changed files with 71 additions and 5 deletions

View file

@ -309,8 +309,41 @@ public class HtmlWriter {
String scriptCode = DocletConstants.NL + " targetPage = \"\" + window.location.search;" + DocletConstants.NL + String scriptCode = DocletConstants.NL + " targetPage = \"\" + window.location.search;" + DocletConstants.NL +
" if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL + " if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
" targetPage = targetPage.substring(1);" + DocletConstants.NL + " targetPage = targetPage.substring(1);" + DocletConstants.NL +
" if (targetPage.indexOf(\":\") != -1)" + DocletConstants.NL + " if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + DocletConstants.NL +
" targetPage = \"undefined\";" + DocletConstants.NL + " targetPage = \"undefined\";" + DocletConstants.NL +
" function validURL(url) {" + DocletConstants.NL +
" if (!(url.indexOf(\".html\") == url.length - 5))" + DocletConstants.NL +
" return false;" + DocletConstants.NL +
" var allowNumber = false;" + DocletConstants.NL +
" var allowSep = false;" + DocletConstants.NL +
" var seenDot = false;" + DocletConstants.NL +
" for (var i = 0; i < url.length - 5; i++) {" + DocletConstants.NL +
" var ch = url.charAt(i);" + DocletConstants.NL +
" if ('a' <= ch && ch <= 'z' ||" + DocletConstants.NL +
" 'A' <= ch && ch <= 'Z' ||" + DocletConstants.NL +
" ch == '$' ||" + DocletConstants.NL +
" ch == '_') {" + DocletConstants.NL +
" allowNumber = true;" + DocletConstants.NL +
" allowSep = true;" + DocletConstants.NL +
" } else if ('0' <= ch && ch <= '9'" + DocletConstants.NL +
" || ch == '-') {" + DocletConstants.NL +
" if (!allowNumber)" + DocletConstants.NL +
" return false;" + DocletConstants.NL +
" } else if (ch == '/' || ch == '.') {" + DocletConstants.NL +
" if (!allowSep)" + DocletConstants.NL +
" return false;" + DocletConstants.NL +
" allowNumber = false;" + DocletConstants.NL +
" allowSep = false;" + DocletConstants.NL +
" if (ch == '.')" + DocletConstants.NL +
" seenDot = true;" + DocletConstants.NL +
" if (ch == '/' && seenDot)" + DocletConstants.NL +
" return false;" + DocletConstants.NL +
" } else {" + DocletConstants.NL +
" return false;"+ DocletConstants.NL +
" }" + DocletConstants.NL +
" }" + DocletConstants.NL +
" return true;" + DocletConstants.NL +
" }" + DocletConstants.NL +
" function loadFrames() {" + DocletConstants.NL + " function loadFrames() {" + DocletConstants.NL +
" if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL + " if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
" top.classFrame.location = top.targetPage;" + DocletConstants.NL + " top.classFrame.location = top.targetPage;" + DocletConstants.NL +

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 4665566 4855876 7025314 * @bug 4665566 4855876 7025314 8012375
* @summary Verify that the output has the right javascript. * @summary Verify that the output has the right javascript.
* @author jamieh * @author jamieh
* @library ../lib/ * @library ../lib/
@ -35,7 +35,7 @@
public class TestJavascript extends JavadocTester { public class TestJavascript extends JavadocTester {
//Test information. //Test information.
private static final String BUG_ID = "4665566-4855876"; private static final String BUG_ID = "4665566-4855876-8012375";
//Javadoc arguments. //Javadoc arguments.
private static final String[] ARGS = new String[] { private static final String[] ARGS = new String[] {
@ -53,8 +53,41 @@ public class TestJavascript extends JavadocTester {
" targetPage = \"\" + window.location.search;" + NL + " targetPage = \"\" + window.location.search;" + NL +
" if (targetPage != \"\" && targetPage != \"undefined\")" + NL + " if (targetPage != \"\" && targetPage != \"undefined\")" + NL +
" targetPage = targetPage.substring(1);" + NL + " targetPage = targetPage.substring(1);" + NL +
" if (targetPage.indexOf(\":\") != -1)" + NL + " if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + NL +
" targetPage = \"undefined\";" + NL + " targetPage = \"undefined\";" + NL +
" function validURL(url) {" + NL +
" if (!(url.indexOf(\".html\") == url.length - 5))" + NL +
" return false;" + NL +
" var allowNumber = false;" + NL +
" var allowSep = false;" + NL +
" var seenDot = false;" + NL +
" for (var i = 0; i < url.length - 5; i++) {" + NL +
" var ch = url.charAt(i);" + NL +
" if ('a' <= ch && ch <= 'z' ||" + NL +
" 'A' <= ch && ch <= 'Z' ||" + NL +
" ch == '$' ||" + NL +
" ch == '_') {" + NL +
" allowNumber = true;" + NL +
" allowSep = true;" + NL +
" } else if ('0' <= ch && ch <= '9'" + NL +
" || ch == '-') {" + NL +
" if (!allowNumber)" + NL +
" return false;" + NL +
" } else if (ch == '/' || ch == '.') {" + NL +
" if (!allowSep)" + NL +
" return false;" + NL +
" allowNumber = false;" + NL +
" allowSep = false;" + NL +
" if (ch == '.')" + NL +
" seenDot = true;" + NL +
" if (ch == '/' && seenDot)" + NL +
" return false;" + NL +
" } else {" + NL +
" return false;" + NL +
" }" + NL +
" }" + NL +
" return true;" + NL +
" }" + NL +
" function loadFrames() {" + NL + " function loadFrames() {" + NL +
" if (targetPage != \"\" && targetPage != \"undefined\")" + NL + " if (targetPage != \"\" && targetPage != \"undefined\")" + NL +
" top.classFrame.location = top.targetPage;" + NL + " top.classFrame.location = top.targetPage;" + NL +