@@ -137,3 +137,76 @@ compare-elements-position-false: (
137137 "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
138138 ("y", "x"),
139139)
140+
141+ // Now check the colors.
142+ define-function: (
143+ "check-colors",
144+ (theme, header_color, content_color, type_color, trait_color),
145+ [
146+ ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"),
147+ // This is needed to ensure that the text color is computed.
148+ ("show-text", true),
149+
150+ // Setting the theme.
151+ ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
152+ // We reload the page so the local storage settings are being used.
153+ ("reload"),
154+
155+ ("move-cursor-to", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"),
156+ ("assert-count", (".notable-traits-tooltiptext", 1)),
157+
158+ ("assert-css", (
159+ ".notable-traits-tooltiptext h3.notable",
160+ {"color": |header_color|},
161+ ALL,
162+ )),
163+ ("assert-css", (
164+ ".notable-traits-tooltiptext pre.content",
165+ {"color": |content_color|},
166+ ALL,
167+ )),
168+ ("assert-css", (
169+ ".notable-traits-tooltiptext pre.content a.struct",
170+ {"color": |type_color|},
171+ ALL,
172+ )),
173+ ("assert-css", (
174+ ".notable-traits-tooltiptext pre.content a.trait",
175+ {"color": |trait_color|},
176+ ALL,
177+ )),
178+ ]
179+ )
180+
181+ call-function: (
182+ "check-colors",
183+ {
184+ "theme": "ayu",
185+ "content_color": "rgb(230, 225, 207)",
186+ "header_color": "rgb(255, 255, 255)",
187+ "type_color": "rgb(255, 160, 165)",
188+ "trait_color": "rgb(57, 175, 215)",
189+ },
190+ )
191+
192+ call-function: (
193+ "check-colors",
194+ {
195+ "theme": "dark",
196+ "content_color": "rgb(221, 221, 221)",
197+ "header_color": "rgb(221, 221, 221)",
198+ "type_color": "rgb(45, 191, 184)",
199+ "trait_color": "rgb(183, 140, 242)",
200+ },
201+ )
202+
203+ call-function: (
204+ "check-colors",
205+ {
206+ "theme": "light",
207+ "content_color": "rgb(0, 0, 0)",
208+ "header_color": "rgb(0, 0, 0)",
209+ "type_color": "rgb(173, 55, 138)",
210+ "trait_color": "rgb(110, 79, 201)",
211+ },
212+ )
0 commit comments