From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/rustdoc-gui/README.md | 34 +++ src/test/rustdoc-gui/anchor-navigable.goml | 11 + src/test/rustdoc-gui/anchors.goml | 34 +++ .../auto-hide-trait-implementations.goml | 13 + src/test/rustdoc-gui/basic-code.goml | 3 + src/test/rustdoc-gui/basic.goml | 4 + src/test/rustdoc-gui/check-code-blocks-margin.goml | 6 + src/test/rustdoc-gui/check_info_sign_position.goml | 11 + src/test/rustdoc-gui/code-blocks-overflow.goml | 8 + src/test/rustdoc-gui/code-color.goml | 30 +++ src/test/rustdoc-gui/code-sidebar-toggle.goml | 7 + src/test/rustdoc-gui/code-tags.goml | 20 ++ src/test/rustdoc-gui/default-settings.goml | 8 + src/test/rustdoc-gui/docblock-big-code-mobile.goml | 9 + .../docblock-code-block-line-number.goml | 22 ++ src/test/rustdoc-gui/docblock-details.goml | 23 ++ src/test/rustdoc-gui/docblock-table-overflow.goml | 21 ++ src/test/rustdoc-gui/duplicate-macro-reexport.goml | 14 + src/test/rustdoc-gui/escape-key.goml | 35 +++ src/test/rustdoc-gui/font-weight.goml | 44 +++ src/test/rustdoc-gui/hash-item-expansion.goml | 11 + src/test/rustdoc-gui/headers-color.goml | 117 ++++++++ src/test/rustdoc-gui/headings.goml | 258 ++++++++++++++++++ .../rustdoc-gui/huge-collection-of-constants.goml | 9 + src/test/rustdoc-gui/impl-default-expansion.goml | 3 + src/test/rustdoc-gui/implementors.goml | 35 +++ src/test/rustdoc-gui/item-info-overflow.goml | 31 +++ src/test/rustdoc-gui/item-info.goml | 32 +++ src/test/rustdoc-gui/item-summary-table.goml | 6 + src/test/rustdoc-gui/javascript-disabled.goml | 6 + src/test/rustdoc-gui/jump-to-def-background.goml | 43 +++ src/test/rustdoc-gui/label-next-to-symbol.goml | 78 ++++++ src/test/rustdoc-gui/list_code_block.goml | 4 + src/test/rustdoc-gui/mobile.goml | 30 +++ src/test/rustdoc-gui/module-items-font.goml | 67 +++++ .../rustdoc-gui/overflow-tooltip-information.goml | 8 + src/test/rustdoc-gui/pocket-menu.goml | 77 ++++++ src/test/rustdoc-gui/run-on-hover.goml | 7 + src/test/rustdoc-gui/rust-logo.goml | 78 ++++++ src/test/rustdoc-gui/search-filter.goml | 83 ++++++ src/test/rustdoc-gui/search-input-mobile.goml | 11 + src/test/rustdoc-gui/search-input.goml | 23 ++ src/test/rustdoc-gui/search-reexport.goml | 33 +++ src/test/rustdoc-gui/search-result-color.goml | 98 +++++++ .../rustdoc-gui/search-result-description.goml | 5 + src/test/rustdoc-gui/search-result-display.goml | 42 +++ .../rustdoc-gui/search-result-go-to-first.goml | 19 ++ src/test/rustdoc-gui/search-result-keyword.goml | 13 + .../search-tab-change-title-fn-sig.goml | 74 ++++++ src/test/rustdoc-gui/settings.goml | 158 +++++++++++ src/test/rustdoc-gui/shortcuts.goml | 13 + src/test/rustdoc-gui/sidebar-macro-reexport.goml | 5 + src/test/rustdoc-gui/sidebar-mobile.goml | 64 +++++ .../rustdoc-gui/sidebar-source-code-display.goml | 254 ++++++++++++++++++ src/test/rustdoc-gui/sidebar-source-code.goml | 45 ++++ src/test/rustdoc-gui/sidebar.goml | 88 ++++++ src/test/rustdoc-gui/source-anchor-scroll.goml | 20 ++ src/test/rustdoc-gui/source-code-page.goml | 49 ++++ src/test/rustdoc-gui/src-font-size.goml | 11 + src/test/rustdoc-gui/src/lib2/Cargo.lock | 14 + src/test/rustdoc-gui/src/lib2/Cargo.toml | 10 + .../rustdoc-gui/src/lib2/another_folder/mod.rs | 3 + .../src/lib2/another_folder/sub_mod/mod.rs | 1 + src/test/rustdoc-gui/src/lib2/another_mod/mod.rs | 1 + .../rustdoc-gui/src/lib2/implementors/Cargo.lock | 7 + .../rustdoc-gui/src/lib2/implementors/Cargo.toml | 7 + src/test/rustdoc-gui/src/lib2/implementors/lib.rs | 20 ++ src/test/rustdoc-gui/src/lib2/lib.rs | 145 ++++++++++ .../rustdoc-gui/src/link_to_definition/Cargo.lock | 7 + .../rustdoc-gui/src/link_to_definition/Cargo.toml | 7 + src/test/rustdoc-gui/src/link_to_definition/lib.rs | 35 +++ .../rustdoc-gui/src/settings/.cargo/config.toml | 2 + src/test/rustdoc-gui/src/settings/Cargo.lock | 7 + src/test/rustdoc-gui/src/settings/Cargo.toml | 7 + src/test/rustdoc-gui/src/settings/lib.rs | 1 + src/test/rustdoc-gui/src/staged_api/Cargo.lock | 7 + src/test/rustdoc-gui/src/staged_api/Cargo.toml | 11 + src/test/rustdoc-gui/src/staged_api/lib.rs | 10 + src/test/rustdoc-gui/src/test_docs/Cargo.lock | 7 + src/test/rustdoc-gui/src/test_docs/Cargo.toml | 13 + src/test/rustdoc-gui/src/test_docs/build.rs | 15 ++ src/test/rustdoc-gui/src/test_docs/lib.rs | 295 +++++++++++++++++++++ src/test/rustdoc-gui/src/test_docs/macros.rs | 4 + src/test/rustdoc-gui/theme-change.goml | 32 +++ src/test/rustdoc-gui/theme-in-history.goml | 28 ++ src/test/rustdoc-gui/toggle-click-deadspace.goml | 12 + src/test/rustdoc-gui/toggle-docs-mobile.goml | 33 +++ src/test/rustdoc-gui/toggle-docs.goml | 42 +++ src/test/rustdoc-gui/toggle-implementors.goml | 4 + .../rustdoc-gui/toggled-open-implementations.goml | 5 + src/test/rustdoc-gui/trait-sidebar-item-order.goml | 8 + src/test/rustdoc-gui/type-declation-overflow.goml | 37 +++ 92 files changed, 3202 insertions(+) create mode 100644 src/test/rustdoc-gui/README.md create mode 100644 src/test/rustdoc-gui/anchor-navigable.goml create mode 100644 src/test/rustdoc-gui/anchors.goml create mode 100644 src/test/rustdoc-gui/auto-hide-trait-implementations.goml create mode 100644 src/test/rustdoc-gui/basic-code.goml create mode 100644 src/test/rustdoc-gui/basic.goml create mode 100644 src/test/rustdoc-gui/check-code-blocks-margin.goml create mode 100644 src/test/rustdoc-gui/check_info_sign_position.goml create mode 100644 src/test/rustdoc-gui/code-blocks-overflow.goml create mode 100644 src/test/rustdoc-gui/code-color.goml create mode 100644 src/test/rustdoc-gui/code-sidebar-toggle.goml create mode 100644 src/test/rustdoc-gui/code-tags.goml create mode 100644 src/test/rustdoc-gui/default-settings.goml create mode 100644 src/test/rustdoc-gui/docblock-big-code-mobile.goml create mode 100644 src/test/rustdoc-gui/docblock-code-block-line-number.goml create mode 100644 src/test/rustdoc-gui/docblock-details.goml create mode 100644 src/test/rustdoc-gui/docblock-table-overflow.goml create mode 100644 src/test/rustdoc-gui/duplicate-macro-reexport.goml create mode 100644 src/test/rustdoc-gui/escape-key.goml create mode 100644 src/test/rustdoc-gui/font-weight.goml create mode 100644 src/test/rustdoc-gui/hash-item-expansion.goml create mode 100644 src/test/rustdoc-gui/headers-color.goml create mode 100644 src/test/rustdoc-gui/headings.goml create mode 100644 src/test/rustdoc-gui/huge-collection-of-constants.goml create mode 100644 src/test/rustdoc-gui/impl-default-expansion.goml create mode 100644 src/test/rustdoc-gui/implementors.goml create mode 100644 src/test/rustdoc-gui/item-info-overflow.goml create mode 100644 src/test/rustdoc-gui/item-info.goml create mode 100644 src/test/rustdoc-gui/item-summary-table.goml create mode 100644 src/test/rustdoc-gui/javascript-disabled.goml create mode 100644 src/test/rustdoc-gui/jump-to-def-background.goml create mode 100644 src/test/rustdoc-gui/label-next-to-symbol.goml create mode 100644 src/test/rustdoc-gui/list_code_block.goml create mode 100644 src/test/rustdoc-gui/mobile.goml create mode 100644 src/test/rustdoc-gui/module-items-font.goml create mode 100644 src/test/rustdoc-gui/overflow-tooltip-information.goml create mode 100644 src/test/rustdoc-gui/pocket-menu.goml create mode 100644 src/test/rustdoc-gui/run-on-hover.goml create mode 100644 src/test/rustdoc-gui/rust-logo.goml create mode 100644 src/test/rustdoc-gui/search-filter.goml create mode 100644 src/test/rustdoc-gui/search-input-mobile.goml create mode 100644 src/test/rustdoc-gui/search-input.goml create mode 100644 src/test/rustdoc-gui/search-reexport.goml create mode 100644 src/test/rustdoc-gui/search-result-color.goml create mode 100644 src/test/rustdoc-gui/search-result-description.goml create mode 100644 src/test/rustdoc-gui/search-result-display.goml create mode 100644 src/test/rustdoc-gui/search-result-go-to-first.goml create mode 100644 src/test/rustdoc-gui/search-result-keyword.goml create mode 100644 src/test/rustdoc-gui/search-tab-change-title-fn-sig.goml create mode 100644 src/test/rustdoc-gui/settings.goml create mode 100644 src/test/rustdoc-gui/shortcuts.goml create mode 100644 src/test/rustdoc-gui/sidebar-macro-reexport.goml create mode 100644 src/test/rustdoc-gui/sidebar-mobile.goml create mode 100644 src/test/rustdoc-gui/sidebar-source-code-display.goml create mode 100644 src/test/rustdoc-gui/sidebar-source-code.goml create mode 100644 src/test/rustdoc-gui/sidebar.goml create mode 100644 src/test/rustdoc-gui/source-anchor-scroll.goml create mode 100644 src/test/rustdoc-gui/source-code-page.goml create mode 100644 src/test/rustdoc-gui/src-font-size.goml create mode 100644 src/test/rustdoc-gui/src/lib2/Cargo.lock create mode 100644 src/test/rustdoc-gui/src/lib2/Cargo.toml create mode 100644 src/test/rustdoc-gui/src/lib2/another_folder/mod.rs create mode 100644 src/test/rustdoc-gui/src/lib2/another_folder/sub_mod/mod.rs create mode 100644 src/test/rustdoc-gui/src/lib2/another_mod/mod.rs create mode 100644 src/test/rustdoc-gui/src/lib2/implementors/Cargo.lock create mode 100644 src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml create mode 100644 src/test/rustdoc-gui/src/lib2/implementors/lib.rs create mode 100644 src/test/rustdoc-gui/src/lib2/lib.rs create mode 100644 src/test/rustdoc-gui/src/link_to_definition/Cargo.lock create mode 100644 src/test/rustdoc-gui/src/link_to_definition/Cargo.toml create mode 100644 src/test/rustdoc-gui/src/link_to_definition/lib.rs create mode 100644 src/test/rustdoc-gui/src/settings/.cargo/config.toml create mode 100644 src/test/rustdoc-gui/src/settings/Cargo.lock create mode 100644 src/test/rustdoc-gui/src/settings/Cargo.toml create mode 100644 src/test/rustdoc-gui/src/settings/lib.rs create mode 100644 src/test/rustdoc-gui/src/staged_api/Cargo.lock create mode 100644 src/test/rustdoc-gui/src/staged_api/Cargo.toml create mode 100644 src/test/rustdoc-gui/src/staged_api/lib.rs create mode 100644 src/test/rustdoc-gui/src/test_docs/Cargo.lock create mode 100644 src/test/rustdoc-gui/src/test_docs/Cargo.toml create mode 100644 src/test/rustdoc-gui/src/test_docs/build.rs create mode 100644 src/test/rustdoc-gui/src/test_docs/lib.rs create mode 100644 src/test/rustdoc-gui/src/test_docs/macros.rs create mode 100644 src/test/rustdoc-gui/theme-change.goml create mode 100644 src/test/rustdoc-gui/theme-in-history.goml create mode 100644 src/test/rustdoc-gui/toggle-click-deadspace.goml create mode 100644 src/test/rustdoc-gui/toggle-docs-mobile.goml create mode 100644 src/test/rustdoc-gui/toggle-docs.goml create mode 100644 src/test/rustdoc-gui/toggle-implementors.goml create mode 100644 src/test/rustdoc-gui/toggled-open-implementations.goml create mode 100644 src/test/rustdoc-gui/trait-sidebar-item-order.goml create mode 100644 src/test/rustdoc-gui/type-declation-overflow.goml (limited to 'src/test/rustdoc-gui') diff --git a/src/test/rustdoc-gui/README.md b/src/test/rustdoc-gui/README.md new file mode 100644 index 000000000..d9854e2e7 --- /dev/null +++ b/src/test/rustdoc-gui/README.md @@ -0,0 +1,34 @@ +The tests present here are used to test the generated HTML from rustdoc. The +goal is to prevent unsound/unexpected GUI changes. + +This is using the [browser-ui-test] framework to do so. It works as follows: + +It wraps [puppeteer] to send commands to a web browser in order to navigate and +test what's being currently displayed in the web page. + +You can find more information and its documentation in its [repository][browser-ui-test]. + +If you need to have more information on the tests run, you can use `--test-args`: + +```bash +$ ./x.py test src/test/rustdoc-gui --stage 1 --test-args --debug +``` + +If you don't want to run in headless mode (helpful to debug sometimes), you can use +`--no-headless`: + +```bash +$ ./x.py test src/test/rustdoc-gui --stage 1 --test-args --no-headless +``` + +To see the supported options, use `--help`. + +Important to be noted: if the chromium instance crashes when you run it, you might need to +use `--no-sandbox` to make it work: + +```bash +$ ./x.py test src/test/rustdoc-gui --stage 1 --test-args --no-sandbox +``` + +[browser-ui-test]: https://github.com/GuillaumeGomez/browser-UI-test/ +[puppeteer]: https://pptr.dev/ diff --git a/src/test/rustdoc-gui/anchor-navigable.goml b/src/test/rustdoc-gui/anchor-navigable.goml new file mode 100644 index 000000000..424c31223 --- /dev/null +++ b/src/test/rustdoc-gui/anchor-navigable.goml @@ -0,0 +1,11 @@ +// The `impl Foo` heading underneath `Implementations` has a § +// anchor to its left (used for linking to that heading). The anchor only shows +// up when hovering the `impl Foo`. This test ensures there's no gap between the +// anchor and the `impl Foo`. If there were a gap, this would cause an annoying +// problem: you hover `impl Foo` to see the anchor, then when you move your +// mouse to the left, the anchor disappears before you reach it. +goto: file://|DOC_PATH|/test_docs/struct.Foo.html +// We check that ".item-info" is bigger than its content. +move-cursor-to: ".impl" +assert-property: (".impl > a.anchor", {"offsetWidth": "9"}) +assert-css: (".impl > a.anchor", {"left": "-8px"}) diff --git a/src/test/rustdoc-gui/anchors.goml b/src/test/rustdoc-gui/anchors.goml new file mode 100644 index 000000000..84b8bbd1b --- /dev/null +++ b/src/test/rustdoc-gui/anchors.goml @@ -0,0 +1,34 @@ +// This test is to ensure that the anchors (`§`) have the expected color and position. +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html +show-text: true + +// This is needed to ensure that the text color is computed. +show-text: true + +// Set the theme to light. +local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} +// We reload the page so the local storage settings are being used. +reload: + +assert-css: ("#toggle-all-docs", {"color": "rgb(0, 0, 0)"}) +assert-css: (".fqn .in-band a:nth-of-type(1)", {"color": "rgb(0, 0, 0)"}) +assert-css: (".fqn .in-band a:nth-of-type(2)", {"color": "rgb(173, 55, 138)"}) +assert-css: (".srclink", {"color": "rgb(56, 115, 173)"}) + +move-cursor-to: ".main-heading .srclink" +assert-css: (".srclink", {"text-decoration": "underline solid rgb(56, 115, 173)"}) + +assert-css: ("#top-doc-prose-title", {"color": "rgb(0, 0, 0)"}) + +assert-css: (".sidebar a", {"color": "rgb(53, 109, 164)"}) +assert-css: (".in-band a", {"color": "rgb(0, 0, 0)"}) + +// We move the cursor over the "Implementations" title so the anchor is displayed. +move-cursor-to: "h2#implementations" +assert-css: ("h2#implementations a.anchor", {"color": "rgb(0, 0, 0)"}) + +// Same thing with the impl block title. +move-cursor-to: "#impl-HeavilyDocumentedStruct" +assert-css: ("#impl-HeavilyDocumentedStruct a.anchor", {"color": "rgb(0, 0, 0)"}) + +assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"}) diff --git a/src/test/rustdoc-gui/auto-hide-trait-implementations.goml b/src/test/rustdoc-gui/auto-hide-trait-implementations.goml new file mode 100644 index 000000000..7b1358fed --- /dev/null +++ b/src/test/rustdoc-gui/auto-hide-trait-implementations.goml @@ -0,0 +1,13 @@ +// Checks that the setting "auto hide trait implementations" is working as expected. +goto: file://|DOC_PATH|/test_docs/struct.Foo.html + +// By default, the trait implementations are not collapsed. +assert-attribute: ("#trait-implementations-list > details", {"open": ""}, ALL) + +// We now set the setting to auto hide all trait implementations. +local-storage: {"rustdoc-auto-hide-trait-implementations": "true" } +// We reload to ensure the trait implementations are collapsed as expected. +reload: + +// We now check that all matching elements don't have the open attributes. +assert-attribute-false: ("#trait-implementations-list > details", {"open": ""}, ALL) diff --git a/src/test/rustdoc-gui/basic-code.goml b/src/test/rustdoc-gui/basic-code.goml new file mode 100644 index 000000000..27deb2c98 --- /dev/null +++ b/src/test/rustdoc-gui/basic-code.goml @@ -0,0 +1,3 @@ +goto: file://|DOC_PATH|/test_docs/index.html +click: ".srclink" +assert-count: (".line-numbers", 1) diff --git a/src/test/rustdoc-gui/basic.goml b/src/test/rustdoc-gui/basic.goml new file mode 100644 index 000000000..239e51a91 --- /dev/null +++ b/src/test/rustdoc-gui/basic.goml @@ -0,0 +1,4 @@ +goto: file://|DOC_PATH|/test_docs/index.html +assert: ("#functions") +goto: ./struct.Foo.html +assert: ("div.item-decl") diff --git a/src/test/rustdoc-gui/check-code-blocks-margin.goml b/src/test/rustdoc-gui/check-code-blocks-margin.goml new file mode 100644 index 000000000..f6266eba7 --- /dev/null +++ b/src/test/rustdoc-gui/check-code-blocks-margin.goml @@ -0,0 +1,6 @@ +// This test ensures that the docblock elements have the appropriate left margin. +goto: file://|DOC_PATH|/test_docs/fn.foo.html +// The top docblock elements shouldn't have left margin... +assert-css: ("#main-content .docblock.item-decl", {"margin-left": "0px"}) +// ... but all the others should! +assert-css: ("#main-content .docblock:not(.item-decl)", {"margin-left": "24px"}) diff --git a/src/test/rustdoc-gui/check_info_sign_position.goml b/src/test/rustdoc-gui/check_info_sign_position.goml new file mode 100644 index 000000000..3bed7a0a0 --- /dev/null +++ b/src/test/rustdoc-gui/check_info_sign_position.goml @@ -0,0 +1,11 @@ +// This test checks the position of the information on the code blocks (like +// `compile_fail` or `ignore`). +goto: file://|DOC_PATH|/test_docs/index.html +goto: ./fn.check_list_code_block.html +// If the codeblock is the first element of the docblock, the information tooltip must have +// have some top margin to avoid going over the toggle (the "[+]"). +assert-css: (".docblock > .information > .compile_fail", { "margin-top": "16px" }) +// Checks that the other codeblocks don't have this top margin. +assert-css: ("ol > li > .information > .compile_fail", { "margin-top": "0px" }) +assert-css: ("ol > li > .information > .ignore", { "margin-top": "0px" }) +assert-css: (".docblock > .information > .ignore", { "margin-top": "0px" }) diff --git a/src/test/rustdoc-gui/code-blocks-overflow.goml b/src/test/rustdoc-gui/code-blocks-overflow.goml new file mode 100644 index 000000000..f93f3f0ae --- /dev/null +++ b/src/test/rustdoc-gui/code-blocks-overflow.goml @@ -0,0 +1,8 @@ +// This test ensures that codeblocks content don't overflow. +goto: file://|DOC_PATH|/lib2/sub_mod/struct.Foo.html +size: (1080, 600) +// There should be two codeblocks: a rust one and a non-rust one. +assert-count: (".docblock > .example-wrap", 2) +assert: ".docblock > .example-wrap > .language-txt" +assert: ".docblock > .example-wrap > .rust-example-rendered" +assert-css: (".docblock > .example-wrap > pre", {"width": "785.25px", "overflow-x": "auto"}, ALL) diff --git a/src/test/rustdoc-gui/code-color.goml b/src/test/rustdoc-gui/code-color.goml new file mode 100644 index 000000000..2f95bfb6b --- /dev/null +++ b/src/test/rustdoc-gui/code-color.goml @@ -0,0 +1,30 @@ +// The ayu theme has a different color for the "" tags in the doc blocks. We need to +// check that the rule isn't applied on other "" elements. +// +// While we're at it, we also check it for the other themes. +goto: file://|DOC_PATH|/test_docs/fn.foo.html +// If the text isn't displayed, the browser doesn't compute color style correctly... +show-text: true +// Set the theme to dark. +local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"} +// We reload the page so the local storage settings are being used. +reload: + +assert-css: (".docblock pre > code", {"color": "rgb(221, 221, 221)"}, ALL) +assert-css: (".docblock > p > code", {"color": "rgb(221, 221, 221)"}, ALL) + +// Set the theme to ayu. +local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"} +// We reload the page so the local storage settings are being used. +reload: + +assert-css: (".docblock pre > code", {"color": "rgb(230, 225, 207)"}, ALL) +assert-css: (".docblock > p > code", {"color": "rgb(255, 180, 84)"}, ALL) + +// Set the theme to light. +local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} +// We reload the page so the local storage settings are being used. +reload: + +assert-css: (".docblock pre > code", {"color": "rgb(0, 0, 0)"}, ALL) +assert-css: (".docblock > p > code", {"color": "rgb(0, 0, 0)"}, ALL) diff --git a/src/test/rustdoc-gui/code-sidebar-toggle.goml b/src/test/rustdoc-gui/code-sidebar-toggle.goml new file mode 100644 index 000000000..867db0569 --- /dev/null +++ b/src/test/rustdoc-gui/code-sidebar-toggle.goml @@ -0,0 +1,7 @@ +// This test checks that the source code pages sidebar toggle is working as expected. +goto: file://|DOC_PATH|/test_docs/index.html +click: ".srclink" +wait-for: "#sidebar-toggle" +click: "#sidebar-toggle" +fail: true +assert-css: ("#source-sidebar", { "left": "-300px" }) diff --git a/src/test/rustdoc-gui/code-tags.goml b/src/test/rustdoc-gui/code-tags.goml new file mode 100644 index 000000000..200569a28 --- /dev/null +++ b/src/test/rustdoc-gui/code-tags.goml @@ -0,0 +1,20 @@ +// This test ensures that items and documentation code blocks are wrapped in

