]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/escape-key.goml
Rollup merge of #95649 - ouz-a:mir-opt, r=oli-obk
[rust.git] / src / test / rustdoc-gui / escape-key.goml
1 // This test ensures that the "Escape" shortcut is handled correctly based on the
2 // current content displayed.
3 goto: file://|DOC_PATH|/test_docs/index.html
4 // First, we check that the search results are hidden when the Escape key is pressed.
5 write: (".search-input", "test")
6 wait-for: "#search h1" // The search element is empty before the first search 
7 assert-attribute: ("#search", {"class": "content"})
8 assert-attribute: ("#main-content", {"class": "content hidden"})
9 assert-document-property: ({"URL": "index.html?search=test"}, ENDS_WITH)
10 press-key: "Escape"
11 assert-attribute: ("#search", {"class": "content hidden"})
12 assert-attribute: ("#main-content", {"class": "content"})
13 assert-document-property: ({"URL": "index.html"}, [ENDS_WITH])
14
15 // Check that focusing the search input brings back the search results
16 focus: ".search-input"
17 assert-attribute: ("#search", {"class": "content"})
18 assert-attribute: ("#main-content", {"class": "content hidden"})
19 assert-document-property: ({"URL": "index.html?search=test"}, ENDS_WITH)
20
21 // Now let's check that when the help popup is displayed and we press Escape, it doesn't
22 // hide the search results too.
23 click: "#help-button"
24 assert-document-property: ({"URL": "index.html?search=test"}, [ENDS_WITH])
25 assert-attribute: ("#help", {"class": ""})
26 press-key: "Escape"
27 assert-attribute: ("#help", {"class": "hidden"})
28 assert-attribute: ("#search", {"class": "content"})
29 assert-attribute: ("#main-content", {"class": "content hidden"})
30 assert-document-property: ({"URL": "index.html?search=test"}, [ENDS_WITH])
31
32 // Check that Escape hides the search results when a search result is focused.
33 focus: ".search-input"
34 assert: ".search-input:focus"
35 press-key: "ArrowDown"
36 assert-false: ".search-input:focus"
37 assert: "#results a:focus"
38 press-key: "Escape"
39 assert-attribute: ("#help", {"class": "hidden"})
40 assert-attribute: ("#search", {"class": "content hidden"})
41 assert-attribute: ("#main-content", {"class": "content"})