2022-09-19 10:32:30 +00:00
|
|
|
// This test checks the position of the `i` for the notable traits.
|
2024-04-05 19:38:55 +00:00
|
|
|
include: "utils.goml"
|
2023-04-11 17:11:34 +00:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
|
2022-09-19 10:32:30 +00:00
|
|
|
show-text: true
|
2024-04-20 12:53:14 +00:00
|
|
|
|
|
|
|
define-function: (
|
|
|
|
"check-notable-tooltip-position",
|
|
|
|
[x, i_x],
|
|
|
|
block {
|
|
|
|
// Checking they have the same y position.
|
|
|
|
compare-elements-position: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
|
|
|
["y"],
|
|
|
|
)
|
|
|
|
// Checking they don't have the same x position.
|
|
|
|
compare-elements-position-false: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
|
|
|
["x"],
|
|
|
|
)
|
|
|
|
// The `i` should be *after* the type.
|
|
|
|
assert-position: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
|
|
|
{"x": |x|},
|
|
|
|
)
|
|
|
|
assert-position: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
|
|
|
{"x": |i_x|},
|
|
|
|
)
|
|
|
|
},
|
2022-10-26 21:42:53 +00:00
|
|
|
)
|
2024-04-20 12:53:14 +00:00
|
|
|
|
|
|
|
define-function: (
|
|
|
|
"check-notable-tooltip-position-complete",
|
|
|
|
[x, i_x, popover_x],
|
|
|
|
block {
|
|
|
|
call-function: ("check-notable-tooltip-position", {"x": |x|, "i_x": |i_x|})
|
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
assert-count: ("//*[@class='tooltip popover']", 1)
|
|
|
|
compare-elements-position-near: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
|
|
|
"//*[@class='tooltip popover']",
|
|
|
|
{"y": 30}
|
|
|
|
)
|
|
|
|
compare-elements-position-false: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
|
|
|
"//*[@class='tooltip popover']",
|
|
|
|
["x"]
|
|
|
|
)
|
|
|
|
assert-position: (
|
|
|
|
"//*[@class='tooltip popover']",
|
|
|
|
{"x": |popover_x|}
|
|
|
|
)
|
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
move-cursor-to: "//h1"
|
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
},
|
2022-10-26 21:42:53 +00:00
|
|
|
)
|
2024-04-20 12:53:14 +00:00
|
|
|
|
|
|
|
// We start with a wide screen.
|
|
|
|
set-window-size: (1100, 600)
|
|
|
|
call-function: ("check-notable-tooltip-position-complete", {
|
|
|
|
"x": 677,
|
|
|
|
"i_x": 955,
|
|
|
|
"popover_x": 463,
|
|
|
|
})
|
2022-09-19 10:32:30 +00:00
|
|
|
|
|
|
|
// Now only the `i` should be on the next line.
|
2023-04-11 17:11:34 +00:00
|
|
|
set-window-size: (1055, 600)
|
2022-09-19 10:32:30 +00:00
|
|
|
compare-elements-position-false: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
2023-01-26 20:32:33 +00:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
2024-04-01 19:11:22 +00:00
|
|
|
["y", "x"],
|
2022-09-19 10:32:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Now both the `i` and the struct name should be on the next line.
|
2023-04-11 17:11:34 +00:00
|
|
|
set-window-size: (980, 600)
|
2024-04-20 12:53:14 +00:00
|
|
|
call-function: ("check-notable-tooltip-position", {
|
|
|
|
"x": 245,
|
|
|
|
"i_x": 523,
|
|
|
|
})
|
2022-09-19 10:32:30 +00:00
|
|
|
|
|
|
|
// Checking on mobile now.
|
2023-04-11 17:11:34 +00:00
|
|
|
set-window-size: (650, 600)
|
2024-04-20 12:53:14 +00:00
|
|
|
call-function: ("check-notable-tooltip-position-complete", {
|
|
|
|
"x": 15,
|
|
|
|
"i_x": 293,
|
|
|
|
"popover_x": 0,
|
|
|
|
})
|
2022-09-19 10:32:30 +00:00
|
|
|
|
2022-11-08 04:18:01 +00:00
|
|
|
// Now check the colors.
|
|
|
|
define-function: (
|
|
|
|
"check-colors",
|
2024-04-01 19:11:22 +00:00
|
|
|
[theme, header_color, content_color, type_color, trait_color, link_color],
|
2023-01-06 14:18:51 +00:00
|
|
|
block {
|
2023-04-11 17:11:34 +00:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
|
2022-11-08 04:18:01 +00:00
|
|
|
// This is needed to ensure that the text color is computed.
|
2023-01-06 14:18:51 +00:00
|
|
|
show-text: true
|
2022-11-08 04:18:01 +00:00
|
|
|
|
2024-04-05 19:38:55 +00:00
|
|
|
call-function: ("switch-theme", {"theme": |theme|})
|
2022-11-08 04:18:01 +00:00
|
|
|
|
2023-05-24 00:19:35 +00:00
|
|
|
assert-css: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
|
|
|
{"color": |content_color|},
|
|
|
|
ALL,
|
|
|
|
)
|
|
|
|
|
2023-01-26 20:32:33 +00:00
|
|
|
move-cursor-to: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
rustdoc: add interaction delays for tooltip popovers
Designing a good hover microinteraction is a matter of guessing
user intent from what are, literally, vague gestures. In this case,
guessing if hovering in our out of the tooltip base is intentional
or not.
To figure this out, a few different techniques are used:
* When the mouse pointer enters a tooltip anchor point, its hitbox
is grown on the bottom, where the popover is/will appear. This was
already there before this commit: search "hover tunnel" in
rustdoc.css for the implementation.
* This commit adds a delay when the mouse pointer enters the base
anchor, in case the mouse pointer was just passing through and the
user didn't want to open it.
* This commit also adds a delay when the mouse pointer exits the
tooltip's base anchor or its popover, before hiding it.
* A fade-out animation is layered onto the pointer exit delay to
immediately inform the user that they successfully dismissed the
popover, while still providing a way for them to cancel it if
it was a mistake and they still wanted to interact with it.
* No animation is used for revealing it, because we don't want
people to try to interact with an element while it's in the
middle of fading in: either they're allowed to interact with
it while it's fading in, meaning it can't serve as mistake-
proofing for opening the popover, or they can't, but they
might try and be frustrated.
See also:
* https://www.nngroup.com/articles/timing-exposing-content/
* https://www.nngroup.com/articles/tooltip-guidelines/
* https://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown
2023-05-23 22:29:43 +00:00
|
|
|
wait-for-count: (".tooltip.popover", 1)
|
2022-11-08 04:18:01 +00:00
|
|
|
|
2023-05-24 00:19:35 +00:00
|
|
|
assert-css: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
|
|
|
{"color": |link_color|},
|
|
|
|
ALL,
|
|
|
|
)
|
|
|
|
|
2023-01-06 14:18:51 +00:00
|
|
|
assert-css: (
|
2023-01-26 20:32:33 +00:00
|
|
|
".tooltip.popover h3",
|
2022-11-08 04:18:01 +00:00
|
|
|
{"color": |header_color|},
|
|
|
|
ALL,
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
|
|
|
assert-css: (
|
2023-01-26 20:32:33 +00:00
|
|
|
".tooltip.popover pre",
|
2022-11-08 04:18:01 +00:00
|
|
|
{"color": |content_color|},
|
|
|
|
ALL,
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
|
|
|
assert-css: (
|
2023-01-26 20:32:33 +00:00
|
|
|
".tooltip.popover pre a.struct",
|
2022-11-08 04:18:01 +00:00
|
|
|
{"color": |type_color|},
|
|
|
|
ALL,
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
|
|
|
assert-css: (
|
2023-01-26 20:32:33 +00:00
|
|
|
".tooltip.popover pre a.trait",
|
2022-11-08 04:18:01 +00:00
|
|
|
{"color": |trait_color|},
|
|
|
|
ALL,
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
|
|
|
},
|
2022-11-08 04:18:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
call-function: (
|
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "ayu",
|
2023-07-02 09:14:31 +00:00
|
|
|
"link_color": "#39afd7",
|
|
|
|
"content_color": "#e6e1cf",
|
|
|
|
"header_color": "#fff",
|
|
|
|
"type_color": "#ffa0a5",
|
|
|
|
"trait_color": "#39afd7",
|
2022-11-08 04:18:01 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
call-function: (
|
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "dark",
|
2023-07-02 09:14:31 +00:00
|
|
|
"link_color": "#d2991d",
|
|
|
|
"content_color": "#ddd",
|
|
|
|
"header_color": "#ddd",
|
|
|
|
"type_color": "#2dbfb8",
|
|
|
|
"trait_color": "#b78cf2",
|
2022-11-08 04:18:01 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
call-function: (
|
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "light",
|
2023-07-02 09:14:31 +00:00
|
|
|
"link_color": "#3873ad",
|
|
|
|
"content_color": "black",
|
|
|
|
"header_color": "black",
|
|
|
|
"type_color": "#ad378a",
|
|
|
|
"trait_color": "#6e4fc9",
|
2022-11-08 04:18:01 +00:00
|
|
|
},
|
|
|
|
)
|
2022-11-09 00:59:03 +00:00
|
|
|
|
|
|
|
reload:
|
|
|
|
|
|
|
|
// Check that pressing escape works
|
2023-01-26 20:32:33 +00:00
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
move-cursor-to: "//*[@class='tooltip popover']"
|
|
|
|
assert-count: ("//*[@class='tooltip popover']", 1)
|
2022-11-09 00:59:03 +00:00
|
|
|
press-key: "Escape"
|
2023-01-26 20:32:33 +00:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
assert: "#method\.create_an_iterator_from_read .tooltip:focus"
|
2022-11-09 00:59:03 +00:00
|
|
|
|
|
|
|
// Check that clicking outside works.
|
2023-01-26 20:32:33 +00:00
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
assert-count: ("//*[@class='tooltip popover']", 1)
|
2022-11-09 00:59:03 +00:00
|
|
|
click: ".search-input"
|
2023-01-26 20:32:33 +00:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
assert-false: "#method\.create_an_iterator_from_read .tooltip:focus"
|
2022-11-09 00:59:03 +00:00
|
|
|
|
|
|
|
// Check that pressing tab over and over works.
|
2023-01-26 20:32:33 +00:00
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
move-cursor-to: "//*[@class='tooltip popover']"
|
|
|
|
assert-count: ("//*[@class='tooltip popover']", 1)
|
2022-11-09 00:59:03 +00:00
|
|
|
press-key: "Tab"
|
|
|
|
press-key: "Tab"
|
|
|
|
press-key: "Tab"
|
|
|
|
press-key: "Tab"
|
|
|
|
press-key: "Tab"
|
|
|
|
press-key: "Tab"
|
|
|
|
press-key: "Tab"
|
2023-01-26 20:32:33 +00:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
assert: "#method\.create_an_iterator_from_read .tooltip:focus"
|
2022-11-18 23:25:37 +00:00
|
|
|
|
2024-04-20 12:53:14 +00:00
|
|
|
define-function: (
|
|
|
|
"setup-popup",
|
|
|
|
[],
|
|
|
|
block {
|
|
|
|
store-window-property: {"scrollY": scroll}
|
|
|
|
click: "#method\.create_an_iterator_from_read .fn"
|
|
|
|
// We ensure that the scroll position changed.
|
|
|
|
assert-window-property-false: {"scrollY": |scroll|}
|
|
|
|
// Store the new position.
|
|
|
|
store-window-property: {"scrollY": scroll}
|
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
wait-for: "//*[@class='tooltip popover']"
|
|
|
|
click: "#settings-menu a"
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2022-11-18 23:25:37 +00:00
|
|
|
// Now we check that the focus isn't given back to the wrong item when opening
|
|
|
|
// another popover.
|
2024-04-20 12:53:14 +00:00
|
|
|
call-function: ("setup-popup", {})
|
2022-11-18 23:25:37 +00:00
|
|
|
click: ".search-input"
|
|
|
|
// We ensure we didn't come back to the previous focused item.
|
|
|
|
assert-window-property-false: {"scrollY": |scroll|}
|
|
|
|
|
|
|
|
// Same but with Escape handling.
|
2024-04-20 12:53:14 +00:00
|
|
|
call-function: ("setup-popup", {})
|
2022-11-18 23:25:37 +00:00
|
|
|
press-key: "Escape"
|
|
|
|
// We ensure we didn't come back to the previous focused item.
|
|
|
|
assert-window-property-false: {"scrollY": |scroll|}
|
rustdoc: improve popover focus handling JS
This commit fixes a few inconsistencies and erratic behavior from the
notable traits, settings, and sidebar popups:
* It makes it so that pressing Escape closes the mobile sidebar.
This is a bit difficult to do on iPhone, but on other setups like
desktop tiling window managers, it's easy and makes sense.
* It makes sure that pressing escape while a notable trait popover is
open focuses the popover's toggle button, instead of leaving nothing
focused, since that makes more sense with keyboard navigation. Clicking
the settings, help, or sidebar buttons, however, will not focus the
notable trait popover toggle button.
* It ensures that notable trait and settings popovers are exclusive
with the mobile sidebar. Nothing should ever overlap a popover, and
there should never be more than one popover open at once.
2022-11-26 16:52:58 +00:00
|
|
|
|
|
|
|
// Opening the mobile sidebar should close the popover.
|
2023-04-11 17:11:34 +00:00
|
|
|
set-window-size: (650, 600)
|
2023-01-26 20:32:33 +00:00
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
assert-count: ("//*[@class='tooltip popover']", 1)
|
rustdoc: improve popover focus handling JS
This commit fixes a few inconsistencies and erratic behavior from the
notable traits, settings, and sidebar popups:
* It makes it so that pressing Escape closes the mobile sidebar.
This is a bit difficult to do on iPhone, but on other setups like
desktop tiling window managers, it's easy and makes sense.
* It makes sure that pressing escape while a notable trait popover is
open focuses the popover's toggle button, instead of leaving nothing
focused, since that makes more sense with keyboard navigation. Clicking
the settings, help, or sidebar buttons, however, will not focus the
notable trait popover toggle button.
* It ensures that notable trait and settings popovers are exclusive
with the mobile sidebar. Nothing should ever overlap a popover, and
there should never be more than one popover open at once.
2022-11-26 16:52:58 +00:00
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
assert: "//*[@class='sidebar shown']"
|
2023-01-26 20:32:33 +00:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
assert-false: "#method\.create_an_iterator_from_read .tooltip:focus"
|
|
|
|
// Clicking a notable trait tooltip popover should close the sidebar.
|
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
assert-count: ("//*[@class='tooltip popover']", 1)
|
rustdoc: improve popover focus handling JS
This commit fixes a few inconsistencies and erratic behavior from the
notable traits, settings, and sidebar popups:
* It makes it so that pressing Escape closes the mobile sidebar.
This is a bit difficult to do on iPhone, but on other setups like
desktop tiling window managers, it's easy and makes sense.
* It makes sure that pressing escape while a notable trait popover is
open focuses the popover's toggle button, instead of leaving nothing
focused, since that makes more sense with keyboard navigation. Clicking
the settings, help, or sidebar buttons, however, will not focus the
notable trait popover toggle button.
* It ensures that notable trait and settings popovers are exclusive
with the mobile sidebar. Nothing should ever overlap a popover, and
there should never be more than one popover open at once.
2022-11-26 16:52:58 +00:00
|
|
|
assert-false: "//*[@class='sidebar shown']"
|
|
|
|
|
|
|
|
// Also check the focus handling for the help button.
|
2023-04-11 17:11:34 +00:00
|
|
|
set-window-size: (1100, 600)
|
rustdoc: improve popover focus handling JS
This commit fixes a few inconsistencies and erratic behavior from the
notable traits, settings, and sidebar popups:
* It makes it so that pressing Escape closes the mobile sidebar.
This is a bit difficult to do on iPhone, but on other setups like
desktop tiling window managers, it's easy and makes sense.
* It makes sure that pressing escape while a notable trait popover is
open focuses the popover's toggle button, instead of leaving nothing
focused, since that makes more sense with keyboard navigation. Clicking
the settings, help, or sidebar buttons, however, will not focus the
notable trait popover toggle button.
* It ensures that notable trait and settings popovers are exclusive
with the mobile sidebar. Nothing should ever overlap a popover, and
there should never be more than one popover open at once.
2022-11-26 16:52:58 +00:00
|
|
|
reload:
|
2023-01-26 20:32:33 +00:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
assert-count: ("//*[@class='tooltip popover']", 1)
|
rustdoc: improve popover focus handling JS
This commit fixes a few inconsistencies and erratic behavior from the
notable traits, settings, and sidebar popups:
* It makes it so that pressing Escape closes the mobile sidebar.
This is a bit difficult to do on iPhone, but on other setups like
desktop tiling window managers, it's easy and makes sense.
* It makes sure that pressing escape while a notable trait popover is
open focuses the popover's toggle button, instead of leaving nothing
focused, since that makes more sense with keyboard navigation. Clicking
the settings, help, or sidebar buttons, however, will not focus the
notable trait popover toggle button.
* It ensures that notable trait and settings popovers are exclusive
with the mobile sidebar. Nothing should ever overlap a popover, and
there should never be more than one popover open at once.
2022-11-26 16:52:58 +00:00
|
|
|
click: "#help-button a"
|
2023-01-26 20:32:33 +00:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
assert-false: "#method\.create_an_iterator_from_read .tooltip:focus"
|