pvollan@apple.com | 873685b | 2017-02-17 19:34:48 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <script src="../../resources/js-test-pre.js"></script> |
| 5 | </head> |
| 6 | <body> |
| 7 | <script> |
| 8 | description("This tests checks that all of the input values for stroke-width parse correctly."); |
| 9 | |
| 10 | function test(value) |
| 11 | { |
| 12 | var div = document.createElement("div"); |
| 13 | div.setAttribute("style", value); |
| 14 | document.body.appendChild(div); |
| 15 | |
| 16 | var result = div.style.getPropertyValue("stroke-width"); |
| 17 | |
| 18 | document.body.removeChild(div); |
| 19 | return result; |
| 20 | } |
| 21 | |
| 22 | function testComputedStyle(value) |
| 23 | { |
| 24 | var div = document.createElement("div"); |
| 25 | div.setAttribute("style", value); |
| 26 | document.body.appendChild(div); |
| 27 | |
| 28 | var result = window.getComputedStyle(div).strokeWidth; |
| 29 | document.body.removeChild(div); |
| 30 | return result; |
| 31 | } |
| 32 | |
| 33 | function testComputedStyleInherited(value) |
| 34 | { |
| 35 | var div = document.createElement("div"); |
| 36 | div.setAttribute("style", value); |
| 37 | |
| 38 | var div2 = document.createElement("div"); |
| 39 | div.appendChild(div2); |
| 40 | |
| 41 | document.body.appendChild(div); |
| 42 | |
| 43 | var result = window.getComputedStyle(div2).strokeWidth; |
| 44 | document.body.removeChild(div); |
| 45 | return result; |
| 46 | } |
| 47 | |
| 48 | shouldBe('testComputedStyleInherited("stroke-width: 4px;")', '"4px"'); |
| 49 | shouldBe('testComputedStyleInherited("stroke-width: 0.01em;")', '"0.01em"'); |
| 50 | shouldBe('testComputedStyleInherited("stroke-width: 10%;")', '"10%"'); |
| 51 | |
| 52 | shouldBe('testComputedStyle(";")', '"1px"'); |
| 53 | shouldBe('test("stroke-width: 4px;")', '"4px"'); |
| 54 | shouldBe('test("stroke-width: 0.01em;")', '"0.01em"'); |
| 55 | shouldBe('test("stroke-width: 10%;")', '"10%"'); |
| 56 | |
| 57 | shouldBeEqualToString('test("stroke-width: 4;")', '4px'); |
| 58 | shouldBeEqualToString('test("stroke-width: em;")', ''); |
| 59 | shouldBeEqualToString('test("stroke-width: %;")', ''); |
| 60 | </script> |
| 61 | <script src="../../resources/js-test-post.js"></script> |
| 62 | </body> |
| 63 | </html> |