blob: 7fcfc9cc29e911b61f81d712289478c297a7e1cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
requestLongerTimeout(2);
// Test that the preview images are updated when the theme changes.
const { getTheme, setTheme } = require("devtools/client/shared/theme");
const TEST_URI = URL_ROOT + "browser_fontinspector.html";
const originalTheme = getTheme();
registerCleanupFunction(() => {
info(`Restoring theme to '${originalTheme}.`);
setTheme(originalTheme);
});
add_task(function* () {
let { inspector, view } = yield openFontInspectorForURL(TEST_URI);
let { chromeDoc: doc } = view;
yield selectNode(".normal-text", inspector);
// Store the original preview URI for later comparison.
let originalURI = doc.querySelector("#all-fonts .font-preview").src;
let newTheme = originalTheme === "light" ? "dark" : "light";
info(`Original theme was '${originalTheme}'.`);
yield setThemeAndWaitForUpdate(newTheme, inspector);
isnot(doc.querySelector("#all-fonts .font-preview").src, originalURI,
"The preview image changed with the theme.");
yield setThemeAndWaitForUpdate(originalTheme, inspector);
is(doc.querySelector("#all-fonts .font-preview").src, originalURI,
"The preview image is correct after the original theme was restored.");
});
/**
* Sets the current theme and waits for fontinspector-updated event.
*
* @param {String} theme - the new theme
* @param {Object} inspector - the inspector panel
*/
function* setThemeAndWaitForUpdate(theme, inspector) {
let onUpdated = inspector.once("fontinspector-updated");
info(`Setting theme to '${theme}'.`);
setTheme(theme);
info("Waiting for font-inspector to update.");
yield onUpdated;
}
|