| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script src="script-tests/set-progress-properties.js"></script> | 7 <script> |
| 8 description('Test setting valid and invalid properties of HTMLProgressElement.')
; |
| 9 |
| 10 var p = document.createElement('progress'); |
| 11 |
| 12 debug("Test values before properties were set"); |
| 13 shouldBe("p.value", "0"); |
| 14 shouldBe("p.max", "1"); |
| 15 shouldBe("p.position", "-1"); |
| 16 |
| 17 debug("Set valid values"); |
| 18 p.value = 7e1; |
| 19 p.max = "1e2"; |
| 20 shouldBe("p.value", "70"); |
| 21 shouldBe("p.max", "100"); |
| 22 shouldBe("p.position", "0.7"); |
| 23 |
| 24 debug("Set value bigger than max"); |
| 25 p.value = 200; |
| 26 p.max = 100.0; |
| 27 shouldBe("p.value", "100"); |
| 28 shouldBe("p.max", "100"); |
| 29 shouldBe("p.position", "1"); |
| 30 |
| 31 debug("Set value less than zero"); |
| 32 p.value = -42; |
| 33 shouldBe('p.value', '0'); |
| 34 shouldBe('p.position', '0'); |
| 35 |
| 36 debug("Set invalid value, should throw"); |
| 37 shouldThrow('p.value = "200A";'); |
| 38 |
| 39 debug("Set invalid max, should throw"); |
| 40 shouldThrow('p.max = "max";'); |
| 41 |
| 42 debug("Set max to Infinity, should throw"); |
| 43 shouldThrow('p.max = Infinity;'); |
| 44 |
| 45 debug("Set value to NaN, should throw"); |
| 46 shouldThrow('p.value = NaN;'); |
| 47 |
| 48 debug("Set value to null and max to 0"); |
| 49 p.value = null; |
| 50 p.max = 0; |
| 51 shouldBe("p.value", "0"); |
| 52 shouldBe("p.max", "1"); |
| 53 shouldBe("p.position", "0"); |
| 54 |
| 55 debug("Set attributes to valid numbers"); |
| 56 p.setAttribute("value", 5); |
| 57 p.setAttribute("max", 10); |
| 58 shouldBe("p.value", "5"); |
| 59 shouldBe("p.max", "10"); |
| 60 shouldBe("parseInt(p.getAttribute('value'))", "5"); |
| 61 shouldBe("parseInt(p.getAttribute('max'))", "10"); |
| 62 |
| 63 debug("Set attributes to invalid values"); |
| 64 p.setAttribute("value", "ABC"); |
| 65 p.setAttribute("max", "#"); |
| 66 shouldBe("p.value", "0"); |
| 67 shouldBe("p.max", "1"); |
| 68 shouldBe("p.getAttribute('value')", "'ABC'"); |
| 69 shouldBe("p.getAttribute('max')", "'#'"); |
| 70 |
| 71 debug("Set value and max to numbers with leading spaces"); |
| 72 p.setAttribute("value", " 5"); |
| 73 p.setAttribute("max", " 10"); |
| 74 shouldBe("p.value", "0"); |
| 75 shouldBe("p.max", "1"); |
| 76 shouldBe("p.position", "0"); |
| 77 </script> |
| 8 </body> | 78 </body> |
| 9 </html> | 79 </html> |
| OLD | NEW |