summaryrefslogtreecommitdiffstats
path: root/dom/manifest/test/test_ManifestProcessor_theme_color.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/manifest/test/test_ManifestProcessor_theme_color.html')
-rw-r--r--dom/manifest/test/test_ManifestProcessor_theme_color.html118
1 files changed, 118 insertions, 0 deletions
diff --git a/dom/manifest/test/test_ManifestProcessor_theme_color.html b/dom/manifest/test/test_ManifestProcessor_theme_color.html
new file mode 100644
index 000000000..c08830025
--- /dev/null
+++ b/dom/manifest/test/test_ManifestProcessor_theme_color.html
@@ -0,0 +1,118 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1195018
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1195018</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script src="common.js"></script>
+ <script>
+/**
+ * theme_color member
+ * https://w3c.github.io/manifest/#theme_color-member
+ **/
+'use strict';
+
+typeTests.forEach(type => {
+ data.jsonText = JSON.stringify({
+ theme_color: type
+ });
+ var result = processor.process(data);
+
+ is(result.theme_color, undefined, `Expect non-string theme_color to be undefined: ${typeof type}.`);
+});
+
+var validThemeColors = [
+ 'maroon',
+ '#f00',
+ '#ff0000',
+ 'rgb(255,0,0)',
+ 'rgb(255,0,0,1)',
+ 'rgb(255,0,0,1.0)',
+ 'rgb(255,0,0,100%)',
+ 'rgb(255 0 0)',
+ 'rgb(255 0 0 / 1)',
+ 'rgb(255 0 0 / 1.0)',
+ 'rgb(255 0 0 / 100%)',
+ 'rgb(100%, 0%, 0%)',
+ 'rgb(100%, 0%, 0%, 1)',
+ 'rgb(100%, 0%, 0%, 1.0)',
+ 'rgb(100%, 0%, 0%, 100%)',
+ 'rgb(100% 0% 0%)',
+ 'rgb(100% 0% 0% / 1)',
+ 'rgb(100%, 0%, 0%, 1.0)',
+ 'rgb(100%, 0%, 0%, 100%)',
+ 'rgb(300,0,0)',
+ 'rgb(300 0 0)',
+ 'rgb(255,-10,0)',
+ 'rgb(110%, 0%, 0%)',
+ 'rgba(255,0,0)',
+ 'rgba(255,0,0,1)',
+ 'rgba(255 0 0 / 1)',
+ 'rgba(100%,0%,0%,1)',
+ 'rgba(0,0,255,0.5)',
+ 'rgba(100%, 50%, 0%, 0.1)',
+ 'hsl(120, 100%, 50%)',
+ 'hsl(120 100% 50%)',
+ 'hsl(120, 100%, 50%, 1.0)',
+ 'hsl(120 100% 50% / 1.0)',
+ 'hsla(120, 100%, 50%)',
+ 'hsla(120 100% 50%)',
+ 'hsla(120, 100%, 50%, 1.0)',
+ 'hsla(120 100% 50% / 1.0)',
+ 'hsl(120deg, 100%, 50%)',
+ 'hsl(133.33333333grad, 100%, 50%)',
+ 'hsl(2.0943951024rad, 100%, 50%)',
+ 'hsl(0.3333333333turn, 100%, 50%)',
+];
+
+validThemeColors.forEach(theme_color => {
+ data.jsonText = JSON.stringify({
+ theme_color: theme_color
+ });
+ var result = processor.process(data);
+
+ is(result.theme_color, theme_color, `Expect theme_color to be returned: ${theme_color}.`);
+});
+
+var invalidThemeColors = [
+ 'marooon',
+ 'f000000',
+ '#ff00000',
+ 'rgb(100, 0%, 0%)',
+ 'rgb(255,0)',
+ 'rbg(255,-10,0)',
+ 'rgb(110, 0%, 0%)',
+ '(255,0,0) }',
+ 'rgba(255)',
+ ' rgb(100%,0%,0%) }',
+ 'hsl(120, 100%, 50)',
+ 'hsl(120, 100%, 50.0)',
+ 'hsl 120, 100%, 50%',
+ 'hsla{120, 100%, 50%, 1}',
+]
+
+invalidThemeColors.forEach(theme_color => {
+ data.jsonText = JSON.stringify({
+ theme_color: theme_color
+ });
+ var result = processor.process(data);
+
+ is(result.theme_color, undefined, `Expect theme_color to be undefined: ${theme_color}.`);
+});
+
+// Trim tests
+validThemeColors.forEach(theme_color => {
+ var expandedThemeColor = `${seperators}${lineTerminators}${theme_color}${lineTerminators}${seperators}`;
+ data.jsonText = JSON.stringify({
+ theme_color: expandedThemeColor
+ });
+ var result = processor.process(data);
+
+ is(result.theme_color, theme_color, `Expect trimmed theme_color to be returned.`);
+});
+ </script>
+</head>