OLD | NEW |
---|---|
1 description( | |
2 "This tests the HTMLImageElement border property." | |
3 ); | |
4 | 1 |
5 function imageBorderWidth(borderValue, style) | 2 function imageBorderWidth(borderValue, style) |
6 { | 3 { |
Srirama
2016/08/10 14:18:03
nit: move the brace to previous line for consisten
sivag
2016/08/10 14:37:11
Done.
| |
7 var image = document.createElement("img"); | 4 var image = document.createElement("img"); |
8 if (borderValue !== undefined) | 5 if (borderValue !== undefined) |
9 image.setAttribute("border", borderValue); | 6 image.setAttribute("border", borderValue); |
10 image.setAttribute("style", style); | 7 image.setAttribute("style", style); |
11 image.setAttribute("width", "0"); | 8 image.setAttribute("width", "0"); |
12 document.body.appendChild(image); | 9 document.body.appendChild(image); |
13 var borderBoxWidth = image.offsetWidth; | 10 var borderBoxWidth = image.offsetWidth; |
14 document.body.removeChild(image); | 11 document.body.removeChild(image); |
15 return borderBoxWidth / 2; | 12 return borderBoxWidth / 2; |
16 } | 13 } |
17 | 14 |
18 shouldBe("imageBorderWidth()", "0"); | 15 test(function() { |
19 shouldBe("imageBorderWidth(null)", "0"); | 16 assert_equals(imageBorderWidth(), 0); |
20 shouldBe("imageBorderWidth('')", "0"); | 17 assert_equals(imageBorderWidth(null), 0); |
21 shouldBe("imageBorderWidth(0)", "0"); | 18 assert_equals(imageBorderWidth(''), 0); |
22 shouldBe("imageBorderWidth('x')", "0"); | 19 assert_equals(imageBorderWidth(0), 0); |
23 shouldBe("imageBorderWidth(undefined, 'border-width: 20px')", "0"); | 20 assert_equals(imageBorderWidth('x'), 0); |
21 assert_equals(imageBorderWidth(undefined, 'border-width: 20px'), 0); | |
24 | 22 |
25 shouldBe("imageBorderWidth(null, 'border-width: 20px')", "20"); | 23 assert_equals(imageBorderWidth(null, 'border-width: 20px'), 20); |
26 shouldBe("imageBorderWidth('', 'border-width: 20px')", "20"); | 24 assert_equals(imageBorderWidth('', 'border-width: 20px'), 20); |
27 shouldBe("imageBorderWidth('x', 'border-width: 20px')", "20"); | 25 assert_equals(imageBorderWidth('x', 'border-width: 20px'), 20); |
28 shouldBe("imageBorderWidth(0, 'border-width: 20px')", "20"); | 26 assert_equals(imageBorderWidth(0, 'border-width: 20px'), 20); |
29 | 27 |
30 shouldBe("imageBorderWidth(10)", "10"); | 28 assert_equals(imageBorderWidth(10), 10); |
31 shouldBe("imageBorderWidth(' 10')", "10"); | 29 assert_equals(imageBorderWidth(' 10'), 10); |
32 shouldBe("imageBorderWidth('10 ')", "10"); | 30 assert_equals(imageBorderWidth('10 '), 10); |
33 shouldBe("imageBorderWidth(' 10 ')", "10"); | 31 assert_equals(imageBorderWidth(' 10 '), 10); |
34 shouldBe("imageBorderWidth('10q')", "10"); | 32 assert_equals(imageBorderWidth('10q'), 10); |
35 shouldBe("imageBorderWidth(' 10q')", "10"); | 33 assert_equals(imageBorderWidth(' 10q'), 10); |
36 shouldBe("imageBorderWidth('10q ')", "10"); | 34 assert_equals(imageBorderWidth('10q '), 10); |
37 shouldBe("imageBorderWidth(' 10q ')", "10"); | 35 assert_equals(imageBorderWidth(' 10q '), 10); |
36 }); | |
OLD | NEW |