# HG changeset patch # User hannesw # Date 1565116788 -7200 # Node ID dbca9d2b408076b78c2a1764af25d4fbceca1b3d # Parent 06d7236d6ef6f9356c058980d3bc17bb6fd768fb 8226765: Commentary on Javadoc comments Reviewed-by: jjg, rhalade, skoivu diff -r 06d7236d6ef6 -r dbca9d2b4080 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java Thu Jan 17 10:44:17 2019 -0500 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java Tue Aug 06 20:39:48 2019 +0200 @@ -61,34 +61,8 @@ public Void visitAttribute(AttributeTree tree, Consumer f) { String name = tree.getName().toString().toLowerCase(Locale.ENGLISH); switch (name) { - // See https://www.w3.org/TR/html-markup/global-attributes.html#common.attrs.event-handler - case "onabort": case "onblur": case "oncanplay": case "oncanplaythrough": - case "onchange": case "onclick": case "oncontextmenu": case "ondblclick": - case "ondrag": case "ondragend": case "ondragenter": case "ondragleave": - case "ondragover": case "ondragstart": case "ondrop": case "ondurationchange": - case "onemptied": case "onended": case "onerror": case "onfocus": case "oninput": - case "oninvalid": case "onkeydown": case "onkeypress": case "onkeyup": - case "onload": case "onloadeddata": case "onloadedmetadata": case "onloadstart": - case "onmousedown": case "onmousemove": case "onmouseout": case "onmouseover": - case "onmouseup": case "onmousewheel": case "onpause": case "onplay": - case "onplaying": case "onprogress": case "onratechange": case "onreadystatechange": - case "onreset": case "onscroll": case "onseeked": case "onseeking": - case "onselect": case "onshow": case "onstalled": case "onsubmit": case "onsuspend": - case "ontimeupdate": case "onvolumechange": case "onwaiting": - // See https://www.w3.org/TR/html4/sgml/dtd.html - // Most of the attributes that take a %Script are also defined as event handlers - // in HTML 5. The one exception is onunload. - // case "onchange": case "onclick": case "ondblclick": case "onfocus": - // case "onkeydown": case "onkeypress": case "onkeyup": case "onload": - // case "onmousedown": case "onmousemove": case "onmouseout": case "onmouseover": - // case "onmouseup": case "onreset": case "onselect": case "onsubmit": - case "onunload": - f.accept(getCurrentPath()); - break; - - // See https://www.w3.org/TR/html4/sgml/dtd.html - // https://www.w3.org/TR/html5/ + // https://www.w3.org/TR/html52/fullindex.html#attributes-table // These are all the attributes that take a %URI or a valid URL potentially surrounded // by spaces case "action": case "cite": case "classid": case "codebase": case "data": @@ -102,6 +76,14 @@ } } break; + // See https://www.w3.org/TR/html52/webappapis.html#events-event-handlers + // An event handler has a name, which always starts with "on" and is followed by + // the name of the event for which it is intended. + default: + if (name.startsWith("on")) { + f.accept(getCurrentPath()); + } + break; } return super.visitAttribute(tree, f); } diff -r 06d7236d6ef6 -r dbca9d2b4080 test/langtools/jdk/javadoc/tool/TestScriptInComment.java --- a/test/langtools/jdk/javadoc/tool/TestScriptInComment.java Thu Jan 17 10:44:17 2019 -0500 +++ b/test/langtools/jdk/javadoc/tool/TestScriptInComment.java Tue Aug 06 20:39:48 2019 +0200 @@ -23,7 +23,7 @@ /** * @test - * @bug 8138725 + * @bug 8138725 8226765 * @summary test --allow-script-in-comments * @modules jdk.javadoc/jdk.javadoc.internal.tool */ @@ -63,6 +63,10 @@ WS("< script >#ALERT", false, "-Xdoclint:none"), // script tag with invalid white space SP("", true), // script tag with an attribute ON("x", true), // event handler attribute + OME("1", true), // onmouseenter event handler attribute + OML("1", true), // onmouseleave event handler attribute + OFI("x", true), // onfocusin event handler attribute + OBE("x", true), // bogus/future event handler attribute URI("x", true); // javascript URI /**