]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/escape-key.goml
Rollup merge of #102445 - jmillikin:cstr-is-empty, r=Mark-Simulacrum
[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 // To be SURE that the search will be run.
7 press-key: 'Enter'
8 wait-for: "#search h1" // The search element is empty before the first search 
9 // Check that the currently displayed element is search.
10 wait-for: "#alternative-display #search"
11 assert-attribute: ("#main-content", {"class": "content hidden"})
12 assert-document-property: ({"URL": "index.html?search=test"}, ENDS_WITH)
13 press-key: "Escape"
14 // Checks that search is no longer in the displayed content.
15 wait-for: "#not-displayed #search"
16 assert-false: "#alternative-display #search"
17 assert-attribute: ("#main-content", {"class": "content"})
18 assert-document-property: ({"URL": "index.html"}, [ENDS_WITH])
19
20 // Check that focusing the search input brings back the search results
21 focus: ".search-input"
22 wait-for: "#alternative-display #search"
23 assert-attribute: ("#main-content", {"class": "content hidden"})
24 assert-document-property: ({"URL": "index.html?search=test"}, ENDS_WITH)
25
26 // Check that Escape hides the search results when a search result is focused.
27 focus: ".search-input"
28 assert: ".search-input:focus"
29 press-key: "ArrowDown"
30 assert-false: ".search-input:focus"
31 assert: "#results a:focus"
32 press-key: "Escape"
33 wait-for: "#not-displayed #search"
34 assert-false: "#alternative-display #search"
35 assert-attribute: ("#main-content", {"class": "content"})