1 <html>
2 <head>
3 <script src="../../../../resources/js-test-pre.js"></script>
4 </head>
5 <body>
6 <p id="description"></p>
7 <div id="console"></div>
8 <script>
9
10 description("This tests the parser and serializer for dashboard region values.");
11
12 var style = document.getElementById('description').style;
13
14 function parseDashboardRegion(string)
15 {
16 try {
17 style.removeProperty("-webkit-dashboard-region");
18 style.setProperty("-webkit-dashboard-region", string, "");
19 var result = style.getPropertyValue("-webkit-dashboard-region");
20 style.removeProperty("-webkit-dashboard-region");
21 return result;
22 } catch (e) {
23 return "" + e;
24 }
25 }
26
27 function testCanonicalDashboardRegion(string)
28 {
29 shouldBe("parseDashboardRegion('" + string + "')", "'" + string + "'");
30 }
31
32 testCanonicalDashboardRegion('none');
33
34 debug('');
35
36 testCanonicalDashboardRegion('dashboard-region(label circle)');
37 testCanonicalDashboardRegion('dashboard-region(label circle 1px 2px 3px 4px)');
38 testCanonicalDashboardRegion('dashboard-region(label circle 0px 0px 0px 0px)');
39 testCanonicalDashboardRegion('dashboard-region(label circle auto auto auto auto)');
40 testCanonicalDashboardRegion('dashboard-region(label circle 1px 2px 3px 4px)');
41
42 debug('');
43
44 testCanonicalDashboardRegion('dashboard-region(label rectangle)');
45 testCanonicalDashboardRegion('dashboard-region(label rectangle 1px 2px 3px 4px)');
46
47 debug('');
48
49 testCanonicalDashboardRegion('dashboard-region(label circle) dashboard-region(label circle)');
50 testCanonicalDashboardRegion('dashboard-region(label circle) dashboard-region(label rectangle)');
51 testCanonicalDashboardRegion('dashboard-region(label circle 1px 2px 3px 4px) dashboard-region(label rectangle 5px 6px 7px 8px)');
52 testCanonicalDashboardRegion('dashboard-region(label rectangle 1px 2px 3px 4px) dashboard-region(label circle 5px 6px 7px 8px)');
53
54 debug('');
55 debug('Tests to demonstrate that commas are allowed.');
56 debug('');
57
58 shouldBe("parseDashboardRegion('dashboard-region(label, circle)')", "'dashboard-region(label circle)'");
59 shouldBe("parseDashboardRegion('dashboard-region(label, circle, 1px, 2px, 3px, 4px)')", "'dashboard-region(label circle 1px 2px 3px 4px)'");
60
61 debug('');
62 debug('Tests for variations in whitespace that are allowed.');
63 debug('');
64
65 shouldBe("parseDashboardRegion(' dashboard-region( label circle ) ')", "'dashboard-region(label circle)'");
66 shouldBe("parseDashboardRegion(' dashboard-region( label circle 1px 2px 3px 4px ) dashboard-region(label rectangle 5px 6px 7px 8px ) ')", "'dashboard-region(label circle 1px 2px 3px 4px) dashboard-region(label rectangle 5px 6px 7px 8px)'");
67 shouldBe("parseDashboardRegion('dashboard-region(label circle 1px 2px 3px 4px)dashboard-region(label rectangle 5px 6px 7px 8px)')", "'dashboard-region(label circle 1px 2px 3px 4px) dashboard-region(label rectangle 5px 6px 7px 8px)'");
68
69 debug('');
70 debug('Tests for case insensitivity.');
71 debug('');
72
73 shouldBe("parseDashboardRegion('Dashboard-region(label Circle)')", "'dashboard-region(label circle)'");
74 shouldBe("parseDashboardRegion('DASHBOARD-REGION(LABEL CIRCLE)')", "'dashboard-region(LABEL circle)'");
75 shouldBe("parseDashboardRegion('DaShBoArD-ReGiOn(LaBeL CiRcLe)')", "'dashboard-region(LaBeL circle)'");
76 shouldBe("parseDashboardRegion('dAsHbOaRd-rEgIoN(lAbEl cIrClE)')", "'dashboard-region(lAbEl circle)'");
77 shouldBe("parseDashboardRegion('Dashboard-region(label Rectangle)')", "'dashboard-region(label rectangle)'");
78 shouldBe("parseDashboardRegion('DASHBOARD-REGION(LABEL RECTANGLE)')", "'dashboard-region(LABEL rectangle)'");
79 shouldBe("parseDashboardRegion('DaShBoArD-ReGiOn(LaBeL ReCtAnGlE)')", "'dashboard-region(LaBeL rectangle)'");
80 shouldBe("parseDashboardRegion('dAsHbOaRd-rEgIoN(lAbEl rEcTaNgLe)')", "'dashboard-region(lAbEl rectangle)'");
81
82 debug('');
83 debug('Some expected failures.');
84 debug('');
85
86 shouldBe("parseDashboardRegion('')", "''");
87 shouldBe("parseDashboardRegion(' ')", "''");
88 shouldBe("parseDashboardRegion('x')", "''");
89 shouldBe("parseDashboardRegion('dashboard-')", "''");
90 shouldBe("parseDashboardRegion('dashboard-region')", "''");
91 shouldBe("parseDashboardRegion('dashboard-region(')", "''");
92 shouldBe("parseDashboardRegion('dashboard-region(label')", "''");
93 shouldBe("parseDashboardRegion('dashboard-region(label ')", "''");
94 shouldBe("parseDashboardRegion('dashboard-region(label c')", "''");
95 shouldBe("parseDashboardRegion('dashboard-region(label circle')", "''");
96 shouldBe("parseDashboardRegion('dashboard-region(label)')", "''");
97 shouldBe("parseDashboardRegion('dashboard-region (label circle)')", "''");
98 shouldBe("parseDashboardRegion('dashboard-region(label,, circle)')", "''");
99 shouldBe("parseDashboardRegion('dashboard-region(label circle 1px2px 3px 4px)')", "''");
100 shouldBe("parseDashboardRegion('dashboard-region(label,, circle, 1px, 2px, 3px, 4px)')", "''");
101 shouldBe("parseDashboardRegion('dashboard-region(label, circle 1px 2px 3px 4px)')", "''");
102 shouldBe("parseDashboardRegion('dashboard-region(label, circle, 1px 2px 3px 4px)')", "''");
103 shouldBe("parseDashboardRegion('dashboard-region(label, circle, 1px, 2px 3px 4px)')", "''");
104 shouldBe("parseDashboardRegion('dashboard-region(label, circle, 1px, 2px, 3px 4px)')", "''");
105 shouldBe("parseDashboardRegion('dashboard-region(label circle, 1px, 2px, 3px, 4px)')", "''");
106 shouldBe("parseDashboardRegion('dashboard-region(label circle 1px, 2px, 3px, 4px)')", "''");
107 shouldBe("parseDashboardRegion('dashboard-region(label circle x)')", "''");
108 shouldBe("parseDashboardRegion('dashboard-region(label circle x x)')", "''");
109 shouldBe("parseDashboardRegion('dashboard-region(label circle x x x)')", "''");
110 shouldBe("parseDashboardRegion('dashboard-region(label circle x x x x)')", "''");
111 shouldBe("parseDashboardRegion('dashboard-region(label circle x x x x x)')", "''");
112 shouldBe("parseDashboardRegion('dashboard-region(label circle 1px 2px 3px 4px x)')", "''");
113 shouldBe("parseDashboardRegion('dashboard-region(label circle 1px 2px 3px 4px x x)')", "''");
114 shouldBe("parseDashboardRegion('dashboard-region(label circle 1px 2px 3px 4px x x x)')", "''");
115 shouldBe("parseDashboardRegion('dashboard-region(label circle 1px 2px 3px 4px x x x x)')", "''");
116 shouldBe("parseDashboardRegion('dashboard-region(label circle 1px 2px 3px 4px x x x x x)')", "''");
117 shouldBe("parseDashboardRegion('dashboard-region(label circle 1px 2px 3px 4px circle 5px 6px 7px 8px)')", "''");
118 shouldBe("parseDashboardRegion('dashboard-region(label, circle, 1px, 2px, 3px, 4px, circle, 5px, 6px, 7px, 8px)')", "''");
119 shouldBe("parseDashboardRegion('none x')", "''");
120 shouldBe("parseDashboardRegion('none x x')", "''");
121 shouldBe("parseDashboardRegion('none x x x')", "''");
122 shouldBe("parseDashboardRegion('none x x x x')", "''");
123 shouldBe("parseDashboardRegion('none dashboard-region(label, circle)')", "''");
124 shouldBe("parseDashboardRegion('dashboard-region(label, circle) none')", "''");
125
126 debug('');
127
128
129 </script>
130 <script src="../../../../resources/js-test-post.js"></script>
131 </body>
132 </html>