diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/shared/test/browser_theme_switching.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/shared/test/browser_theme_switching.js')
-rw-r--r-- | devtools/client/shared/test/browser_theme_switching.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/devtools/client/shared/test/browser_theme_switching.js b/devtools/client/shared/test/browser_theme_switching.js new file mode 100644 index 000000000..392462a67 --- /dev/null +++ b/devtools/client/shared/test/browser_theme_switching.js @@ -0,0 +1,53 @@ +/* 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"; + +add_task(function* () { + let target = TargetFactory.forTab(gBrowser.selectedTab); + let toolbox = yield gDevTools.showToolbox(target); + let doc = toolbox.doc; + let root = doc.documentElement; + + let platform = root.getAttribute("platform"); + let expectedPlatform = getPlatform(); + is(platform, expectedPlatform, ":root[platform] is correct"); + + let theme = Services.prefs.getCharPref("devtools.theme"); + let className = "theme-" + theme; + ok(root.classList.contains(className), + ":root has " + className + " class (current theme)"); + + // Convert the xpath result into an array of strings + // like `href="{URL}" type="text/css"` + let sheetsIterator = doc.evaluate("processing-instruction('xml-stylesheet')", + doc, null, XPathResult.ANY_TYPE, null); + let sheetsInDOM = []; + + /* eslint-disable no-cond-assign */ + let sheet; + while (sheet = sheetsIterator.iterateNext()) { + sheetsInDOM.push(sheet.data); + } + /* eslint-enable no-cond-assign */ + + let sheetsFromTheme = gDevTools.getThemeDefinition(theme).stylesheets; + info("Checking for existence of " + sheetsInDOM.length + " sheets"); + for (let themeSheet of sheetsFromTheme) { + ok(sheetsInDOM.some(s => s.includes(themeSheet)), + "There is a stylesheet for " + themeSheet); + } + + yield toolbox.destroy(); +}); + +function getPlatform() { + let {OS} = Services.appinfo; + if (OS == "WINNT") { + return "win"; + } else if (OS == "Darwin") { + return "mac"; + } + return "linux"; +} |