test/com/sun/javadoc/testJavascript/TestJavascript.java

changeset 1829
c7c6bfe7fc1f
parent 942
148d3dc4e1e1
child 1835
536cad596942
     1.1 --- a/test/com/sun/javadoc/testJavascript/TestJavascript.java	Sun Apr 28 08:16:41 2013 +0100
     1.2 +++ b/test/com/sun/javadoc/testJavascript/TestJavascript.java	Fri May 03 08:52:33 2013 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -23,7 +23,7 @@
    1.11  
    1.12  /*
    1.13   * @test
    1.14 - * @bug      4665566 4855876 7025314
    1.15 + * @bug      4665566 4855876 7025314 8012375
    1.16   * @summary  Verify that the output has the right javascript.
    1.17   * @author   jamieh
    1.18   * @library  ../lib/
    1.19 @@ -35,7 +35,7 @@
    1.20  public class TestJavascript extends JavadocTester {
    1.21  
    1.22      //Test information.
    1.23 -    private static final String BUG_ID = "4665566-4855876";
    1.24 +    private static final String BUG_ID = "4665566-4855876-8012375";
    1.25  
    1.26      //Javadoc arguments.
    1.27      private static final String[] ARGS = new String[] {
    1.28 @@ -53,8 +53,41 @@
    1.29                          "    targetPage = \"\" + window.location.search;" + NL +
    1.30              "    if (targetPage != \"\" && targetPage != \"undefined\")" + NL +
    1.31              "        targetPage = targetPage.substring(1);" + NL +
    1.32 -            "    if (targetPage.indexOf(\":\") != -1)" + NL +
    1.33 +            "    if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + NL +
    1.34              "        targetPage = \"undefined\";" + NL +
    1.35 +            "    function validURL(url) {" + NL +
    1.36 +            "        if (!(url.indexOf(\".html\") == url.length - 5))" + NL +
    1.37 +            "            return false;" + NL +
    1.38 +            "        var allowNumber = false;" + NL +
    1.39 +            "        var allowSep = false;" + NL +
    1.40 +            "        var seenDot = false;" + NL +
    1.41 +            "        for (var i = 0; i < url.length - 5; i++) {" + NL +
    1.42 +            "            var ch = url.charAt(i);" + NL +
    1.43 +            "            if ('a' <= ch && ch <= 'z' ||" + NL +
    1.44 +            "                    'A' <= ch && ch <= 'Z' ||" + NL +
    1.45 +            "                    ch == '$' ||" + NL +
    1.46 +            "                    ch == '_') {" + NL +
    1.47 +            "                allowNumber = true;" + NL +
    1.48 +            "                allowSep = true;" + NL +
    1.49 +            "            } else if ('0' <= ch && ch <= '9'" + NL +
    1.50 +            "                    || ch == '-') {" + NL +
    1.51 +            "                if (!allowNumber)" + NL +
    1.52 +            "                     return false;" + NL +
    1.53 +            "            } else if (ch == '/' || ch == '.') {" + NL +
    1.54 +            "                if (!allowSep)" + NL +
    1.55 +            "                    return false;" + NL +
    1.56 +            "                allowNumber = false;" + NL +
    1.57 +            "                allowSep = false;" + NL +
    1.58 +            "                if (ch == '.')" + NL +
    1.59 +            "                     seenDot = true;" + NL +
    1.60 +            "                if (ch == '/' && seenDot)" + NL +
    1.61 +            "                     return false;" + NL +
    1.62 +            "            } else {" + NL +
    1.63 +            "                return false;" + NL +
    1.64 +            "            }" + NL +
    1.65 +            "        }" + NL +
    1.66 +            "        return true;" + NL +
    1.67 +            "    }" + NL +
    1.68              "    function loadFrames() {" + NL +
    1.69              "        if (targetPage != \"\" && targetPage != \"undefined\")" + NL +
    1.70              "             top.classFrame.location = top.targetPage;" + NL +

mercurial