2021-07-15 20:12:28 +00:00
|
|
|
// This test ensure that the sidebar isn't "hidden" on mobile but instead moved out of the viewport.
|
|
|
|
// This is especially important for devices for "text-first" content (like for users with
|
|
|
|
// sight issues).
|
2023-04-11 17:11:34 +00:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
|
2021-07-15 20:12:28 +00:00
|
|
|
// Switching to "mobile view" by reducing the width to 600px.
|
2023-04-11 17:11:34 +00:00
|
|
|
set-window-size: (600, 600)
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
2021-07-15 20:12:28 +00:00
|
|
|
// Opening the sidebar menu.
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "0px"})
|
2021-07-16 15:04:49 +00:00
|
|
|
// Closing the sidebar menu.
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
2021-07-16 15:04:49 +00:00
|
|
|
// Force the sidebar open by focusing a link inside it.
|
|
|
|
// This makes it easier for keyboard users to get to it.
|
2022-10-15 18:53:47 +00:00
|
|
|
focus: ".sidebar-elems h3 a"
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "0px"})
|
2021-07-16 15:04:49 +00:00
|
|
|
// When we tab out of the sidebar, close it.
|
|
|
|
focus: ".search-input"
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
2022-01-12 02:27:44 +00:00
|
|
|
|
|
|
|
// Open the sidebar menu.
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
assert-css: (".sidebar", {"left": "0px"})
|
2022-01-12 02:27:44 +00:00
|
|
|
|
2022-10-18 18:14:01 +00:00
|
|
|
// Make sure the "struct Foo" header is hidden, since the mobile topbar already does it.
|
|
|
|
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='Foo']/parent::h2", {"display": "none"})
|
|
|
|
// Make sure the global navigation is still here.
|
|
|
|
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='In test_docs']/parent::h2", {"display": "block"})
|
|
|
|
|
2022-01-12 02:27:44 +00:00
|
|
|
// Click elsewhere.
|
|
|
|
click: "body"
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
|
|
|
|
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
|
|
|
// Open the sidebar menu, and make sure pressing Escape closes it.
|
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
assert-css: (".sidebar", {"left": "0px"})
|
|
|
|
press-key: "Escape"
|
|
|
|
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
|
|
|
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
// Check that the topbar is visible
|
|
|
|
assert-property: (".mobile-topbar", {"clientHeight": "45"})
|
2022-01-19 06:05:17 +00:00
|
|
|
|
|
|
|
// Check that clicking an element from the sidebar scrolls to the right place
|
|
|
|
// so the target is not obscured by the topbar.
|
|
|
|
click: ".sidebar-menu-toggle"
|
2022-02-08 16:05:00 +00:00
|
|
|
click: ".sidebar-elems section .block li > a"
|
2023-02-12 19:27:40 +00:00
|
|
|
assert-position: ("#method\.must_use", {"y": 46})
|
2022-01-22 01:44:54 +00:00
|
|
|
|
|
|
|
// Check that the bottom-most item on the sidebar menu can be scrolled fully into view.
|
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
scroll-to: ".block.keyword li:nth-child(1)"
|
2022-10-18 18:14:01 +00:00
|
|
|
compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 543.19})
|
2022-07-25 12:35:06 +00:00
|
|
|
|
|
|
|
// Now checking the background color of the sidebar.
|
2022-10-05 09:20:14 +00:00
|
|
|
show-text: true
|
2022-07-25 12:35:06 +00:00
|
|
|
|
2022-11-26 21:35:05 +00:00
|
|
|
define-function: (
|
|
|
|
"check-colors",
|
|
|
|
(theme, color, background),
|
2023-01-06 14:18:51 +00:00
|
|
|
block {
|
2023-04-11 17:11:34 +00:00
|
|
|
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}
|
2023-01-06 14:18:51 +00:00
|
|
|
reload:
|
2022-07-25 12:35:06 +00:00
|
|
|
|
2022-11-26 21:35:05 +00:00
|
|
|
// Open the sidebar menu.
|
2023-01-06 14:18:51 +00:00
|
|
|
click: ".sidebar-menu-toggle"
|
|
|
|
assert-css: (".sidebar", {
|
2022-11-26 21:35:05 +00:00
|
|
|
"background-color": |background|,
|
|
|
|
"color": |color|,
|
2023-01-06 14:18:51 +00:00
|
|
|
})
|
|
|
|
},
|
2022-11-26 21:35:05 +00:00
|
|
|
)
|
2022-07-25 12:35:06 +00:00
|
|
|
|
2022-11-26 21:35:05 +00:00
|
|
|
call-function: ("check-colors", {
|
|
|
|
"theme": "ayu",
|
|
|
|
"color": "rgb(197, 197, 197)",
|
|
|
|
"background": "rgb(20, 25, 31)",
|
|
|
|
})
|
|
|
|
call-function: ("check-colors", {
|
|
|
|
"theme": "dark",
|
|
|
|
"color": "rgb(221, 221, 221)",
|
|
|
|
"background": "rgb(80, 80, 80)",
|
|
|
|
})
|
|
|
|
call-function: ("check-colors", {
|
|
|
|
"theme": "light",
|
|
|
|
"color": "rgb(0, 0, 0)",
|
|
|
|
"background": "rgb(245, 245, 245)",
|
|
|
|
})
|