2022-09-19 05:32:30 -05:00
|
|
|
// This test checks the position of the `i` for the notable traits.
|
2022-10-07 13:17:05 -05:00
|
|
|
goto: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
|
2022-09-19 05:32:30 -05:00
|
|
|
show-text: true
|
|
|
|
// We start with a wide screen.
|
|
|
|
size: (1100, 600)
|
|
|
|
// Checking they have the same y position.
|
|
|
|
compare-elements-position: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
2022-09-19 05:32:30 -05:00
|
|
|
("y"),
|
|
|
|
)
|
|
|
|
// Checking they don't have the same x position.
|
|
|
|
compare-elements-position-false: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
2022-09-19 05:32:30 -05:00
|
|
|
("x"),
|
|
|
|
)
|
|
|
|
// The `i` should be *after* the type.
|
|
|
|
assert-position: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
2022-09-22 13:51:48 -05:00
|
|
|
{"x": 677},
|
2022-09-19 05:32:30 -05:00
|
|
|
)
|
|
|
|
assert-position: (
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
2022-11-08 19:00:22 -06:00
|
|
|
{"x": 955},
|
2022-09-19 05:32:30 -05:00
|
|
|
)
|
2022-11-08 19:00:22 -06:00
|
|
|
// The tooltip should be below the `i`
|
2022-11-07 16:53:30 -06:00
|
|
|
// Also, clicking the tooltip should bring its text into the DOM
|
2023-01-26 14:32:33 -06:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
assert-count: ("//*[@class='tooltip popover']", 1)
|
2022-10-26 16:42:53 -05:00
|
|
|
compare-elements-position-near: (
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
|
|
|
"//*[@class='tooltip popover']",
|
2022-11-08 19:00:22 -06:00
|
|
|
{"y": 30}
|
2022-10-26 16:42:53 -05:00
|
|
|
)
|
|
|
|
compare-elements-position-false: (
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
|
|
|
"//*[@class='tooltip popover']",
|
2022-10-26 16:42:53 -05:00
|
|
|
("x")
|
|
|
|
)
|
2023-01-26 14:32:33 -06:00
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
2022-11-07 16:53:30 -06:00
|
|
|
move-cursor-to: "//h1"
|
2023-01-26 14:32:33 -06:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
2022-09-19 05:32:30 -05:00
|
|
|
|
|
|
|
// Now only the `i` should be on the next line.
|
|
|
|
size: (1055, 600)
|
|
|
|
compare-elements-position-false: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
2022-09-19 05:32:30 -05:00
|
|
|
("y", "x"),
|
|
|
|
)
|
|
|
|
|
|
|
|
// Now both the `i` and the struct name should be on the next line.
|
|
|
|
size: (980, 600)
|
|
|
|
// Checking they have the same y position.
|
|
|
|
compare-elements-position: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
2022-09-19 05:32:30 -05:00
|
|
|
("y"),
|
|
|
|
)
|
|
|
|
// Checking they don't have the same x position.
|
|
|
|
compare-elements-position-false: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
2022-09-19 05:32:30 -05:00
|
|
|
("x"),
|
|
|
|
)
|
|
|
|
// The `i` should be *after* the type.
|
|
|
|
assert-position: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
|
|
|
{"x": 245},
|
|
|
|
)
|
|
|
|
assert-position: (
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
2022-11-08 19:00:22 -06:00
|
|
|
{"x": 523},
|
2022-09-19 05:32:30 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// Checking on mobile now.
|
|
|
|
size: (650, 600)
|
|
|
|
// Checking they have the same y position.
|
|
|
|
compare-elements-position: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
2022-09-19 05:32:30 -05:00
|
|
|
("y"),
|
|
|
|
)
|
|
|
|
// Checking they don't have the same x position.
|
|
|
|
compare-elements-position-false: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
2022-09-19 05:32:30 -05:00
|
|
|
("x"),
|
|
|
|
)
|
|
|
|
// The `i` should be *after* the type.
|
|
|
|
assert-position: (
|
|
|
|
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
|
|
|
{"x": 15},
|
|
|
|
)
|
|
|
|
assert-position: (
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
2022-11-08 19:00:22 -06:00
|
|
|
{"x": 293},
|
2022-09-19 05:32:30 -05:00
|
|
|
)
|
2022-11-08 19:00:22 -06:00
|
|
|
// The tooltip should STILL be below `i`
|
2023-01-26 14:32:33 -06:00
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
assert-count: ("//*[@class='tooltip popover']", 1)
|
2022-11-08 19:00:22 -06:00
|
|
|
compare-elements-position-near: (
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
|
|
|
"//*[@class='tooltip popover']",
|
2022-11-08 19:00:22 -06:00
|
|
|
{"y": 30}
|
2022-10-26 16:42:53 -05:00
|
|
|
)
|
|
|
|
compare-elements-position-false: (
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
|
|
|
"//*[@class='tooltip popover']",
|
2022-10-26 16:42:53 -05:00
|
|
|
("x")
|
|
|
|
)
|
2022-11-08 19:00:22 -06:00
|
|
|
assert-position: (
|
2023-01-26 14:32:33 -06:00
|
|
|
"//*[@class='tooltip popover']",
|
2022-11-08 19:00:22 -06:00
|
|
|
{"x": 0}
|
2022-10-26 16:42:53 -05:00
|
|
|
)
|
2023-01-26 14:32:33 -06:00
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
2022-11-07 16:53:30 -06:00
|
|
|
move-cursor-to: "//h1"
|
2023-01-26 14:32:33 -06:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
2022-09-19 05:32:30 -05:00
|
|
|
|
2022-11-07 22:18:01 -06:00
|
|
|
// Now check the colors.
|
|
|
|
define-function: (
|
|
|
|
"check-colors",
|
|
|
|
(theme, header_color, content_color, type_color, trait_color),
|
2023-01-06 08:18:51 -06:00
|
|
|
block {
|
|
|
|
goto: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
|
2022-11-07 22:18:01 -06:00
|
|
|
// This is needed to ensure that the text color is computed.
|
2023-01-06 08:18:51 -06:00
|
|
|
show-text: true
|
2022-11-07 22:18:01 -06:00
|
|
|
|
|
|
|
// Setting the theme.
|
2023-01-06 08:18:51 -06:00
|
|
|
local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
2022-11-07 22:18:01 -06:00
|
|
|
// We reload the page so the local storage settings are being used.
|
2023-01-06 08:18:51 -06:00
|
|
|
reload:
|
2022-11-07 22:18:01 -06:00
|
|
|
|
2023-01-26 14:32:33 -06:00
|
|
|
move-cursor-to: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
assert-count: (".tooltip.popover", 1)
|
2022-11-07 22:18:01 -06:00
|
|
|
|
2023-01-06 08:18:51 -06:00
|
|
|
assert-css: (
|
2023-01-26 14:32:33 -06:00
|
|
|
".tooltip.popover h3",
|
2022-11-07 22:18:01 -06:00
|
|
|
{"color": |header_color|},
|
|
|
|
ALL,
|
2023-01-06 08:18:51 -06:00
|
|
|
)
|
|
|
|
assert-css: (
|
2023-01-26 14:32:33 -06:00
|
|
|
".tooltip.popover pre",
|
2022-11-07 22:18:01 -06:00
|
|
|
{"color": |content_color|},
|
|
|
|
ALL,
|
2023-01-06 08:18:51 -06:00
|
|
|
)
|
|
|
|
assert-css: (
|
2023-01-26 14:32:33 -06:00
|
|
|
".tooltip.popover pre a.struct",
|
2022-11-07 22:18:01 -06:00
|
|
|
{"color": |type_color|},
|
|
|
|
ALL,
|
2023-01-06 08:18:51 -06:00
|
|
|
)
|
|
|
|
assert-css: (
|
2023-01-26 14:32:33 -06:00
|
|
|
".tooltip.popover pre a.trait",
|
2022-11-07 22:18:01 -06:00
|
|
|
{"color": |trait_color|},
|
|
|
|
ALL,
|
2023-01-06 08:18:51 -06:00
|
|
|
)
|
|
|
|
},
|
2022-11-07 22:18:01 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
call-function: (
|
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "ayu",
|
|
|
|
"content_color": "rgb(230, 225, 207)",
|
|
|
|
"header_color": "rgb(255, 255, 255)",
|
|
|
|
"type_color": "rgb(255, 160, 165)",
|
|
|
|
"trait_color": "rgb(57, 175, 215)",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
call-function: (
|
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "dark",
|
|
|
|
"content_color": "rgb(221, 221, 221)",
|
|
|
|
"header_color": "rgb(221, 221, 221)",
|
|
|
|
"type_color": "rgb(45, 191, 184)",
|
|
|
|
"trait_color": "rgb(183, 140, 242)",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
call-function: (
|
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "light",
|
|
|
|
"content_color": "rgb(0, 0, 0)",
|
|
|
|
"header_color": "rgb(0, 0, 0)",
|
|
|
|
"type_color": "rgb(173, 55, 138)",
|
|
|
|
"trait_color": "rgb(110, 79, 201)",
|
|
|
|
},
|
|
|
|
)
|
2022-11-08 18:59:03 -06:00
|
|
|
|
|
|
|
reload:
|
|
|
|
|
|
|
|
// Check that pressing escape works
|
2023-01-26 14:32:33 -06: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-08 18:59:03 -06:00
|
|
|
press-key: "Escape"
|
2023-01-26 14:32:33 -06:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
assert: "#method\.create_an_iterator_from_read .tooltip:focus"
|
2022-11-08 18:59:03 -06:00
|
|
|
|
|
|
|
// Check that clicking outside works.
|
2023-01-26 14:32:33 -06:00
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
assert-count: ("//*[@class='tooltip popover']", 1)
|
2022-11-08 18:59:03 -06:00
|
|
|
click: ".search-input"
|
2023-01-26 14:32:33 -06:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
assert-false: "#method\.create_an_iterator_from_read .tooltip:focus"
|
2022-11-08 18:59:03 -06:00
|
|
|
|
|
|
|
// Check that pressing tab over and over works.
|
2023-01-26 14:32:33 -06: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-08 18:59:03 -06: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 14:32:33 -06:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
assert: "#method\.create_an_iterator_from_read .tooltip:focus"
|
2022-11-18 17:25:37 -06:00
|
|
|
|
|
|
|
// Now we check that the focus isn't given back to the wrong item when opening
|
|
|
|
// another popover.
|
|
|
|
store-window-property: (scroll, "scrollY")
|
2022-11-28 11:21:19 -06:00
|
|
|
click: "#method\.create_an_iterator_from_read .fn"
|
2022-11-18 17:25:37 -06:00
|
|
|
// We ensure that the scroll position changed.
|
|
|
|
assert-window-property-false: {"scrollY": |scroll|}
|
|
|
|
// Store the new position.
|
|
|
|
store-window-property: (scroll, "scrollY")
|
2023-01-26 14:32:33 -06:00
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
wait-for: "//*[@class='tooltip popover']"
|
2022-11-18 17:25:37 -06:00
|
|
|
click: "#settings-menu a"
|
|
|
|
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.
|
|
|
|
store-window-property: (scroll, "scrollY")
|
2022-11-28 11:21:19 -06:00
|
|
|
click: "#method\.create_an_iterator_from_read .fn"
|
2022-11-18 17:25:37 -06:00
|
|
|
// We ensure that the scroll position changed.
|
|
|
|
assert-window-property-false: {"scrollY": |scroll|}
|
|
|
|
// Store the new position.
|
|
|
|
store-window-property: (scroll, "scrollY")
|
2023-01-26 14:32:33 -06:00
|
|
|
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
|
|
|
|
wait-for: "//*[@class='tooltip popover']"
|
2022-11-18 17:25:37 -06:00
|
|
|
click: "#settings-menu a"
|
|
|
|
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 10:52:58 -06:00
|
|
|
|
|
|
|
// Opening the mobile sidebar should close the popover.
|
|
|
|
size: (650, 600)
|
2023-01-26 14:32:33 -06: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 10:52:58 -06:00
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
assert: "//*[@class='sidebar shown']"
|
2023-01-26 14:32:33 -06: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 10:52:58 -06:00
|
|
|
assert-false: "//*[@class='sidebar shown']"
|
|
|
|
|
|
|
|
// Also check the focus handling for the help button.
|
|
|
|
size: (1100, 600)
|
|
|
|
reload:
|
2023-01-26 14:32:33 -06: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 10:52:58 -06:00
|
|
|
click: "#help-button a"
|
2023-01-26 14:32:33 -06:00
|
|
|
assert-count: ("//*[@class='tooltip popover']", 0)
|
|
|
|
assert-false: "#method\.create_an_iterator_from_read .tooltip:focus"
|