|
2 | 2 | goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
3 | 3 | local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"}
|
4 | 4 | reload:
|
| 5 | + |
| 6 | +store-value: (background_light, "rgb(255, 255, 255)") |
| 7 | +store-value: (background_dark, "rgb(53, 53, 53)") |
| 8 | +store-value: (background_ayu, "rgb(15, 20, 25)") |
| 9 | + |
5 | 10 | click: "#settings-menu"
|
6 | 11 | wait-for: "#theme-ayu"
|
7 | 12 | click: "#theme-ayu"
|
8 | 13 | // should be the ayu theme so let's check the color.
|
9 |
| -wait-for-css: ("body", { "background-color": "rgb(15, 20, 25)" }) |
| 14 | +wait-for-css: ("body", { "background-color": |background_ayu| }) |
10 | 15 | assert-local-storage: { "rustdoc-theme": "ayu" }
|
11 | 16 | click: "#theme-light"
|
12 | 17 | // should be the light theme so let's check the color.
|
13 |
| -wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" }) |
| 18 | +wait-for-css: ("body", { "background-color": |background_light| }) |
14 | 19 | assert-local-storage: { "rustdoc-theme": "light" }
|
15 | 20 | click: "#theme-dark"
|
16 | 21 | // Should be the dark theme so let's check the color.
|
17 |
| -wait-for-css: ("body", { "background-color": "rgb(53, 53, 53)" }) |
| 22 | +wait-for-css: ("body", { "background-color": |background_dark| }) |
18 | 23 | assert-local-storage: { "rustdoc-theme": "dark" }
|
19 | 24 |
|
| 25 | +local-storage: { |
| 26 | + "rustdoc-preferred-light-theme": "light", |
| 27 | + "rustdoc-preferred-dark-theme": "light", |
| 28 | +} |
20 | 29 | goto: "file://" + |DOC_PATH| + "/settings.html"
|
| 30 | + |
21 | 31 | wait-for: "#settings"
|
22 | 32 | click: "#theme-light"
|
23 |
| -wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" }) |
| 33 | +wait-for-css: ("body", { "background-color": |background_light| }) |
24 | 34 | assert-local-storage: { "rustdoc-theme": "light" }
|
25 | 35 |
|
26 | 36 | click: "#theme-dark"
|
27 |
| -wait-for-css: ("body", { "background-color": "rgb(53, 53, 53)" }) |
| 37 | +wait-for-css: ("body", { "background-color": |background_dark| }) |
28 | 38 | assert-local-storage: { "rustdoc-theme": "dark" }
|
29 | 39 |
|
30 | 40 | click: "#theme-ayu"
|
31 |
| -wait-for-css: ("body", { "background-color": "rgb(15, 20, 25)" }) |
| 41 | +wait-for-css: ("body", { "background-color": |background_ayu| }) |
32 | 42 | assert-local-storage: { "rustdoc-theme": "ayu" }
|
| 43 | + |
| 44 | +assert-local-storage-false: { "rustdoc-use-system-theme": "true" } |
| 45 | +click: "#theme-system-preference" |
| 46 | +wait-for: ".setting-line:not(.hidden) #preferred-light-theme" |
| 47 | +assert-local-storage: { "rustdoc-use-system-theme": "true" } |
| 48 | +// We click on both preferred light and dark themes to be sure that there is a change. |
| 49 | +click: "#preferred-light-theme-dark" |
| 50 | +click: "#preferred-dark-theme-dark" |
| 51 | +wait-for-css: ("body", { "background-color": |background_dark| }) |
| 52 | + |
| 53 | +reload: |
| 54 | +// Ensure that the "preferred themes" are still displayed. |
| 55 | +wait-for: ".setting-line:not(.hidden) #preferred-light-theme" |
| 56 | +click: "#theme-light" |
| 57 | +wait-for-css: ("body", { "background-color": |background_light| }) |
| 58 | +assert-local-storage: { "rustdoc-theme": "light" } |
| 59 | +// Ensure it's now hidden again |
| 60 | +wait-for: ".setting-line.hidden #preferred-light-theme" |
| 61 | +// And ensure the theme was rightly set. |
| 62 | +wait-for-css: ("body", { "background-color": |background_light| }) |
| 63 | +assert-local-storage: { "rustdoc-theme": "light" } |
| 64 | + |
| 65 | +reload: |
| 66 | +wait-for: "#settings" |
| 67 | +assert: ".setting-line.hidden #preferred-light-theme" |
0 commit comments