# HG changeset patch # User bpatel # Date 1486076123 28800 # Node ID 640eb9781ce5ee14baacf2b8689db8ccb047894a # Parent 1a1b1242f7aa1ef9d764008cde56419bb81e0a42 8173707: Javadoc generated pages should default to no-frames view Reviewed-by: jjg, ksrini diff -r 1a1b1242f7aa -r 640eb9781ce5 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java Thu Feb 02 14:34:21 2017 -0800 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java Thu Feb 02 14:55:23 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,10 +29,12 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; +import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; +import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; /** @@ -92,6 +94,15 @@ Content frame = getFrameDetails(); HtmlTree body = new HtmlTree(HtmlTag.BODY); body.addAttr(HtmlAttr.ONLOAD, "loadFrames()"); + String topFilePath = configuration.topFile.getPath(); + String javaScriptRefresh = "\nif (targetPage == \"\" || targetPage == \"undefined\")\n" + + " window.location.replace('" + topFilePath + "');\n"; + RawHtml scriptContent = new RawHtml(javaScriptRefresh.replace("\n", DocletConstants.NL)); + HtmlTree scriptTree = HtmlTree.SCRIPT(); + scriptTree.addContent(scriptContent); + body.addContent(scriptTree); + Content noScript = HtmlTree.NOSCRIPT(contents.noScriptMessage); + body.addContent(noScript); if (configuration.allowTag(HtmlTag.MAIN)) { HtmlTree main = HtmlTree.MAIN(frame); body.addContent(main); diff -r 1a1b1242f7aa -r 640eb9781ce5 langtools/test/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java --- a/langtools/test/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java Thu Feb 02 14:34:21 2017 -0800 +++ b/langtools/test/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java Thu Feb 02 14:55:23 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8162353 8164747 + * @bug 8162353 8164747 8173707 * @summary javadoc should provide a way to disable use of frames * @library /tools/lib ../lib * @modules @@ -323,10 +323,14 @@ } private void checkIndex() { - // the index.html page only contains frames in frames mode + // the index.html page only contains frames and Javascript to default to no-frames view, + // in frames mode checkOutput("index.html", frames, "", + "
\n" + + "\n" + + "\n" + "