2022-02-24 11:18:10 +00:00
|
|
|
// This test ensures that the elements in the sidebar are displayed correctly.
|
|
|
|
javascript: false
|
2023-04-11 17:11:34 +00:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
2022-02-24 11:18:10 +00:00
|
|
|
// Since the javascript is disabled, there shouldn't be a toggle.
|
2022-12-15 23:29:52 +00:00
|
|
|
assert-false: "#src-sidebar-toggle"
|
2022-10-24 17:47:24 +00:00
|
|
|
wait-for-css: (".sidebar", {"display": "none"})
|
2022-02-24 11:18:10 +00:00
|
|
|
|
|
|
|
// Let's retry with javascript enabled.
|
|
|
|
javascript: true
|
|
|
|
reload:
|
2022-12-15 23:29:52 +00:00
|
|
|
wait-for: "#src-sidebar-toggle"
|
|
|
|
assert-css: ("#src-sidebar-toggle", {"visibility": "visible"})
|
|
|
|
assert-css: (".sidebar > *:not(#src-sidebar-toggle)", {"visibility": "hidden"})
|
2022-02-24 11:18:10 +00:00
|
|
|
// Let's expand the sidebar now.
|
2022-12-15 23:29:52 +00:00
|
|
|
click: "#src-sidebar-toggle"
|
|
|
|
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
|
2022-06-25 20:22:35 +00:00
|
|
|
|
2022-07-01 19:13:46 +00:00
|
|
|
// 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"
|
2023-04-11 17:11:34 +00:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
2022-07-02 17:41:46 +00:00
|
|
|
wait-for-css: (".sidebar", {"width": "300px"})
|
2022-07-01 19:13:46 +00:00
|
|
|
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
|
|
|
|
|
2022-06-25 20:22:35 +00:00
|
|
|
// Now we check the display of the sidebar items.
|
|
|
|
show-text: true
|
|
|
|
|
2022-11-16 16:36:43 +00:00
|
|
|
define-function: (
|
|
|
|
"check-colors",
|
|
|
|
(
|
|
|
|
theme, color, color_hover, background, background_hover, background_toggle,
|
|
|
|
background_toggle_hover,
|
|
|
|
),
|
2023-01-06 14:18:51 +00:00
|
|
|
block {
|
2023-04-11 17:11:34 +00:00
|
|
|
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
2023-01-06 14:18:51 +00:00
|
|
|
reload:
|
|
|
|
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
|
|
|
|
assert-css: (
|
2023-07-14 23:38:01 +00:00
|
|
|
"#src-sidebar details[open] > .files a.selected",
|
2022-11-16 16:36:43 +00:00
|
|
|
{"color": |color_hover|, "background-color": |background|},
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
2022-11-24 22:36:41 +00:00
|
|
|
|
2022-11-16 16:36:43 +00:00
|
|
|
// Without hover or focus.
|
2023-01-06 14:18:51 +00:00
|
|
|
assert-css: ("#src-sidebar-toggle > button", {"background-color": |background_toggle|})
|
2022-11-16 16:36:43 +00:00
|
|
|
// With focus.
|
2023-01-06 14:18:51 +00:00
|
|
|
focus: "#src-sidebar-toggle > button"
|
|
|
|
assert-css: (
|
2022-12-15 23:29:52 +00:00
|
|
|
"#src-sidebar-toggle > button:focus",
|
2022-11-24 22:39:49 +00:00
|
|
|
{"background-color": |background_toggle_hover|},
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
|
|
|
focus: ".search-input"
|
2022-11-16 16:36:43 +00:00
|
|
|
// With hover.
|
2023-01-06 14:18:51 +00:00
|
|
|
move-cursor-to: "#src-sidebar-toggle > button"
|
|
|
|
assert-css: (
|
2022-12-15 23:29:52 +00:00
|
|
|
"#src-sidebar-toggle > button:hover",
|
2022-11-24 22:39:49 +00:00
|
|
|
{"background-color": |background_toggle_hover|},
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
2022-11-24 22:36:41 +00:00
|
|
|
|
|
|
|
// Without hover or focus.
|
2023-01-06 14:18:51 +00:00
|
|
|
assert-css: (
|
2023-07-14 23:38:01 +00:00
|
|
|
"#src-sidebar details[open] > .files a:not(.selected)",
|
2022-11-16 16:36:43 +00:00
|
|
|
{"color": |color|, "background-color": |background_toggle|},
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
2022-11-16 16:36:43 +00:00
|
|
|
// With focus.
|
2023-07-14 23:38:01 +00:00
|
|
|
focus: "#src-sidebar details[open] > .files a:not(.selected)"
|
2023-01-06 14:18:51 +00:00
|
|
|
wait-for-css: (
|
2023-07-14 23:38:01 +00:00
|
|
|
"#src-sidebar details[open] > .files a:not(.selected):focus",
|
2022-11-16 16:36:43 +00:00
|
|
|
{"color": |color_hover|, "background-color": |background_hover|},
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
|
|
|
focus: ".search-input"
|
2022-11-16 16:36:43 +00:00
|
|
|
// With hover.
|
2023-07-14 23:38:01 +00:00
|
|
|
move-cursor-to: "#src-sidebar details[open] > .files a:not(.selected)"
|
2023-01-06 14:18:51 +00:00
|
|
|
assert-css: (
|
2023-07-14 23:38:01 +00:00
|
|
|
"#src-sidebar details[open] > .files a:not(.selected):hover",
|
2022-11-16 16:36:43 +00:00
|
|
|
{"color": |color_hover|, "background-color": |background_hover|},
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
2022-11-24 22:36:41 +00:00
|
|
|
|
|
|
|
// Without hover or focus.
|
2023-01-06 14:18:51 +00:00
|
|
|
assert-css: (
|
2023-07-14 23:38:01 +00:00
|
|
|
"#src-sidebar .dir-entry summary",
|
2022-11-24 22:36:41 +00:00
|
|
|
{"color": |color|, "background-color": |background_toggle|},
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
2022-11-24 22:36:41 +00:00
|
|
|
// With focus.
|
2023-07-14 23:38:01 +00:00
|
|
|
focus: "#src-sidebar .dir-entry summary"
|
2023-01-06 14:18:51 +00:00
|
|
|
wait-for-css: (
|
2023-07-14 23:38:01 +00:00
|
|
|
"#src-sidebar .dir-entry summary:focus",
|
2022-11-24 22:36:41 +00:00
|
|
|
{"color": |color_hover|, "background-color": |background_hover|},
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
|
|
|
focus: ".search-input"
|
2022-11-24 22:36:41 +00:00
|
|
|
// With hover.
|
2023-07-14 23:38:01 +00:00
|
|
|
move-cursor-to: "#src-sidebar .dir-entry summary"
|
2023-01-06 14:18:51 +00:00
|
|
|
assert-css: (
|
2023-07-14 23:38:01 +00:00
|
|
|
"#src-sidebar .dir-entry summary:hover",
|
2022-11-24 22:36:41 +00:00
|
|
|
{"color": |color_hover|, "background-color": |background_hover|},
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
2022-11-24 22:36:41 +00:00
|
|
|
|
|
|
|
// Without hover or focus.
|
2023-01-06 14:18:51 +00:00
|
|
|
assert-css: (
|
2023-07-14 23:38:01 +00:00
|
|
|
"#src-sidebar details[open] > .folders > details > summary",
|
2022-11-16 16:36:43 +00:00
|
|
|
{"color": |color|, "background-color": |background_toggle|},
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
2022-11-16 16:36:43 +00:00
|
|
|
// With focus.
|
2023-07-14 23:38:01 +00:00
|
|
|
focus: "#src-sidebar details[open] > .folders > details > summary"
|
2023-01-06 14:18:51 +00:00
|
|
|
wait-for-css: (
|
2023-07-14 23:38:01 +00:00
|
|
|
"#src-sidebar details[open] > .folders > details > summary:focus",
|
2022-11-16 16:36:43 +00:00
|
|
|
{"color": |color_hover|, "background-color": |background_hover|},
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
|
|
|
focus: ".search-input"
|
2022-11-16 16:36:43 +00:00
|
|
|
// With hover.
|
2023-07-14 23:38:01 +00:00
|
|
|
move-cursor-to: "#src-sidebar details[open] > .folders > details > summary"
|
2023-01-06 14:18:51 +00:00
|
|
|
assert-css: (
|
2023-07-14 23:38:01 +00:00
|
|
|
"#src-sidebar details[open] > .folders > details > summary:hover",
|
2022-11-16 16:36:43 +00:00
|
|
|
{"color": |color_hover|, "background-color": |background_hover|},
|
2023-01-06 14:18:51 +00:00
|
|
|
)
|
|
|
|
},
|
2022-06-25 20:22:35 +00:00
|
|
|
)
|
|
|
|
|
2022-11-16 16:36:43 +00:00
|
|
|
call-function: ("check-colors", {
|
|
|
|
"theme": "light",
|
2023-05-11 09:34:19 +00:00
|
|
|
"color": "black",
|
|
|
|
"color_hover": "#000",
|
|
|
|
"background": "#fff",
|
|
|
|
"background_hover": "#e0e0e0",
|
2022-11-16 16:36:43 +00:00
|
|
|
"background_toggle": "rgba(0, 0, 0, 0)",
|
2023-05-11 09:34:19 +00:00
|
|
|
"background_toggle_hover": "#e0e0e0",
|
2022-11-16 16:36:43 +00:00
|
|
|
})
|
|
|
|
call-function: ("check-colors", {
|
|
|
|
"theme": "dark",
|
2023-05-11 09:34:19 +00:00
|
|
|
"color": "#ddd",
|
|
|
|
"color_hover": "#ddd",
|
|
|
|
"background": "#333",
|
|
|
|
"background_hover": "#444",
|
2022-11-16 16:36:43 +00:00
|
|
|
"background_toggle": "rgba(0, 0, 0, 0)",
|
2023-05-11 09:34:19 +00:00
|
|
|
"background_toggle_hover": "#676767",
|
2022-11-16 16:36:43 +00:00
|
|
|
})
|
|
|
|
call-function: ("check-colors", {
|
|
|
|
"theme": "ayu",
|
2023-05-11 09:34:19 +00:00
|
|
|
"color": "#c5c5c5",
|
|
|
|
"color_hover": "#ffb44c",
|
2023-08-03 09:25:25 +00:00
|
|
|
"background": "#14191f",
|
2023-05-11 09:34:19 +00:00
|
|
|
"background_hover": "#14191f",
|
2022-11-16 16:36:43 +00:00
|
|
|
"background_toggle": "rgba(0, 0, 0, 0)",
|
|
|
|
"background_toggle_hover": "rgba(70, 70, 70, 0.33)",
|
|
|
|
})
|
2022-06-29 13:15:53 +00:00
|
|
|
|
|
|
|
// Now checking on mobile devices.
|
2023-04-11 17:11:34 +00:00
|
|
|
set-window-size: (500, 700)
|
2022-06-29 13:15:53 +00:00
|
|
|
reload:
|
|
|
|
// Waiting for the sidebar to be displayed...
|
2022-12-15 23:29:52 +00:00
|
|
|
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
|
2022-06-29 13:15:53 +00:00
|
|
|
|
|
|
|
// We now check it takes the full size of the display.
|
|
|
|
assert-property: ("body", {"clientWidth": "500", "clientHeight": "700"})
|
2022-06-29 13:30:01 +00:00
|
|
|
assert-property: (".sidebar", {"clientWidth": "500", "clientHeight": "700"})
|
|
|
|
|
|
|
|
// We now check the display of the toggle once the sidebar is expanded.
|
2022-12-15 23:29:52 +00:00
|
|
|
assert-property: ("#src-sidebar-toggle", {"clientWidth": "500", "clientHeight": "39"})
|
2022-06-29 13:30:01 +00:00
|
|
|
assert-css: (
|
2022-12-15 23:29:52 +00:00
|
|
|
"#src-sidebar-toggle",
|
2022-06-29 13:30:01 +00:00
|
|
|
{
|
|
|
|
"border-top-width": "0px",
|
|
|
|
"border-right-width": "0px",
|
|
|
|
"border-left-width": "0px",
|
|
|
|
"border-bottom-width": "1px",
|
|
|
|
},
|
|
|
|
)
|
2022-06-29 21:21:46 +00:00
|
|
|
|
|
|
|
// We now check that the scroll position is kept when opening the sidebar.
|
2022-12-15 23:29:52 +00:00
|
|
|
click: "#src-sidebar-toggle"
|
2023-01-06 19:20:03 +00:00
|
|
|
wait-for-css: (".sidebar", {"left": "-1000px"})
|
2022-06-29 21:21:46 +00:00
|
|
|
// We scroll to line 117 to change the scroll position.
|
|
|
|
scroll-to: '//*[@id="117"]'
|
2023-09-20 01:08:55 +00:00
|
|
|
assert-window-property: {"pageYOffset": "2516"}
|
2022-06-29 21:21:46 +00:00
|
|
|
// Expanding the sidebar...
|
2022-12-15 23:29:52 +00:00
|
|
|
click: "#src-sidebar-toggle"
|
2023-01-06 19:20:03 +00:00
|
|
|
wait-for-css: (".sidebar", {"left": "0px"})
|
2022-12-15 23:29:52 +00:00
|
|
|
click: "#src-sidebar-toggle"
|
2023-01-06 19:20:03 +00:00
|
|
|
wait-for-css: (".sidebar", {"left": "-1000px"})
|
2022-06-29 21:21:46 +00:00
|
|
|
// The "scrollTop" property should be the same.
|
2023-09-20 01:08:55 +00:00
|
|
|
assert-window-property: {"pageYOffset": "2516"}
|
2022-07-01 19:13:46 +00:00
|
|
|
|
|
|
|
// 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.
|
2023-04-10 23:15:51 +00:00
|
|
|
set-window-size: (500, 700)
|
2022-12-15 23:29:52 +00:00
|
|
|
click: "#src-sidebar-toggle"
|
2023-07-14 23:38:01 +00:00
|
|
|
wait-for-css: ("#src-sidebar", {"visibility": "visible"})
|
2022-07-01 19:13:46 +00:00
|
|
|
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
|
|
|
|
click: ".sidebar a.selected"
|
2023-04-11 17:11:34 +00:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
2023-07-14 23:38:01 +00:00
|
|
|
wait-for-css: ("#src-sidebar", {"visibility": "hidden"})
|
2022-07-02 17:41:46 +00:00
|
|
|
assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
|
|
|
|
// Resize back to desktop size, to check that the sidebar doesn't spontaneously open.
|
2023-04-11 17:11:34 +00:00
|
|
|
set-window-size: (1000, 1000)
|
2023-07-14 23:38:01 +00:00
|
|
|
wait-for-css: ("#src-sidebar", {"visibility": "hidden"})
|
2022-07-01 19:13:46 +00:00
|
|
|
assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
|
2022-12-15 23:29:52 +00:00
|
|
|
click: "#src-sidebar-toggle"
|
2023-07-14 23:38:01 +00:00
|
|
|
wait-for-css: ("#src-sidebar", {"visibility": "visible"})
|
2022-07-02 17:41:46 +00:00
|
|
|
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
|