| OLD | NEW |
| (Empty) |
| 1 description('Test setting valid and invalid properties of HTMLMeterElement.'); | |
| 2 | |
| 3 var m = document.createElement('meter'); | |
| 4 | |
| 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"); | |
| 12 | |
| 13 debug("Set valid values"); | |
| 14 m.min = "-10"; | |
| 15 m.value = 7e1; | |
| 16 m.max = "1e2"; | |
| 17 m.low = "10.1"; | |
| 18 m.high = "99.5"; | |
| 19 m.optimum = "70"; | |
| 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"); | |
| 26 | |
| 27 debug("Set attributes to improper values - 1"); | |
| 28 m.min = -10; | |
| 29 m.value = 200; | |
| 30 m.max = 100.0; | |
| 31 m.low = 200; | |
| 32 m.high = -50; | |
| 33 m.optimum = null; | |
| 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"); | |
| 40 | |
| 41 debug("Set attributes to improper values - 2"); | |
| 42 m.min = 200.0; | |
| 43 m.value = -200.0; | |
| 44 m.max = 0; | |
| 45 m.low = null; | |
| 46 shouldBe("m.min", "200.0"); | |
| 47 shouldBe("m.value", "200.0"); | |
| 48 shouldBe("m.max", "200.0"); | |
| 49 shouldBe("m.low", "200.0"); | |
| 50 | |
| 51 debug("Set attributes to improper values - 3"); | |
| 52 m.min = 100.0; | |
| 53 m.value = 200.0; | |
| 54 m.max = 50; | |
| 55 m.low = 10; | |
| 56 m.high = 15e1; | |
| 57 m.optimum = 12.5; | |
| 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"); | |
| 64 | |
| 65 debug("Set attributes to improper values - 4"); | |
| 66 m.min = 0.0; | |
| 67 m.value = 250.0; | |
| 68 m.max = 200; | |
| 69 m.low = -10; | |
| 70 m.high = 15e2; | |
| 71 m.optimum = 12.5; | |
| 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"); | |
| 78 | |
| 79 debug("Set value to invalid value"); | |
| 80 shouldThrow('m.value = "value";'); | |
| 81 | |
| 82 debug("Set min to NaN"); | |
| 83 shouldThrow('m.min = NaN;'); | |
| 84 | |
| 85 debug("Set max to Infinity"); | |
| 86 shouldThrow('m.max = Infinity;'); | |
| 87 | |
| 88 debug("Set low to invalid value"); | |
| 89 shouldThrow('m.low = "low";'); | |
| 90 | |
| 91 debug("Set high to NaN"); | |
| 92 shouldThrow('m.high = NaN;'); | |
| 93 | |
| 94 debug("Set optimum to Infinity"); | |
| 95 shouldThrow('m.optimum = Infinity;'); | |
| 96 | |
| 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"); | |
| 105 | |
| 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')", "'#'"); | |
| 113 | |
| 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"); | |
| 127 | |
| OLD | NEW |