From 7f35556a256241579f6f1b0905fd671bc1182af1 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Mon, 22 Nov 2021 00:49:57 -0800 Subject: [PATCH] Add GUI test for clicking on non-toggle summary --- src/librustdoc/html/static/js/main.js | 2 +- src/test/rustdoc-gui/src/lib2/lib.rs | 2 ++ src/test/rustdoc-gui/toggle-click-deadspace.goml | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/test/rustdoc-gui/toggle-click-deadspace.goml diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 908d3f65fd35b..32aa82195a962 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -891,7 +891,7 @@ function hideThemeButtonState() { if (e.target.tagName != "SUMMARY") { e.preventDefault(); } - }) + }); }); onEachLazy(document.getElementsByClassName("notable-traits"), function(e) { diff --git a/src/test/rustdoc-gui/src/lib2/lib.rs b/src/test/rustdoc-gui/src/lib2/lib.rs index f2e76b546c4af..79354ec874507 100644 --- a/src/test/rustdoc-gui/src/lib2/lib.rs +++ b/src/test/rustdoc-gui/src/lib2/lib.rs @@ -22,6 +22,8 @@ pub struct Foo { } impl Foo { + /// Some documentation + /// # A Heading pub fn a_method(&self) {} } diff --git a/src/test/rustdoc-gui/toggle-click-deadspace.goml b/src/test/rustdoc-gui/toggle-click-deadspace.goml new file mode 100644 index 0000000000000..4d08927a7bede --- /dev/null +++ b/src/test/rustdoc-gui/toggle-click-deadspace.goml @@ -0,0 +1,8 @@ +// This test ensures that clicking on a method summary, but not on the "[-]", +// doesn't toggle the
. +goto: file://|DOC_PATH|/test_docs/struct.Foo.html +assert-attribute: (".impl-items .rustdoc-toggle", {"open": ""}) +click: "h4.code-header" // This is the position of "pub" in "pub fn a_method" +assert-attribute: (".impl-items .rustdoc-toggle", {"open": ""}) +click: ".impl-items .rustdoc-toggle summary::before" // This is the position of "[-]" next to that pub fn. +assert-attribute-false: (".impl-items .rustdoc-toggle", {"open": ""})