aboutsummaryrefslogtreecommitdiffstats
path: root/test/runner/lib/getBrowserString.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/runner/lib/getBrowserString.js')
-rw-r--r--test/runner/lib/getBrowserString.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/runner/lib/getBrowserString.js b/test/runner/lib/getBrowserString.js
new file mode 100644
index 000000000..413a60500
--- /dev/null
+++ b/test/runner/lib/getBrowserString.js
@@ -0,0 +1,49 @@
+const browserMap = {
+ chrome: "Chrome",
+ edge: "Edge",
+ firefox: "Firefox",
+ ie: "IE",
+ jsdom: "JSDOM",
+ opera: "Opera",
+ safari: "Safari"
+};
+
+export function browserSupportsHeadless( browser ) {
+ browser = browser.toLowerCase();
+ return (
+ browser === "chrome" ||
+ browser === "firefox" ||
+ browser === "edge"
+ );
+}
+
+export function getBrowserString(
+ {
+ browser,
+ browser_version: browserVersion,
+ device,
+ os,
+ os_version: osVersion
+ },
+ headless
+) {
+ browser = browser.toLowerCase();
+ browser = browserMap[ browser ] || browser;
+ let str = browser;
+ if ( browserVersion ) {
+ str += ` ${ browserVersion }`;
+ }
+ if ( device ) {
+ str += ` for ${ device }`;
+ }
+ if ( os ) {
+ str += ` on ${ os }`;
+ }
+ if ( osVersion ) {
+ str += ` ${ osVersion }`;
+ }
+ if ( headless && browserSupportsHeadless( browser ) ) {
+ str += " (headless)";
+ }
+ return str;
+}