1 /*
   2  * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
   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  *
  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 4645058 4747738 4855054 8024756 8141492
  27  * @summary  Javascript IE load error when linked by -linkoffline
  28  *           Window title shouldn't change when loading left frames (javascript)
  29  * @author dkramer
  30  * @library ../lib
  31  * @modules jdk.javadoc
  32  * @build JavadocTester
  33  * @run main JavascriptWinTitle
  34  */
  35 
  36 public class JavascriptWinTitle extends JavadocTester {
  37 
  38     public static void main(String... args) throws Exception {
  39         JavascriptWinTitle tester = new JavascriptWinTitle();
  40         tester.runTests();
  41     }
  42 
  43     @Test
  44     void test() {
  45         javadoc("-d", "out",
  46                 "-doctitle", "Document Title",
  47                 "-windowtitle", "Window Title",
  48                 "-overview", testSrc("overview.html"),
  49                 "-linkoffline", "http://java.sun.com/j2se/1.4/docs/api", testSrc,
  50                 "-sourcepath", testSrc,
  51                 "p1", "p2");
  52         checkExit(Exit.OK);
  53         checkOutput("overview-summary.html", true,
  54                 "<script type=\"text/javascript\">",
  55                 "<body>");
  56 
  57         // Test that "onload" is not present in BODY tag:
  58         checkOutput("p1/package-summary.html", true, "<body>");
  59         checkOutput("overview-frame.html", true, "<body>");
  60         checkOutput("allclasses-frame.html", true, "<body>");
  61         checkOutput("p1/package-frame.html", true, "<body>");
  62 
  63         // Test that win title javascript is followed by NOSCRIPT code.
  64         checkOutput("p1/C.html", true,
  65                 "<script type=\"text/javascript\"><!--\n"
  66                 + "    try {\n"
  67                 + "        if (location.href.indexOf('is-external=true') == -1) {\n"
  68                 + "            parent.document.title=\"C (Window Title)\";\n"
  69                 + "        }\n"
  70                 + "    }\n"
  71                 + "    catch(err) {\n"
  72                 + "    }\n"
  73                 + "//-->\n");
  74     }
  75 }