1 description('Test setting valid and invalid properties of HTMLProgressElement.');
3 var p
= document
.createElement('progress');
5 debug("Test values before properties were set");
6 shouldBe("p.value", "0");
7 shouldBe("p.max", "1");
8 shouldBe("p.position", "-1");
10 debug("Set valid values");
13 shouldBe("p.value", "70");
14 shouldBe("p.max", "100");
15 shouldBe("p.position", "0.7");
17 debug("Set value bigger than max");
20 shouldBe("p.value", "100");
21 shouldBe("p.max", "100");
22 shouldBe("p.position", "1");
24 debug("Set value less than zero");
26 shouldBe('p.value', '0');
27 shouldBe('p.position', '0');
29 debug("Set invalid value, should throw");
30 shouldThrow('p.value = "200A";');
32 debug("Set invalid max, should throw");
33 shouldThrow('p.max = "max";');
35 debug("Set max to Infinity, should throw");
36 shouldThrow('p.max = Infinity;');
38 debug("Set value to NaN, should throw");
39 shouldThrow('p.value = NaN;');
41 debug("Set value to null and max to 0");
44 shouldBe("p.value", "0");
45 shouldBe("p.max", "1");
46 shouldBe("p.position", "0");
48 debug("Set attributes to valid numbers");
49 p
.setAttribute("value", 5);
50 p
.setAttribute("max", 10);
51 shouldBe("p.value", "5");
52 shouldBe("p.max", "10");
53 shouldBe("parseInt(p.getAttribute('value'))", "5");
54 shouldBe("parseInt(p.getAttribute('max'))", "10");
56 debug("Set attributes to invalid values");
57 p
.setAttribute("value", "ABC");
58 p
.setAttribute("max", "#");
59 shouldBe("p.value", "0");
60 shouldBe("p.max", "1");
61 shouldBe("p.getAttribute('value')", "'ABC'");
62 shouldBe("p.getAttribute('max')", "'#'");
64 debug("Set value and max to numbers with leading spaces");
65 p
.setAttribute("value", " 5");
66 p
.setAttribute("max", " 10");
67 shouldBe("p.value", "0");
68 shouldBe("p.max", "1");
69 shouldBe("p.position", "0");