mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-27 21:48:49 +00:00
38bd296c8c
- Bug 1145306 - Expose circular buffer status from profiler. r=mstange (8b24a7439) - Bug 1145824 - Add getElapsedTime to nsIProfiler. (r=mstange) (9bbd99f66) - Bug 1145824 - In nsProfiler, allow GetProfile and getProfileData to filter by a start time. (r=mstange) (43bdcb254) - Bug 1141712 - Make LUL work with inplace ticking (not using the unwinder thread). r=mstange. (ed43cdf70) - Bug 1151679 - Stream the property name of getprop and setprop optimization sites. (r=djvj) (3eb8efeb4) - Bug 1142181 - ProfilerBacktrace.cpp should #include its own .h file first, r=aklotz (c1aff9f49) - Bug 1154115 - Rewrite profiler JSON streaming. (r=mstange) (834891a91) - Bug 1157906 - Can't return arrays as a root response, fixes inspect button. r=bgrins (d66407512) - Bug 1160361 - Abort tilt commands when remote. r=bgrins (5bcfbc8d0) - Bug 947242 - DevTools themes - switch to new theme colors;r=jsantell (5ed17dcdc)
82 lines
3.3 KiB
JavaScript
82 lines
3.3 KiB
JavaScript
/* vim: set ts=2 et sw=2 tw=80: */
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
// Tests that theme utilities work
|
|
|
|
let {getColor, getTheme, setTheme} = devtools.require("devtools/shared/theme");
|
|
|
|
function test() {
|
|
testGetTheme();
|
|
testSetTheme();
|
|
testGetColor();
|
|
testColorExistence();
|
|
}
|
|
|
|
function testGetTheme () {
|
|
let originalTheme = getTheme();
|
|
ok(originalTheme, "has some theme to start with.");
|
|
Services.prefs.setCharPref("devtools.theme", "light");
|
|
is(getTheme(), "light", "getTheme() correctly returns light theme");
|
|
Services.prefs.setCharPref("devtools.theme", "dark");
|
|
is(getTheme(), "dark", "getTheme() correctly returns dark theme");
|
|
Services.prefs.setCharPref("devtools.theme", "unknown");
|
|
is(getTheme(), "unknown", "getTheme() correctly returns an unknown theme");
|
|
Services.prefs.setCharPref("devtools.theme", originalTheme);
|
|
}
|
|
|
|
function testSetTheme () {
|
|
let originalTheme = getTheme();
|
|
setTheme("dark");
|
|
is(Services.prefs.getCharPref("devtools.theme"), "dark", "setTheme() correctly sets dark theme.");
|
|
setTheme("light");
|
|
is(Services.prefs.getCharPref("devtools.theme"), "light", "setTheme() correctly sets light theme.");
|
|
setTheme("unknown");
|
|
is(Services.prefs.getCharPref("devtools.theme"), "unknown", "setTheme() correctly sets an unknown theme.");
|
|
Services.prefs.setCharPref("devtools.theme", originalTheme);
|
|
}
|
|
|
|
function testGetColor () {
|
|
let BLUE_DARK = "#46afe3";
|
|
let BLUE_LIGHT = "#0088cc";
|
|
let originalTheme = getTheme();
|
|
|
|
setTheme("dark");
|
|
is(getColor("highlight-blue"), BLUE_DARK, "correctly gets color for enabled theme.");
|
|
setTheme("light");
|
|
is(getColor("highlight-blue"), BLUE_LIGHT, "correctly gets color for enabled theme.");
|
|
setTheme("metal");
|
|
is(getColor("highlight-blue"), BLUE_LIGHT, "correctly uses light for default theme if enabled theme not found");
|
|
|
|
is(getColor("highlight-blue", "dark"), BLUE_DARK, "if provided and found, uses the provided theme.");
|
|
is(getColor("highlight-blue", "metal"), BLUE_LIGHT, "if provided and not found, defaults to light theme.");
|
|
is(getColor("somecomponents"), null, "if a type cannot be found, should return null.");
|
|
|
|
setTheme(originalTheme);
|
|
}
|
|
|
|
function testColorExistence () {
|
|
var vars = ["body-background", "sidebar-background", "contrast-background", "tab-toolbar-background",
|
|
"toolbar-background", "selection-background", "selection-color",
|
|
"selection-background-semitransparent", "splitter-color", "comment", "body-color",
|
|
"body-color-alt", "content-color1", "content-color2", "content-color3",
|
|
"highlight-green", "highlight-blue", "highlight-bluegrey", "highlight-purple",
|
|
"highlight-lightorange", "highlight-orange", "highlight-red", "highlight-pink"
|
|
];
|
|
|
|
for (let type of vars) {
|
|
ok(getColor(type, "light"), `${type} is a valid color in light theme`);
|
|
ok(getColor(type, "dark"), `${type} is a valid color in light theme`);
|
|
}
|
|
}
|
|
|
|
function isColor (s) {
|
|
// Regexes from Heather Arthur's `color-string`
|
|
// https://github.com/harthur/color-string
|
|
// MIT License
|
|
return /^#([a-fA-F0-9]{3})$/.test(s) ||
|
|
/^#([a-fA-F0-9]{6})$/.test(s) ||
|
|
/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d\.]+)\s*)?\)$/.test(s) ||
|
|
/^rgba?\(\s*([\d\.]+)\%\s*,\s*([\d\.]+)\%\s*,\s*([\d\.]+)\%\s*(?:,\s*([\d\.]+)\s*)?\)$/.test(s);
|
|
}
|