mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
bb7ed64f45
Fixes the desktop scrolling weirdness mentioned in https://github.com/rust-lang/rust/pull/98775#issuecomment-1182575603 As described in the MDN page for this property: * The current Firefox ESR is 102, and the first Firefox version to support this feature is 59. * The current Chrome version 112, and the first version to support this is 63. * Edge is described as having a minor bug in `none` mode, but we use `contain` mode anyway, so it doesn't matter. * Safari 16, released September 2022, is the last browser to add this feature, and is also the oldest version we officially support.
206 lines
8.0 KiB
Plaintext
206 lines
8.0 KiB
Plaintext
// This test ensures that the elements in the sidebar are displayed correctly.
|
|
javascript: false
|
|
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
|
// Since the javascript is disabled, there shouldn't be a toggle.
|
|
assert-false: "#src-sidebar-toggle"
|
|
wait-for-css: (".sidebar", {"display": "none"})
|
|
|
|
// Let's retry with javascript enabled.
|
|
javascript: true
|
|
reload:
|
|
wait-for: "#src-sidebar-toggle"
|
|
assert-css: ("#src-sidebar-toggle", {"visibility": "visible"})
|
|
assert-css: (".sidebar > *:not(#src-sidebar-toggle)", {"visibility": "hidden"})
|
|
// Let's expand the sidebar now.
|
|
click: "#src-sidebar-toggle"
|
|
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
|
|
|
|
// We now check that opening the sidebar and clicking a link will leave it open.
|
|
// The behavior here on desktop is different than the behavior on mobile,
|
|
// but since the sidebar doesn't fill the entire screen here, it makes sense to have the
|
|
// sidebar stay resident.
|
|
wait-for-css: (".sidebar", {"width": "300px"})
|
|
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
|
|
click: ".sidebar a.selected"
|
|
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
|
wait-for-css: (".sidebar", {"width": "300px"})
|
|
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
|
|
|
|
// Now we check the display of the sidebar items.
|
|
show-text: true
|
|
|
|
define-function: (
|
|
"check-colors",
|
|
(
|
|
theme, color, color_hover, background, background_hover, background_toggle,
|
|
background_toggle_hover,
|
|
),
|
|
block {
|
|
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
|
reload:
|
|
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
|
|
assert-css: (
|
|
"#source-sidebar details[open] > .files a.selected",
|
|
{"color": |color_hover|, "background-color": |background|},
|
|
)
|
|
|
|
// Without hover or focus.
|
|
assert-css: ("#src-sidebar-toggle > button", {"background-color": |background_toggle|})
|
|
// With focus.
|
|
focus: "#src-sidebar-toggle > button"
|
|
assert-css: (
|
|
"#src-sidebar-toggle > button:focus",
|
|
{"background-color": |background_toggle_hover|},
|
|
)
|
|
focus: ".search-input"
|
|
// With hover.
|
|
move-cursor-to: "#src-sidebar-toggle > button"
|
|
assert-css: (
|
|
"#src-sidebar-toggle > button:hover",
|
|
{"background-color": |background_toggle_hover|},
|
|
)
|
|
|
|
// Without hover or focus.
|
|
assert-css: (
|
|
"#source-sidebar details[open] > .files a:not(.selected)",
|
|
{"color": |color|, "background-color": |background_toggle|},
|
|
)
|
|
// With focus.
|
|
focus: "#source-sidebar details[open] > .files a:not(.selected)"
|
|
wait-for-css: (
|
|
"#source-sidebar details[open] > .files a:not(.selected):focus",
|
|
{"color": |color_hover|, "background-color": |background_hover|},
|
|
)
|
|
focus: ".search-input"
|
|
// With hover.
|
|
move-cursor-to: "#source-sidebar details[open] > .files a:not(.selected)"
|
|
assert-css: (
|
|
"#source-sidebar details[open] > .files a:not(.selected):hover",
|
|
{"color": |color_hover|, "background-color": |background_hover|},
|
|
)
|
|
|
|
// Without hover or focus.
|
|
assert-css: (
|
|
"#source-sidebar .dir-entry summary",
|
|
{"color": |color|, "background-color": |background_toggle|},
|
|
)
|
|
// With focus.
|
|
focus: "#source-sidebar .dir-entry summary"
|
|
wait-for-css: (
|
|
"#source-sidebar .dir-entry summary:focus",
|
|
{"color": |color_hover|, "background-color": |background_hover|},
|
|
)
|
|
focus: ".search-input"
|
|
// With hover.
|
|
move-cursor-to: "#source-sidebar .dir-entry summary"
|
|
assert-css: (
|
|
"#source-sidebar .dir-entry summary:hover",
|
|
{"color": |color_hover|, "background-color": |background_hover|},
|
|
)
|
|
|
|
// Without hover or focus.
|
|
assert-css: (
|
|
"#source-sidebar details[open] > .folders > details > summary",
|
|
{"color": |color|, "background-color": |background_toggle|},
|
|
)
|
|
// With focus.
|
|
focus: "#source-sidebar details[open] > .folders > details > summary"
|
|
wait-for-css: (
|
|
"#source-sidebar details[open] > .folders > details > summary:focus",
|
|
{"color": |color_hover|, "background-color": |background_hover|},
|
|
)
|
|
focus: ".search-input"
|
|
// With hover.
|
|
move-cursor-to: "#source-sidebar details[open] > .folders > details > summary"
|
|
assert-css: (
|
|
"#source-sidebar details[open] > .folders > details > summary:hover",
|
|
{"color": |color_hover|, "background-color": |background_hover|},
|
|
)
|
|
},
|
|
)
|
|
|
|
call-function: ("check-colors", {
|
|
"theme": "light",
|
|
"color": "rgb(0, 0, 0)",
|
|
"color_hover": "rgb(0, 0, 0)",
|
|
"background": "rgb(255, 255, 255)",
|
|
"background_hover": "rgb(224, 224, 224)",
|
|
"background_toggle": "rgba(0, 0, 0, 0)",
|
|
"background_toggle_hover": "rgb(224, 224, 224)",
|
|
})
|
|
call-function: ("check-colors", {
|
|
"theme": "dark",
|
|
"color": "rgb(221, 221, 221)",
|
|
"color_hover": "rgb(221, 221, 221)",
|
|
"background": "rgb(51, 51, 51)",
|
|
"background_hover": "rgb(68, 68, 68)",
|
|
"background_toggle": "rgba(0, 0, 0, 0)",
|
|
"background_toggle_hover": "rgb(103, 103, 103)",
|
|
})
|
|
call-function: ("check-colors", {
|
|
"theme": "ayu",
|
|
"color": "rgb(197, 197, 197)",
|
|
"color_hover": "rgb(255, 180, 76)",
|
|
"background": "rgb(20, 25, 31)",
|
|
"background_hover": "rgb(20, 25, 31)",
|
|
"background_toggle": "rgba(0, 0, 0, 0)",
|
|
"background_toggle_hover": "rgba(70, 70, 70, 0.33)",
|
|
})
|
|
|
|
// Now checking on mobile devices.
|
|
set-window-size: (500, 700)
|
|
reload:
|
|
// Waiting for the sidebar to be displayed...
|
|
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
|
|
|
|
// We now check it takes the full size of the display.
|
|
assert-property: ("body", {"clientWidth": "500", "clientHeight": "700"})
|
|
assert-property: (".sidebar", {"clientWidth": "500", "clientHeight": "700"})
|
|
|
|
// We now check the display of the toggle once the sidebar is expanded.
|
|
assert-property: ("#src-sidebar-toggle", {"clientWidth": "500", "clientHeight": "39"})
|
|
assert-css: (
|
|
"#src-sidebar-toggle",
|
|
{
|
|
"border-top-width": "0px",
|
|
"border-right-width": "0px",
|
|
"border-left-width": "0px",
|
|
"border-bottom-width": "1px",
|
|
},
|
|
)
|
|
|
|
// We now check that the scroll position is kept when opening the sidebar.
|
|
click: "#src-sidebar-toggle"
|
|
wait-for-css: (".sidebar", {"left": "-1000px"})
|
|
// We scroll to line 117 to change the scroll position.
|
|
scroll-to: '//*[@id="117"]'
|
|
assert-window-property: {"pageYOffset": "2542"}
|
|
// Expanding the sidebar...
|
|
click: "#src-sidebar-toggle"
|
|
wait-for-css: (".sidebar", {"left": "0px"})
|
|
click: "#src-sidebar-toggle"
|
|
wait-for-css: (".sidebar", {"left": "-1000px"})
|
|
// The "scrollTop" property should be the same.
|
|
assert-window-property: {"pageYOffset": "2542"}
|
|
|
|
// We now check that opening the sidebar and clicking a link will close it.
|
|
// The behavior here on mobile is different than the behavior on desktop,
|
|
// but common sense dictates that if you have a list of files that fills the entire screen, and
|
|
// you click one of them, you probably want to actually see the file's contents, and not just
|
|
// make it the current selection.
|
|
set-window-size: (500, 700)
|
|
click: "#src-sidebar-toggle"
|
|
wait-for-css: ("#source-sidebar", {"visibility": "visible"})
|
|
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
|
|
click: ".sidebar a.selected"
|
|
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
|
wait-for-css: ("#source-sidebar", {"visibility": "hidden"})
|
|
assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
|
|
// Resize back to desktop size, to check that the sidebar doesn't spontaneously open.
|
|
set-window-size: (1000, 1000)
|
|
wait-for-css: ("#source-sidebar", {"visibility": "hidden"})
|
|
assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
|
|
click: "#src-sidebar-toggle"
|
|
wait-for-css: ("#source-sidebar", {"visibility": "visible"})
|
|
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
|