about summary refs log tree commit diff
path: root/src/test/rustdoc-gui/sidebar-source-code-display.goml
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2022-06-30 17:28:29 -0700
committerMichael Howell <michael@notriddle.com>2022-07-05 11:12:18 -0700
commit6b60bc64087e130f30e3bc095a3ef9e0c1790fef (patch)
treeca86c2f236a54f09a0ba7b69e07bd4db608d5be8 /src/test/rustdoc-gui/sidebar-source-code-display.goml
parent54f79babae06d3772c067f696e5b12db822ae25f (diff)
downloadrust-6b60bc64087e130f30e3bc095a3ef9e0c1790fef.tar.gz
rust-6b60bc64087e130f30e3bc095a3ef9e0c1790fef.zip
rustdoc: improve scroll locking in the rustdoc mobile sidebars
This commit ports the scroll locking behavior from the source sidebar to the
regular sidebar, and also fixes some bad behavior where opening a "mobile"
sidebar, and growing the viewport so that the "desktop" mode without scroll
locking is activated, could potentially leave the page stuck.

This does not affect the behavior on larger screens. Only small ones, where
the sidebar covers up the main content.
Diffstat (limited to 'src/test/rustdoc-gui/sidebar-source-code-display.goml')
-rw-r--r--src/test/rustdoc-gui/sidebar-source-code-display.goml11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/rustdoc-gui/sidebar-source-code-display.goml b/src/test/rustdoc-gui/sidebar-source-code-display.goml
index fa322574fde..e4662a10ed5 100644
--- a/src/test/rustdoc-gui/sidebar-source-code-display.goml
+++ b/src/test/rustdoc-gui/sidebar-source-code-display.goml
@@ -233,6 +233,17 @@ wait-for-css: (".sidebar", {"width": "0px"})
 // The "scrollTop" property should be the same.
 assert-window-property: {"pageYOffset": "2519"}
 
+// We now check that the scroll position is restored if the window is resized.
+size: (500, 700)
+click: "#sidebar-toggle"
+wait-for-css: ("#source-sidebar", {"visibility": "visible"})
+assert-window-property: {"pageYOffset": "0"}
+size: (900, 900)
+assert-window-property: {"pageYOffset": "2519"}
+size: (500, 700)
+click: "#sidebar-toggle"
+wait-for-css: ("#source-sidebar", {"visibility": "hidden"})
+
 // 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