+goto: file://|DOC_PATH|/test_docs/fn.foo.html
+size: (1080, 600)
+// There should be three doc codeblocks
+// Check that their content is inside 

+assert-count: (".example-wrap pre > code", 3)
+// Check that function signature is inside 

+assert: "pre.rust.fn > code"
+
+goto: file://|DOC_PATH|/test_docs/struct.Foo.html
+assert: "pre.rust.struct > code"
+
+goto: file://|DOC_PATH|/test_docs/enum.AnEnum.html
+assert: "pre.rust.enum > code"
+
+goto: file://|DOC_PATH|/test_docs/trait.AnotherOne.html
+assert: "pre.rust.trait > code"
+
+goto: file://|DOC_PATH|/test_docs/type.SomeType.html
+assert: "pre.rust.typedef > code"
diff --git a/src/test/rustdoc-gui/default-settings.goml b/src/test/rustdoc-gui/default-settings.goml
new file mode 100644
index 000000000..90f0b087a
--- /dev/null
+++ b/src/test/rustdoc-gui/default-settings.goml
@@ -0,0 +1,8 @@
+// This test ensures that the default settings are correctly applied.
+//
+// The "settings" crate uses "ayu" as default setting, which is what we will
+// check.
+goto: file://|DOC_PATH|/settings/index.html
+// Wait a bit to be sure the default theme is applied.
+// If the theme isn't applied, the command will time out.
+wait-for-css: ("body", {"background-color": "rgb(15, 20, 25)"})
diff --git a/src/test/rustdoc-gui/docblock-big-code-mobile.goml b/src/test/rustdoc-gui/docblock-big-code-mobile.goml
new file mode 100644
index 000000000..02f79f1fc
--- /dev/null
+++ b/src/test/rustdoc-gui/docblock-big-code-mobile.goml
@@ -0,0 +1,9 @@
+// If we have a long ``, we need to ensure that it'll be fully displayed on mobile, meaning
+// that it'll be on two lines.
+emulate: "iPhone 8" // it has the following size: (375, 667)
+goto: file://|DOC_PATH|/test_docs/long_code_block/index.html
+// We now check that the block is on two lines:
+show-text: true // We need to enable text draw to be able to have the "real" size
+// Little explanations for this test: if the text wasn't displayed on two lines, it would take
+// around 20px (which is the font size).
+assert-property: (".docblock p > code", {"offsetHeight": "44"})
diff --git a/src/test/rustdoc-gui/docblock-code-block-line-number.goml b/src/test/rustdoc-gui/docblock-code-block-line-number.goml
new file mode 100644
index 000000000..baf9651c4
--- /dev/null
+++ b/src/test/rustdoc-gui/docblock-code-block-line-number.goml
@@ -0,0 +1,22 @@
+// Checks that the setting "line numbers" is working as expected.
+goto: file://|DOC_PATH|/test_docs/fn.foo.html
+
+// We check that without this setting, there is no line number displayed.
+assert-false: "pre.line-number"
+
+// We now set the setting to show the line numbers on code examples.
+local-storage: {"rustdoc-line-numbers": "true" }
+// We reload to make the line numbers appear.
+reload:
+
+// We wait for them to be added into the DOM by the JS...
+wait-for: "pre.line-number"
+// If the test didn't fail, it means that it was found!
+// Let's now check some CSS properties...
+assert-css: ("pre.line-number", {
+    "margin": "0px",
+    "padding": "13px 8px",
+    "text-align": "right",
+})
+// The first code block has two lines so let's check its `
` elements lists both of them.
+assert-text: ("pre.line-number", "1\n2")
diff --git a/src/test/rustdoc-gui/docblock-details.goml b/src/test/rustdoc-gui/docblock-details.goml
new file mode 100644
index 000000000..f6287ade2
--- /dev/null
+++ b/src/test/rustdoc-gui/docblock-details.goml
@@ -0,0 +1,23 @@
+// This ensures that the `
`/`` elements are displayed as expected. +goto: file://|DOC_PATH|/test_docs/details/struct.Details.html +show-text: true +local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} +reload: + +// We first check that the headers in the `.top-doc` doc block still have their +// bottom border. +assert-text: (".top-doc .docblock > h3", "Hello") +assert-css: ( + ".top-doc .docblock > h3", + {"border-bottom": "1px solid rgb(210, 210, 210)"}, +) +// We now check that the `` doesn't have a bottom border and has the correct display. +assert-css: ( + ".top-doc .docblock summary h4", + {"border-bottom": "0px none rgb(210, 210, 210)"}, +) +// This allows to ensure that summary is on one line only! +assert-property: (".top-doc .docblock summary h4", {"offsetHeight": "33"}) +assert-css: (".top-doc .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"}) +// So `33 + 15 + 5` == `53` +assert-property: (".top-doc .docblock summary", {"offsetHeight": "53"}) diff --git a/src/test/rustdoc-gui/docblock-table-overflow.goml b/src/test/rustdoc-gui/docblock-table-overflow.goml new file mode 100644 index 000000000..af76d2ea4 --- /dev/null +++ b/src/test/rustdoc-gui/docblock-table-overflow.goml @@ -0,0 +1,21 @@ +// This test ensures that the type declaration content overflow is handled inside the
 directly.
+goto: file://|DOC_PATH|/lib2/long_table/struct.Foo.html
+// We set a fixed size so there is no chance of "random" resize.
+size: (1100, 800)
+// Logically, the ".docblock" and the "

" should have the same scroll width. +compare-elements-property: (".top-doc .docblock", ".top-doc .docblock > p", ["scrollWidth"]) +assert-property: (".top-doc .docblock", {"scrollWidth": "801"}) +// However, since there is overflow in the , its scroll width is bigger. +assert-property: (".top-doc .docblock table", {"scrollWidth": "1573"}) + +// Checking it works on other doc blocks as well... + +// Logically, the ".docblock" and the "

" should have the same scroll width. +compare-elements-property: ( + "#implementations-list > details .docblock", + "#implementations-list > details .docblock > p", + ["scrollWidth"], +) +assert-property: ("#implementations-list > details .docblock", {"scrollWidth": "801"}) +// However, since there is overflow in the

, its scroll width is bigger. +assert-property: ("#implementations-list > details .docblock table", {"scrollWidth": "1573"}) diff --git a/src/test/rustdoc-gui/duplicate-macro-reexport.goml b/src/test/rustdoc-gui/duplicate-macro-reexport.goml new file mode 100644 index 000000000..9ea599062 --- /dev/null +++ b/src/test/rustdoc-gui/duplicate-macro-reexport.goml @@ -0,0 +1,14 @@ +// This test ensures that there is no macro duplicates in the sidebar. +goto: file://|DOC_PATH|/test_docs/macro.a.html +// Waiting for the elements in the sidebar to be rendered. +wait-for: ".sidebar-elems .macro" +// Check there is only one macro named "a" listed in the sidebar. +assert-count: ( + "//*[@class='sidebar-elems']//*[@class='block macro']//li/a[text()='a']", + 1, +) +// Check there is only one macro named "b" listed in the sidebar. +assert-count: ( + "//*[@class='sidebar-elems']//*[@class='block macro']//li/a[text()='b']", + 1, +) diff --git a/src/test/rustdoc-gui/escape-key.goml b/src/test/rustdoc-gui/escape-key.goml new file mode 100644 index 000000000..a5afb037d --- /dev/null +++ b/src/test/rustdoc-gui/escape-key.goml @@ -0,0 +1,35 @@ +// This test ensures that the "Escape" shortcut is handled correctly based on the +// current content displayed. +goto: file://|DOC_PATH|/test_docs/index.html +// First, we check that the search results are hidden when the Escape key is pressed. +write: (".search-input", "test") +// To be SURE that the search will be run. +press-key: 'Enter' +wait-for: "#search h1" // The search element is empty before the first search +// Check that the currently displayed element is search. +wait-for: "#alternative-display #search" +assert-attribute: ("#main-content", {"class": "content hidden"}) +assert-document-property: ({"URL": "index.html?search=test"}, ENDS_WITH) +press-key: "Escape" +// Checks that search is no longer in the displayed content. +wait-for: "#not-displayed #search" +assert-false: "#alternative-display #search" +assert-attribute: ("#main-content", {"class": "content"}) +assert-document-property: ({"URL": "index.html"}, [ENDS_WITH]) + +// Check that focusing the search input brings back the search results +focus: ".search-input" +wait-for: "#alternative-display #search" +assert-attribute: ("#main-content", {"class": "content hidden"}) +assert-document-property: ({"URL": "index.html?search=test"}, ENDS_WITH) + +// Check that Escape hides the search results when a search result is focused. +focus: ".search-input" +assert: ".search-input:focus" +press-key: "ArrowDown" +assert-false: ".search-input:focus" +assert: "#results a:focus" +press-key: "Escape" +wait-for: "#not-displayed #search" +assert-false: "#alternative-display #search" +assert-attribute: ("#main-content", {"class": "content"}) diff --git a/src/test/rustdoc-gui/font-weight.goml b/src/test/rustdoc-gui/font-weight.goml new file mode 100644 index 000000000..5f29fde66 --- /dev/null +++ b/src/test/rustdoc-gui/font-weight.goml @@ -0,0 +1,44 @@ +// This test checks that the font weight is correctly applied. +goto: file://|DOC_PATH|/lib2/struct.Foo.html +assert-css: ("//*[@class='docblock item-decl']//a[text()='Alias']", {"font-weight": "400"}) +assert-css: ( + "//*[@class='structfield small-section-header']//a[text()='Alias']", + {"font-weight": "400"}, +) +assert-css: ("#method\.a_method > .code-header", {"font-weight": "600"}) +assert-css: ("#associatedtype\.X > .code-header", {"font-weight": "600"}) +assert-css: ("#associatedconstant\.Y > .code-header", {"font-weight": "600"}) + +goto: file://|DOC_PATH|/test_docs/type.SomeType.html +assert-css: (".top-doc .docblock p", {"font-weight": "400"}, ALL) + +goto: file://|DOC_PATH|/test_docs/struct.Foo.html +assert-css: (".impl-items .method", {"font-weight": "600"}, ALL) + +goto: file://|DOC_PATH|/lib2/trait.Trait.html + +// This is a complex selector, so here's how it works: +// +// * //*[@class='docblock item-decl'] — selects element of any tag with classes docblock and item-decl +// * /pre[@class='rust trait'] — selects immediate child with tag pre and classes rust and trait +// * /code — selects immediate child with tag code +// * /a[@class='constant'] — selects immediate child with tag a and class constant +// * //text() — selects child that is text node +// * /parent::* — selects immediate parent of the text node (the * means it can be any tag) +// +// This uses '/parent::*' as a proxy for the style of the text node. +// We can't just select the '' because intermediate tags could be added. +assert-count: ( + "//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", + 1, +) +assert-css: ( + "//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", + {"font-weight": "400"}, +) + +assert-count: (".methods .associatedtype", 1) +assert-css: (".methods .associatedtype", {"font-weight": "600"}) +assert-count: (".methods .constant", 1) +assert-css: (".methods .constant", {"font-weight": "600"}) +assert-css: (".methods .method", {"font-weight": "600"}) diff --git a/src/test/rustdoc-gui/hash-item-expansion.goml b/src/test/rustdoc-gui/hash-item-expansion.goml new file mode 100644 index 000000000..861f69283 --- /dev/null +++ b/src/test/rustdoc-gui/hash-item-expansion.goml @@ -0,0 +1,11 @@ +// This test ensures that the element corresponding to the hash is displayed. +goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.borrow +// In the blanket implementations list, "Borrow" is the second one, hence the ":nth(2)". +assert-attribute: ("#blanket-implementations-list > details:nth-child(2)", {"open": ""}) +// We first check that the impl block is open by default. +assert-attribute: ("#implementations-list details", {"open": ""}) +// To ensure that we will click on the currently hidden method. +assert-text: (".sidebar-elems section .block li > a", "must_use") +click: ".sidebar-elems section .block li > a" +// We check that the impl block was opened as expected so that we can see the method. +assert-attribute: ("#implementations-list > details", {"open": ""}) diff --git a/src/test/rustdoc-gui/headers-color.goml b/src/test/rustdoc-gui/headers-color.goml new file mode 100644 index 000000000..a47a9c8a1 --- /dev/null +++ b/src/test/rustdoc-gui/headers-color.goml @@ -0,0 +1,117 @@ +// This test check for headers text and background colors for the different themes. +goto: file://|DOC_PATH|/test_docs/struct.Foo.html + +// This is needed so that the text color is computed. +show-text: true + +// Ayu theme +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-preferred-dark-theme": "ayu", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: ( + ".impl", + {"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"}, + ALL, +) +assert-css: ( + ".impl .code-header", + {"color": "rgb(230, 225, 207)", "background-color": "rgb(15, 20, 25)"}, + ALL, +) + +goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl-Foo +assert-css: ( + "#impl-Foo", + {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, +) + +goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use +assert-css: ( + "#method\.must_use", + {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, + ALL, +) + +goto: file://|DOC_PATH|/test_docs/index.html +assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL) + +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html +// We select headings (h2, h3, h...). +assert-css: (".docblock > :not(p) > a", {"color": "rgb(57, 175, 215)"}, ALL) + +// Dark theme +local-storage: { + "rustdoc-theme": "dark", + "rustdoc-preferred-dark-theme": "dark", + "rustdoc-use-system-theme": "false", +} +goto: file://|DOC_PATH|/test_docs/struct.Foo.html + +assert-css: ( + ".impl", + {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"}, + ALL, +) +assert-css: ( + ".impl .code-header", + {"color": "rgb(221, 221, 221)", "background-color": "rgb(53, 53, 53)"}, + ALL, +) + +goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl-Foo +assert-css: ( + "#impl-Foo", + {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, +) + +goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use +assert-css: ( + "#method\.must_use", + {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, + ALL, +) + +goto: file://|DOC_PATH|/test_docs/index.html +assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL) + +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html +// We select headings (h2, h3, h...). +assert-css: (".docblock > :not(p) > a", {"color": "rgb(210, 153, 29)"}, ALL) + +// Light theme +local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} +reload: + +goto: file://|DOC_PATH|/test_docs/struct.Foo.html + +assert-css: ( + ".impl", + {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, + ALL, +) +assert-css: ( + ".impl .code-header", + {"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"}, + ALL, +) + +goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl-Foo +assert-css: ("#impl-Foo", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}) + +goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use +assert-css: ( + "#method\.must_use", + {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}, + ALL, +) + +goto: file://|DOC_PATH|/test_docs/index.html +assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL) + +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html +// We select headings (h2, h3, h...). +assert-css: (".docblock > :not(p) > a", {"color": "rgb(56, 115, 173)"}, ALL) diff --git a/src/test/rustdoc-gui/headings.goml b/src/test/rustdoc-gui/headings.goml new file mode 100644 index 000000000..8c2c3df15 --- /dev/null +++ b/src/test/rustdoc-gui/headings.goml @@ -0,0 +1,258 @@ +// This test checks that headers (a) have the correct heading level, (b) are the right size, +// and (c) have the correct underlining (or absence of underlining). +// The sizes may change as design changes, but try to make sure a lower header is never bigger than +// its parent headers. Also make sure lower headers don't have underlines when their parents lack +// an underline. +// Most of these sizes are set in CSS in `em` units, so here's a conversion chart based on our +// default 16px font size: +// 24px 1.5em +// 22px 1.375rem +// 20px 1.25rem +// 18px 1.125em +// 16px 1rem +// 14px 0.875rem +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html + +assert-css: ("h1.fqn", {"font-size": "24px"}) + +assert-css: ("h2#top-doc-prose-title", {"font-size": "22px"}) +assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"}) +assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "20px"}) +assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"}) +assert-css: ("h4#top-doc-prose-sub-sub-heading", {"font-size": "18px"}) +assert-css: ("h4#top-doc-prose-sub-sub-heading", {"border-bottom-width": "1px"}) + +assert-css: ("h2#fields", {"font-size": "22px"}) +assert-css: ("h2#fields", {"border-bottom-width": "1px"}) +assert-css: ("h3#title-for-field", {"font-size": "20px"}) +assert-css: ("h3#title-for-field", {"border-bottom-width": "0px"}) +assert-css: ("h4#sub-heading-for-field", {"font-size": "16px"}) +assert-css: ("h4#sub-heading-for-field", {"border-bottom-width": "0px"}) + +assert-css: ("h2#implementations", {"font-size": "22px"}) +assert-css: ("h2#implementations", {"border-bottom-width": "1px"}) + +assert-css: ("#impl-HeavilyDocumentedStruct > h3.code-header", {"font-size": "18px"}) +assert-css: ("#impl-HeavilyDocumentedStruct > h3.code-header", {"border-bottom-width": "0px"}) +assert-css: ("#method\.do_nothing > h4.code-header", {"font-size": "16px"}) +assert-css: ("#method\.do_nothing > h4.code-header", {"border-bottom-width": "0px"}) + +assert-css: ("h4#title-for-struct-impl-doc", {"font-size": "16px"}) +assert-css: ("h4#title-for-struct-impl-doc", {"border-bottom-width": "0px"}) +assert-css: ("h5#sub-heading-for-struct-impl-doc", {"font-size": "16px"}) +assert-css: ("h5#sub-heading-for-struct-impl-doc", {"border-bottom-width": "0px"}) +assert-css: ("h6#sub-sub-heading-for-struct-impl-doc", {"font-size": "14px"}) +assert-css: ("h6#sub-sub-heading-for-struct-impl-doc", {"border-bottom-width": "0px"}) + +assert-css: ("h5#title-for-struct-impl-item-doc", {"font-size": "16px"}) +assert-css: ("h5#title-for-struct-impl-item-doc", {"border-bottom-width": "0px"}) +assert-css: ("h6#sub-heading-for-struct-impl-item-doc", {"font-size": "14px"}) +assert-css: ("h6#sub-heading-for-struct-impl-item-doc", {"border-bottom-width": "0px"}) +assert-css: ("h6#sub-sub-heading-for-struct-impl-item-doc", {"font-size": "14px"}) + +goto: file://|DOC_PATH|/test_docs/enum.HeavilyDocumentedEnum.html + +assert-css: ("h1.fqn", {"font-size": "24px"}) + +assert-css: ("h2#top-doc-prose-title", {"font-size": "22px"}) +assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"}) +assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "20px"}) +assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"}) +assert-css: ("h4#top-doc-prose-sub-sub-heading", {"font-size": "18px"}) +assert-css: ("h4#top-doc-prose-sub-sub-heading", {"border-bottom-width": "1px"}) + +assert-css: ("h2#variants", {"font-size": "22px"}) +assert-css: ("h2#variants", {"border-bottom-width": "1px"}) + +assert-css: ("h4#none-prose-title", {"font-size": "16px"}) +assert-css: ("h4#none-prose-title", {"border-bottom-width": "0px"}) +assert-css: ("h5#none-prose-sub-heading", {"font-size": "16px"}) +assert-css: ("h5#none-prose-sub-heading", {"border-bottom-width": "0px"}) + +assert-css: ("h4#wrapped-prose-title", {"font-size": "16px"}) +assert-css: ("h4#wrapped-prose-title", {"border-bottom-width": "0px"}) +assert-css: ("h5#wrapped-prose-sub-heading", {"font-size": "16px"}) +assert-css: ("h5#wrapped-prose-sub-heading", {"border-bottom-width": "0px"}) + +assert-css: ("h5#wrapped0-prose-title", {"font-size": "16px"}) +assert-css: ("h5#wrapped0-prose-title", {"border-bottom-width": "0px"}) +assert-css: ("h6#wrapped0-prose-sub-heading", {"font-size": "14px"}) +assert-css: ("h6#wrapped0-prose-sub-heading", {"border-bottom-width": "0px"}) + +assert-css: ("h5#structy-prose-title", {"font-size": "16px"}) +assert-css: ("h5#structy-prose-title", {"border-bottom-width": "0px"}) +assert-css: ("h6#structy-prose-sub-heading", {"font-size": "14px"}) +assert-css: ("h6#structy-prose-sub-heading", {"border-bottom-width": "0px"}) + +assert-css: ("h2#implementations", {"font-size": "22px"}) +assert-css: ("h2#implementations", {"border-bottom-width": "1px"}) + +assert-css: ("#impl-HeavilyDocumentedEnum > h3.code-header", {"font-size": "18px"}) +assert-css: ("#impl-HeavilyDocumentedEnum > h3.code-header", {"border-bottom-width": "0px"}) +assert-css: ("#method\.do_nothing > h4.code-header", {"font-size": "16px"}) +assert-css: ("#method\.do_nothing > h4.code-header", {"border-bottom-width": "0px"}) + +assert-css: ("h4#title-for-enum-impl-doc", {"font-size": "16px"}) +assert-css: ("h4#title-for-enum-impl-doc", {"border-bottom-width": "0px"}) +assert-css: ("h5#sub-heading-for-enum-impl-doc", {"font-size": "16px"}) +assert-css: ("h5#sub-heading-for-enum-impl-doc", {"border-bottom-width": "0px"}) +assert-css: ("h6#sub-sub-heading-for-enum-impl-doc", {"font-size": "14px"}) +assert-css: ("h6#sub-sub-heading-for-enum-impl-doc", {"border-bottom-width": "0px"}) + +assert-css: ("h5#title-for-enum-impl-item-doc", {"font-size": "16px"}) +assert-css: ("h5#title-for-enum-impl-item-doc", {"border-bottom-width": "0px"}) +assert-css: ("h6#sub-heading-for-enum-impl-item-doc", {"font-size": "14px"}) +assert-css: ("h6#sub-heading-for-enum-impl-item-doc", {"border-bottom-width": "0px"}) +assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"font-size": "14px"}) +assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"border-bottom-width": "0px"}) + +assert-text: (".sidebar .mod h3", "Modules") +assert-css: (".sidebar .mod h3", {"border-bottom-width": "0px"}, ALL) + +goto: file://|DOC_PATH|/test_docs/union.HeavilyDocumentedUnion.html + +assert-css: ("h1.fqn", {"font-size": "24px"}) + +assert-css: ("h2#top-doc-prose-title", {"font-size": "22px"}) +assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"}) +assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "20px"}) +assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"}) + +assert-css: ("h2#fields", {"font-size": "22px"}) +assert-css: ("h2#fields", {"border-bottom-width": "1px"}) + +assert-css: ("h3#title-for-union-variant", {"font-size": "20px"}) +assert-css: ("h3#title-for-union-variant", {"border-bottom-width": "0px"}) +assert-css: ("h4#sub-heading-for-union-variant", {"font-size": "16px"}) +assert-css: ("h4#sub-heading-for-union-variant", {"border-bottom-width": "0px"}) + +assert-css: ("h2#implementations", {"font-size": "22px"}) +assert-css: ("h2#implementations", {"border-bottom-width": "1px"}) + +assert-css: ("#impl-HeavilyDocumentedUnion > h3.code-header", {"font-size": "18px"}) +assert-css: ("#impl-HeavilyDocumentedUnion > h3.code-header", {"border-bottom-width": "0px"}) +assert-css: ("h4#title-for-union-impl-doc", {"font-size": "16px"}) +assert-css: ("h4#title-for-union-impl-doc", {"border-bottom-width": "0px"}) +assert-css: ("h5#sub-heading-for-union-impl-doc", {"font-size": "16px"}) +assert-css: ("h5#sub-heading-for-union-impl-doc", {"border-bottom-width": "0px"}) + +assert-css: ("h5#title-for-union-impl-item-doc", {"font-size": "16px"}) +assert-css: ("h5#title-for-union-impl-item-doc", {"border-bottom-width": "0px"}) +assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"font-size": "14px"}) +assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"border-bottom-width": "0px"}) + +goto: file://|DOC_PATH|/test_docs/macro.heavily_documented_macro.html + +assert-css: ("h1.fqn", {"font-size": "24px"}) + +assert-css: ("h2#top-doc-prose-title", {"font-size": "22px"}) +assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"}) +assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "20px"}) +assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"}) + +// Checking colors now. +show-text: true +local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html +assert-css: ( + ".top-doc .docblock h2", + {"color": "rgb(0, 0, 0)", "border-bottom": "1px solid rgb(221, 221, 221)"}, +) +assert-css: ( + ".top-doc .docblock h3", + {"color": "rgb(0, 0, 0)", "border-bottom": "1px solid rgb(221, 221, 221)"}, +) +assert-css: ( + ".top-doc .docblock h4", + {"color": "rgb(0, 0, 0)", "border-bottom": "1px solid rgb(221, 221, 221)"}, +) +assert-css: ( + ".top-doc .docblock h5", + {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, +) +assert-css: ( + "#implementations-list .docblock h4", + {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, +) +assert-css: ( + "#implementations-list .docblock h5", + {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, +) +assert-css: ( + "#implementations-list .docblock h6", + {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, +) + +local-storage: {"rustdoc-theme": "dark"} +reload: +assert-css: ( + ".top-doc .docblock h2", + {"color": "rgb(221, 221, 221)", "border-bottom": "1px solid rgb(210, 210, 210)"}, +) +assert-css: ( + ".top-doc .docblock h3", + {"color": "rgb(221, 221, 221)", "border-bottom": "1px solid rgb(210, 210, 210)"}, +) +assert-css: ( + ".top-doc .docblock h4", + {"color": "rgb(221, 221, 221)", "border-bottom": "1px solid rgb(210, 210, 210)"}, +) +assert-css: ( + ".top-doc .docblock h5", + {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, +) +assert-css: ( + "#implementations-list .docblock h4", + {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, +) +assert-css: ( + "#implementations-list .docblock h5", + {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, +) +assert-css: ( + "#implementations-list .docblock h6", + {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, +) + +local-storage: {"rustdoc-theme": "ayu"} +reload: +assert-css: ( + ".top-doc .docblock h2", + {"color": "rgb(255, 255, 255)", "border-bottom": "1px solid rgb(92, 103, 115)"}, +) +assert-css: ( + ".top-doc .docblock h2", + {"color": "rgb(255, 255, 255)", "border-bottom": "1px solid rgb(92, 103, 115)"}, +) +assert-css: ( + ".top-doc .docblock h4", + {"color": "rgb(255, 255, 255)", "border-bottom": "1px solid rgb(92, 103, 115)"}, +) +assert-css: ( + ".top-doc .docblock h5", + {"color": "rgb(197, 197, 197)", "border-bottom": "0px none rgb(92, 103, 115)"}, +) +assert-css: ( + "#implementations-list .docblock h4", + {"color": "rgb(255, 255, 255)", "border-bottom": "0px none rgb(92, 103, 115)"}, +) +assert-css: ( + "#implementations-list .docblock h5", + {"color": "rgb(197, 197, 197)", "border-bottom": "0px none rgb(92, 103, 115)"}, +) +assert-css: ( + "#implementations-list .docblock h6", + {"color": "rgb(197, 197, 197)", "border-bottom": "0px none rgb(92, 103, 115)"}, +) + +local-storage: {"rustdoc-theme": "light"} +goto: file://|DOC_PATH|/staged_api/struct.Foo.html +assert-css: (".since", {"color": "rgb(128, 128, 128)"}) + +local-storage: {"rustdoc-theme": "dark"} +reload: +assert-css: (".since", {"color": "rgb(128, 128, 128)"}) + +local-storage: {"rustdoc-theme": "ayu"} +reload: +assert-css: (".since", {"color": "rgb(128, 128, 128)"}) diff --git a/src/test/rustdoc-gui/huge-collection-of-constants.goml b/src/test/rustdoc-gui/huge-collection-of-constants.goml new file mode 100644 index 000000000..4f75b5841 --- /dev/null +++ b/src/test/rustdoc-gui/huge-collection-of-constants.goml @@ -0,0 +1,9 @@ +// Make sure that the last two entries are more than 12 pixels apart and not stacked on each other. + +goto: file://|DOC_PATH|/test_docs/huge_amount_of_consts/index.html + +compare-elements-position-near-false: ( + "//*[@class='item-table']//div[last()-1]", + "//*[@class='item-table']//div[last()-3]", + {"y": 12}, +) diff --git a/src/test/rustdoc-gui/impl-default-expansion.goml b/src/test/rustdoc-gui/impl-default-expansion.goml new file mode 100644 index 000000000..6df2661e6 --- /dev/null +++ b/src/test/rustdoc-gui/impl-default-expansion.goml @@ -0,0 +1,3 @@ +// This test ensures that the impl blocks are open by default. +goto: file://|DOC_PATH|/test_docs/struct.Foo.html +assert-attribute: ("#implementations-list details.implementors-toggle", {"open": ""}) diff --git a/src/test/rustdoc-gui/implementors.goml b/src/test/rustdoc-gui/implementors.goml new file mode 100644 index 000000000..666a6e125 --- /dev/null +++ b/src/test/rustdoc-gui/implementors.goml @@ -0,0 +1,35 @@ +// The goal of this test is to check that the external trait implementors, generated with JS, +// have the same display than the "local" ones. +goto: file://|DOC_PATH|/implementors/trait.Whatever.html +assert: "#implementors-list" +// There are supposed to be two implementors listed. +assert-count: ("#implementors-list .impl", 2) +// Now we check that both implementors have an anchor, an ID and a similar DOM. +assert: ("#implementors-list .impl:nth-child(1) > a.anchor") +assert-attribute: ("#implementors-list .impl:nth-child(1)", {"id": "impl-Whatever-for-Struct"}) +assert-attribute: ("#implementors-list .impl:nth-child(1) > a.anchor", {"href": "#impl-Whatever-for-Struct"}) +assert: "#implementors-list .impl:nth-child(1) > .code-header.in-band" + +assert: ("#implementors-list .impl:nth-child(2) > a.anchor") +assert-attribute: ("#implementors-list .impl:nth-child(2)", {"id": "impl-Whatever-1"}) +assert-attribute: ("#implementors-list .impl:nth-child(2) > a.anchor", {"href": "#impl-Whatever-1"}) +assert: "#implementors-list .impl:nth-child(2) > .code-header.in-band" + +goto: file://|DOC_PATH|/test_docs/struct.HasEmptyTraits.html +compare-elements-position-near-false: ( + "#impl-EmptyTrait1-for-HasEmptyTraits", + "#impl-EmptyTrait2-for-HasEmptyTraits", + {"y": 30}, +) +compare-elements-position-near: ( + "#impl-EmptyTrait3-for-HasEmptyTraits h3", + "#impl-EmptyTrait3-for-HasEmptyTraits .item-info", + {"y": 30}, +) + +// Now check that re-exports work correctly. +// There should be exactly one impl shown on both of these pages. +goto: file://|DOC_PATH|/lib2/trait.TraitToReexport.html +assert-count: ("#implementors-list .impl", 1) +goto: file://|DOC_PATH|/implementors/trait.TraitToReexport.html +assert-count: ("#implementors-list .impl", 1) diff --git a/src/test/rustdoc-gui/item-info-overflow.goml b/src/test/rustdoc-gui/item-info-overflow.goml new file mode 100644 index 000000000..b7095a3c5 --- /dev/null +++ b/src/test/rustdoc-gui/item-info-overflow.goml @@ -0,0 +1,31 @@ +// This test ensures that the "item-info" elements don't overflow. +goto: file://|DOC_PATH|/lib2/struct.LongItemInfo.html +// We set a fixed size so there is no chance of "random" resize. +size: (1200, 870) +// Logically, the "item-decl" and the "item-info" should have the same scroll width. +compare-elements-property: (".docblock.item-decl", ".item-info", ["scrollWidth"]) +assert-property: (".item-info", {"scrollWidth": "890"}) +// Just to be sure we're comparing the correct "item-info": +assert-text: ( + ".item-info", + "Available on Android or Linux or Emscripten or DragonFly BSD", + STARTS_WITH, +) + +// Checking the "item-info" on an impl block as well: +goto: file://|DOC_PATH|/lib2/struct.LongItemInfo2.html +compare-elements-property: ( + "#impl-SimpleTrait-for-LongItemInfo2 .item-info", + "#impl-SimpleTrait-for-LongItemInfo2 + .docblock", + ["scrollWidth"], +) +assert-property: ( + "#impl-SimpleTrait-for-LongItemInfo2 .item-info", + {"scrollWidth": "866"}, +) +// Just to be sure we're comparing the correct "item-info": +assert-text: ( + "#impl-SimpleTrait-for-LongItemInfo2 .item-info", + "Available on Android or Linux or Emscripten or DragonFly BSD", + STARTS_WITH, +) diff --git a/src/test/rustdoc-gui/item-info.goml b/src/test/rustdoc-gui/item-info.goml new file mode 100644 index 000000000..50c45b76b --- /dev/null +++ b/src/test/rustdoc-gui/item-info.goml @@ -0,0 +1,32 @@ +// This test ensures a few things for item info elements. +goto: file://|DOC_PATH|/lib2/struct.Foo.html +// Ensuring that the item information don't take 100% of the width if unnecessary. +// We set a fixed size so there is no chance of "random" resize. +size: (1100, 800) +// We check that ".item-info" is bigger than its content. +assert-css: (".item-info", {"width": "790px"}) +assert-css: (".item-info .stab", {"width": "289px"}) +assert-position: (".item-info .stab", {"x": 295}) + +// Now we ensure that they're not rendered on the same line. +goto: file://|DOC_PATH|/lib2/trait.Trait.html +// We first ensure that there are two item info on the trait. +assert-count: ("#main-content > .item-info .stab", 2) +// They should not have the same `y` position! +compare-elements-position-false: ( + "#main-content > .item-info .stab:nth-of-type(1)", + "#main-content > .item-info .stab:nth-of-type(2)", + ("y"), +) +// But they should have the same `x` position. +compare-elements-position: ( + "#main-content > .item-info .stab:nth-of-type(1)", + "#main-content > .item-info .stab:nth-of-type(2)", + ("x"), +) +// They are supposed to have the same height too. +compare-elements-css: ( + "#main-content > .item-info .stab:nth-of-type(1)", + "#main-content > .item-info .stab:nth-of-type(2)", + ["height"], +) diff --git a/src/test/rustdoc-gui/item-summary-table.goml b/src/test/rustdoc-gui/item-summary-table.goml new file mode 100644 index 000000000..6bf4e288c --- /dev/null +++ b/src/test/rustdoc-gui/item-summary-table.goml @@ -0,0 +1,6 @@ +// This test ensures that
elements aren't display in items summary. +goto: file://|DOC_PATH|/lib2/summary_table/index.html +// We check that we picked the right item first. +assert-text: (".item-table .item-left", "Foo") +// Then we check that its summary is empty. +assert-text: (".item-table .item-right", "") diff --git a/src/test/rustdoc-gui/javascript-disabled.goml b/src/test/rustdoc-gui/javascript-disabled.goml new file mode 100644 index 000000000..1693f7b64 --- /dev/null +++ b/src/test/rustdoc-gui/javascript-disabled.goml @@ -0,0 +1,6 @@ +// When JavaScript is disabled, we hide the search bar, because it +// can't be used without JS. +javascript: false + +goto: file://|DOC_PATH|/test_docs/struct.Foo.html +assert-css: (".sub", {"display": "none"}) diff --git a/src/test/rustdoc-gui/jump-to-def-background.goml b/src/test/rustdoc-gui/jump-to-def-background.goml new file mode 100644 index 000000000..d17400f5b --- /dev/null +++ b/src/test/rustdoc-gui/jump-to-def-background.goml @@ -0,0 +1,43 @@ +// We check the background color on the jump to definition links in the source code page. +goto: file://|DOC_PATH|/src/link_to_definition/lib.rs.html + +// Set the theme to dark. +local-storage: { + "rustdoc-theme": "dark", + "rustdoc-preferred-dark-theme": "dark", + "rustdoc-use-system-theme": "false", +} +// We reload the page so the local storage settings are being used. +reload: + +assert-css: ( + "body.source .example-wrap pre.rust a", + {"background-color": "rgb(51, 51, 51)"}, + ALL, +) + +// Set the theme to ayu. +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-preferred-dark-theme": "ayu", + "rustdoc-use-system-theme": "false", +} +// We reload the page so the local storage settings are being used. +reload: + +assert-css: ( + "body.source .example-wrap pre.rust a", + {"background-color": "rgb(51, 51, 51)"}, + ALL, +) + +// Set the theme to light. +local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} +// We reload the page so the local storage settings are being used. +reload: + +assert-css: ( + "body.source .example-wrap pre.rust a", + {"background-color": "rgb(238, 238, 238)"}, + ALL, +) diff --git a/src/test/rustdoc-gui/label-next-to-symbol.goml b/src/test/rustdoc-gui/label-next-to-symbol.goml new file mode 100644 index 000000000..ca3994a08 --- /dev/null +++ b/src/test/rustdoc-gui/label-next-to-symbol.goml @@ -0,0 +1,78 @@ +// These tests verify that labels like "UNIX" and "Deprecated" stay on the same line as their symbol. +// It also verifies the staggered layout on mobile. +goto: file://|DOC_PATH|/test_docs/index.html + +// Desktop view +size: (1080, 600) +assert: (".stab.deprecated") +assert: (".stab.portability") + +// make sure that deprecated and portability are different colours +assert-css: ( + ".item-table .item-left .stab.deprecated", + { "background-color": "rgb(255, 196, 196)" }, +) +assert-css: ( + ".item-table .item-left .stab.portability", + { "background-color": "rgb(243, 223, 255)" }, +) + +// table like view +assert-css: (".item-right.docblock-short", { "padding-left": "0px" }) +compare-elements-position-near: ( + "//*[@class='item-left module-item']//a[text()='replaced_function']", + ".item-left .stab.deprecated", + {"y": 2}, +) +compare-elements-position: ( + ".item-left .stab.deprecated", + ".item-left .stab.portability", + ("y"), +) + +// Ensure no wrap +compare-elements-position-near: ( + "//*[@class='item-left module-item']//a[text()='replaced_function']", + "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", + {"y": 2}, +) +// compare parent elements +compare-elements-position: ( + "//*[@class='item-left module-item']//a[text()='replaced_function']/..", + "//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..", + ("y"), +) + + +// Mobile view +size: (600, 600) +// staggered layout with 2em spacing +assert-css: (".item-right.docblock-short", { "padding-left": "32px" }) +compare-elements-position-near: ( + "//*[@class='item-left module-item']//a[text()='replaced_function']", + ".item-left .stab.deprecated", + {"y": 1}, +) +compare-elements-position: ( + ".item-left .stab.deprecated", + ".item-left .stab.portability", + ("y"), +) + +// Ensure wrap +compare-elements-position-near-false: ( + "//*[@class='item-left module-item']//a[text()='replaced_function']", + "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", + {"y": 12}, +) +// compare parent elements +compare-elements-position-false: ( + "//*[@class='item-left module-item']//a[text()='replaced_function']/..", + "//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..", + ("y"), +) +compare-elements-position-false: ( + ".item-left .stab.deprecated", + "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", + ("y"), +) diff --git a/src/test/rustdoc-gui/list_code_block.goml b/src/test/rustdoc-gui/list_code_block.goml new file mode 100644 index 000000000..eba1a662b --- /dev/null +++ b/src/test/rustdoc-gui/list_code_block.goml @@ -0,0 +1,4 @@ +// This test checks that code blocks in list are supported. +goto: file://|DOC_PATH|/test_docs/index.html +goto: ./fn.check_list_code_block.html +assert: ("pre.rust.fn") diff --git a/src/test/rustdoc-gui/mobile.goml b/src/test/rustdoc-gui/mobile.goml new file mode 100644 index 000000000..13b9b563d --- /dev/null +++ b/src/test/rustdoc-gui/mobile.goml @@ -0,0 +1,30 @@ +// Test various properties of the mobile UI +goto: file://|DOC_PATH|/staged_api/struct.Foo.html +size: (400, 600) + +font-size: 18 +wait-for: 100 // wait a bit for the resize and the font-size change to be fully taken into account. + +// The out-of-band info (source, stable version, collapse) should be below the +// h1 when the screen gets narrow enough. +assert-css: (".main-heading", { + "display": "flex", + "flex-direction": "column" +}) + +assert-property: (".mobile-topbar h2.location", {"offsetHeight": 36}) + +// Note: We can't use assert-text here because the 'Since' is set by CSS and +// is therefore not part of the DOM. +assert-css: (".content .out-of-band .since::before", { "content": "\"Since \"" }) + +size: (1000, 1000) +wait-for: 100 // wait a bit for the resize to be fully taken into account. +assert-css-false: (".content .out-of-band .since::before", { "content": "\"Since \"" }) + +// On the settings page, the theme buttons should not line-wrap. Instead, they should +// all be placed as a group on a line below the setting name "Theme." +goto: file://|DOC_PATH|/settings.html +size: (400, 600) +// Ignored for now https://github.com/rust-lang/rust/issues/93784. +// compare-elements-position-near-false: ("#preferred-light-theme .setting-name", "#preferred-light-theme .choice", {"y": 16}) diff --git a/src/test/rustdoc-gui/module-items-font.goml b/src/test/rustdoc-gui/module-items-font.goml new file mode 100644 index 000000000..758ee391a --- /dev/null +++ b/src/test/rustdoc-gui/module-items-font.goml @@ -0,0 +1,67 @@ +// This test checks that the correct font is used on module items (in index.html pages). +goto: file://|DOC_PATH|/test_docs/index.html +assert-css: ( + ".item-table .module-item a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, + ALL, +) +assert-css: ( + ".item-table .docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, + ALL, +) + +// modules +assert-css: ( + "#modules + .item-table .item-left a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#modules + .item-table .item-right.docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) +// structs +assert-css: ( + "#structs + .item-table .item-left a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#structs + .item-table .item-right.docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) +// enums +assert-css: ( + "#enums + .item-table .item-left a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#enums + .item-table .item-right.docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) +// traits +assert-css: ( + "#traits + .item-table .item-left a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#traits + .item-table .item-right.docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) +// functions +assert-css: ( + "#functions + .item-table .item-left a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#functions + .item-table .item-right.docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) +// keywords +assert-css: ( + "#keywords + .item-table .item-left a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#keywords + .item-table .item-right.docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) diff --git a/src/test/rustdoc-gui/overflow-tooltip-information.goml b/src/test/rustdoc-gui/overflow-tooltip-information.goml new file mode 100644 index 000000000..7ef85a4c4 --- /dev/null +++ b/src/test/rustdoc-gui/overflow-tooltip-information.goml @@ -0,0 +1,8 @@ +// The goal of this test is to ensure that the tooltip `.information` class doesn't +// have overflow and max-width CSS rules set because they create a bug in firefox on +// mac. For more information: https://github.com/rust-lang/rust/issues/89185 +goto: file://|DOC_PATH|/test_docs/fn.foo.html +assert-css: (".docblock > .information", { + "overflow-x": "visible", + "max-width": "none" +}, ALL) diff --git a/src/test/rustdoc-gui/pocket-menu.goml b/src/test/rustdoc-gui/pocket-menu.goml new file mode 100644 index 000000000..54f3790a7 --- /dev/null +++ b/src/test/rustdoc-gui/pocket-menu.goml @@ -0,0 +1,77 @@ +// This test ensures that the "pocket menus" are working as expected. +goto: file://|DOC_PATH|/test_docs/index.html +// First we check that the help menu doesn't exist yet. +assert-false: "#help-button .popover" +// Then we display the help menu. +click: "#help-button" +assert: "#help-button .popover" +assert-css: ("#help-button .popover", {"display": "block"}) + +// Now we click somewhere else on the page to ensure it is handling the blur event +// correctly. +click: ".sidebar" +assert-css: ("#help-button .popover", {"display": "none"}) + +// Now we will check that we cannot have two "pocket menus" displayed at the same time. +click: "#help-button" +assert-css: ("#help-button .popover", {"display": "block"}) +click: "#settings-menu" +assert-css: ("#help-button .popover", {"display": "none"}) +assert-css: ("#settings-menu .popover", {"display": "block"}) + +// Now the other way. +click: "#help-button" +assert-css: ("#help-button .popover", {"display": "block"}) +assert-css: ("#settings-menu .popover", {"display": "none"}) + +// Now verify that clicking the help menu again closes it. +click: "#help-button" +assert-css: ("#help-button .popover", {"display": "none"}) +assert-css: ("#settings-menu .popover", {"display": "none"}) + +// We check the borders color now: + +// Ayu theme +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-use-system-theme": "false", +} +reload: + +click: "#help-button" +assert-css: ( + "#help-button .popover", + {"display": "block", "border-color": "rgb(92, 103, 115)"}, +) +compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"]) +compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) + +// Dark theme +local-storage: { + "rustdoc-theme": "dark", + "rustdoc-use-system-theme": "false", +} +reload: + +click: "#help-button" +assert-css: ( + "#help-button .popover", + {"display": "block", "border-color": "rgb(210, 210, 210)"}, +) +compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"]) +compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) + +// Light theme +local-storage: { + "rustdoc-theme": "light", + "rustdoc-use-system-theme": "false", +} +reload: + +click: "#help-button" +assert-css: ( + "#help-button .popover", + {"display": "block", "border-color": "rgb(221, 221, 221)"}, +) +compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"]) +compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) diff --git a/src/test/rustdoc-gui/run-on-hover.goml b/src/test/rustdoc-gui/run-on-hover.goml new file mode 100644 index 000000000..b8efa8e30 --- /dev/null +++ b/src/test/rustdoc-gui/run-on-hover.goml @@ -0,0 +1,7 @@ +// Example code blocks sometimes have a "Run" button to run them on the +// Playground. That button is hidden until the user hovers over the code block. +// This test checks that it is hidden, and that it shows on hover. +goto: file://|DOC_PATH|/test_docs/fn.foo.html +assert-css: (".test-arrow", {"visibility": "hidden"}) +move-cursor-to: ".example-wrap" +assert-css: (".test-arrow", {"visibility": "visible"}) diff --git a/src/test/rustdoc-gui/rust-logo.goml b/src/test/rustdoc-gui/rust-logo.goml new file mode 100644 index 000000000..4a9dcf735 --- /dev/null +++ b/src/test/rustdoc-gui/rust-logo.goml @@ -0,0 +1,78 @@ +// This test ensures that the correct style is applied to the rust logo in the sidebar. +goto: file://|DOC_PATH|/test_docs/index.html + +// First we start with the dark theme. +local-storage: { + "rustdoc-theme": "dark", + "rustdoc-preferred-dark-theme": "dark", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: ( + ".rust-logo", + {"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"}, +) + +// In the source view page now. +goto: file://|DOC_PATH|/src/test_docs/lib.rs.html + +local-storage: { + "rustdoc-theme": "dark", + "rustdoc-preferred-dark-theme": "dark", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: ( + ".rust-logo", + {"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"}, +) + +// Then with the ayu theme. +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-preferred-dark-theme": "ayu", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: ( + ".rust-logo", + {"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"}, +) + +// In the source view page now. +goto: file://|DOC_PATH|/src/test_docs/lib.rs.html + +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-preferred-dark-theme": "ayu", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: ( + ".rust-logo", + {"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"}, +) + +// And finally with the light theme. +local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} +reload: + +assert-css: ( + ".rust-logo", + {"filter": "none"}, +) + +// In the source view page now. +goto: file://|DOC_PATH|/src/test_docs/lib.rs.html + +local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} +reload: + +assert-css: ( + ".rust-logo", + {"filter": "none"}, +) diff --git a/src/test/rustdoc-gui/search-filter.goml b/src/test/rustdoc-gui/search-filter.goml new file mode 100644 index 000000000..d645e2370 --- /dev/null +++ b/src/test/rustdoc-gui/search-filter.goml @@ -0,0 +1,83 @@ +// Checks that the crate search filtering is handled correctly and changes the results. +goto: file://|DOC_PATH|/test_docs/index.html +show-text: true +write: (".search-input", "test") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#titles" +assert-text: ("#results .externcrate", "test_docs") + +wait-for: "#crate-search" +// We now want to change the crate filter. +click: "#crate-search" +// We select "lib2" option then press enter to change the filter. +press-key: "ArrowDown" +press-key: "ArrowDown" +press-key: "Enter" +// Waiting for the search results to appear... +wait-for: "#titles" +assert-document-property: ({"URL": "&filter-crate="}, CONTAINS) +// We check that there is no more "test_docs" appearing. +assert-false: "#results .externcrate" +// We also check that "lib2" is the filter crate. +assert-property: ("#crate-search", {"value": "lib2"}) + +// Now we check that leaving the search results and putting them back keeps the +// crate filtering. +press-key: "Escape" +wait-for-css: ("#main-content", {"display": "block"}) +focus: ".search-input" +wait-for-css: ("#main-content", {"display": "none"}) +// We check that there is no more "test_docs" appearing. +assert-false: "#results .externcrate" +assert-property: ("#crate-search", {"value": "lib2"}) + +// Selecting back "All crates" +click: "#crate-search" +press-key: "ArrowUp" +press-key: "ArrowUp" +press-key: "Enter" +// Waiting for the search results to appear... +wait-for: "#titles" +assert-property: ("#crate-search", {"value": "All crates"}) + +// Checking that the URL parameter is taken into account for crate filtering. +goto: file://|DOC_PATH|/test_docs/index.html?search=test&filter-crate=lib2 +wait-for: "#crate-search" +assert-property: ("#crate-search", {"value": "lib2"}) +assert-false: "#results .externcrate" + +// Checking that the text for the "title" is correct (the "All" comes from the "` is correctly handled when it goes to next line. +// To do so we need to update the length of one of its `