1 description('Test setting valid and invalid properties of HTMLMeterElement.');
3 var m = document.createElement('meter');
5 debug("Test values before properties were set");
6 shouldBe("m.min", "0");
7 shouldBe("m.value", "0");
8 shouldBe("m.max", "1");
9 shouldBe("m.low", "0");
10 shouldBe("m.high", "1");
11 shouldBe("m.optimum", "0.5");
13 debug("Set valid values");
20 shouldBe("m.min", "-10");
21 shouldBe("m.value", "70");
22 shouldBe("m.max", "100");
23 shouldBe("m.low", "10.1");
24 shouldBe("m.high", "99.5");
25 shouldBe("m.optimum", "70");
27 debug("Set attributes to improper values - 1");
34 shouldBe("m.min", "-10");
35 shouldBe("m.value", "100");
36 shouldBe("m.max", "100");
37 shouldBe("m.low", "100");
38 shouldBe("m.high", "100");
39 shouldBe("m.optimum", "0");
41 debug("Set attributes to improper values - 2");
46 shouldBe("m.min", "200.0");
47 shouldBe("m.value", "200.0");
48 shouldBe("m.max", "200.0");
49 shouldBe("m.low", "200.0");
51 debug("Set attributes to improper values - 3");
58 shouldBe("m.min", "100.0");
59 shouldBe("m.value", "100.0");
60 shouldBe("m.max", "100.0");
61 shouldBe("m.low", "100.0");
62 shouldBe("m.high", "100.0");
63 shouldBe("m.optimum", "100.0");
65 debug("Set attributes to improper values - 4");
72 shouldBe("m.min", "0.0");
73 shouldBe("m.value", "200.0");
74 shouldBe("m.max", "200.0");
75 shouldBe("m.low", "0.0");
76 shouldBe("m.high", "200.0");
77 shouldBe("m.optimum", "12.5");
79 debug("Set value to invalid value");
80 shouldThrow('m.value = "value";', '"NotSupportedError: Failed to set the \'value\' property on \'HTMLMeterElement\': The value provided is not a number."');
82 debug("Set min to NaN");
83 shouldThrow('m.min = NaN;', '"NotSupportedError: Failed to set the \'min\' property on \'HTMLMeterElement\': The value provided is not a number."');
85 debug("Set max to Infinity");
86 shouldThrow('m.max = Infinity;', '"NotSupportedError: Failed to set the \'max\' property on \'HTMLMeterElement\': The value provided is infinite."');
88 debug("Set low to invalid value");
89 shouldThrow('m.low = "low";', '"NotSupportedError: Failed to set the \'low\' property on \'HTMLMeterElement\': The value provided is not a number."');
91 debug("Set high to NaN");
92 shouldThrow('m.high = NaN;', '"NotSupportedError: Failed to set the \'high\' property on \'HTMLMeterElement\': The value provided is not a number."');
94 debug("Set optimum to Infinity");
95 shouldThrow('m.optimum = Infinity;', '"NotSupportedError: Failed to set the \'optimum\' property on \'HTMLMeterElement\': The value provided is infinite."');
97 debug("Set attributes to valid numbers");
98 m.setAttribute("min", 0);
99 m.setAttribute("value", 5);
100 m.setAttribute("max", 10);
101 shouldBe("m.value", "5");
102 shouldBe("m.max", "10");
103 shouldBe("parseInt(m.getAttribute('value'))", "5");
104 shouldBe("parseInt(m.getAttribute('max'))", "10");
106 debug("Set attributes to invalid values");
107 m.setAttribute("value", "ABC");
108 m.setAttribute("max", "#");
109 shouldBe("m.value", "0");
110 shouldBe("m.max", "1");
111 shouldBe("m.getAttribute('value')", "'ABC'");
112 shouldBe("m.getAttribute('max')", "'#'");
114 debug("Set attributes to numbers with leading spaces");
115 m.setAttribute("value", " 5");
116 m.setAttribute("min", " 5");
117 m.setAttribute("max", " 5");
118 m.setAttribute("low", " 5");
119 m.setAttribute("high", " 5");
120 m.setAttribute("optimum", " 5");
121 shouldBe("m.value", "0");
122 shouldBe("m.min", "0");
123 shouldBe("m.max", "1");
124 shouldBe("m.low", "0");
125 shouldBe("m.high", "1");
126 shouldBe("m.optimum", "0.5");