|
Line 0
LayoutTests/fast/replaced/table-cell-width-percent.html_sec1
|
|
|
1 |
<html> |
| 2 |
<head> |
| 3 |
<title>Test for Buzilla Bug 81084: Fix rendering of replaced elements with relative dimensions within a table cell.</title> |
| 4 |
<script src="../js/resources/js-test-pre.js"></script> |
| 5 |
<script> |
| 6 |
|
| 7 |
function getComputedStyleForElement(element, cssPropertyName) |
| 8 |
{ |
| 9 |
if (window.getComputedStyle) { |
| 10 |
return window.getComputedStyle(element, '').getPropertyValue(cssPropertyName.replace(/([A-Z])/g, "-$1").toLowerCase()); |
| 11 |
} |
| 12 |
if (element.currentStyle) { |
| 13 |
return element.currentStyle[cssPropertyName]; |
| 14 |
} |
| 15 |
return null; |
| 16 |
} |
| 17 |
|
| 18 |
function getWidth(id) |
| 19 |
{ |
| 20 |
return getComputedStyleForElement(document.getElementById(id), 'width'); |
| 21 |
} |
| 22 |
|
| 23 |
function getHeight(id) |
| 24 |
{ |
| 25 |
return getComputedStyleForElement(document.getElementById(id), 'height'); |
| 26 |
} |
| 27 |
|
| 28 |
function test() |
| 29 |
{ |
| 30 |
description("This test checks that with replaced elements with relative dimensions (percent height) within a table cell (with percent height/width), the table cell gets the proper width."); |
| 31 |
|
| 32 |
shouldBe("getWidth('canvas-td-height-percent')", "'300px'"); |
| 33 |
shouldBe("getHeight('canvas-td-height-percent')", "'150px'"); |
| 34 |
shouldBe("getWidth('canvas-td-width-percent')", "'490px'"); |
| 35 |
shouldBe("getHeight('canvas-td-width-percent')", "'150px'"); |
| 36 |
|
| 37 |
shouldBe("getWidth('embed-td-height-percent')", "'300px'"); |
| 38 |
shouldBe("getHeight('embed-td-height-percent')", "'150px'"); |
| 39 |
shouldBe("getWidth('embed-td-width-percent')", "'490px'"); |
| 40 |
shouldBe("getHeight('embed-td-width-percent')", "'150px'"); |
| 41 |
|
| 42 |
shouldBe("getWidth('img-td-height-percent')", "'100px'"); |
| 43 |
shouldBe("getHeight('img-td-height-percent')", "'100px'"); |
| 44 |
shouldBe("getWidth('img-td-width-percent')", "'490px'"); |
| 45 |
shouldBe("getHeight('img-td-width-percent')", "'100px'"); |
| 46 |
|
| 47 |
shouldBe("getWidth('img-td-height-percent-nested')", "'100px'"); |
| 48 |
shouldBe("getHeight('img-td-height-percent-nested')", "'100px'"); |
| 49 |
shouldBe("getWidth('img-td-width-percent-nested')", "'490px'"); |
| 50 |
shouldBe("getHeight('img-td-width-percent-nested')", "'100px'"); |
| 51 |
|
| 52 |
shouldBe("getWidth('object-td-height-percent')", "'300px'"); |
| 53 |
shouldBe("getHeight('object-td-height-percent')", "'150px'"); |
| 54 |
shouldBe("getWidth('object-td-width-percent')", "'490px'"); |
| 55 |
shouldBe("getHeight('object-td-width-percent')", "'150px'"); |
| 56 |
|
| 57 |
shouldBeTrue("getWidth('button-td-height-percent') != '0px'"); |
| 58 |
shouldBeTrue("getHeight('button-td-height-percent') != '0px'"); |
| 59 |
shouldBeTrue("getWidth('button-td-width-percent') != '0px'"); |
| 60 |
shouldBeTrue("getHeight('button-td-width-percent') != '0px'"); |
| 61 |
|
| 62 |
shouldBeTrue("getWidth('input-button-td-height-percent') != '0px'"); |
| 63 |
shouldBeTrue("getHeight('input-button-td-height-percent') != '0px'"); |
| 64 |
shouldBeTrue("getWidth('input-button-td-width-percent') != '0px'"); |
| 65 |
shouldBeTrue("getHeight('input-button-td-width-percent') != '0px'"); |
| 66 |
|
| 67 |
shouldBeTrue("getWidth('input-checkbox-td-height-percent') != '0px'"); |
| 68 |
shouldBeTrue("getHeight('input-checkbox-td-height-percent') != '0px'"); |
| 69 |
shouldBeTrue("getWidth('input-checkbox-td-width-percent') != '0px'"); |
| 70 |
shouldBeTrue("getHeight('input-checkbox-td-width-percent') != '0px'"); |
| 71 |
|
| 72 |
shouldBeTrue("getWidth('input-file-td-height-percent') != '0px'"); |
| 73 |
shouldBeTrue("getHeight('input-file-td-height-percent') != '0px'"); |
| 74 |
shouldBeTrue("getWidth('input-file-td-width-percent') != '0px'"); |
| 75 |
shouldBeTrue("getHeight('input-file-td-width-percent') != '0px'"); |
| 76 |
|
| 77 |
shouldBe("getWidth('input-image-td-height-percent')", "'100px'"); |
| 78 |
shouldBe("getHeight('input-image-td-height-percent')", "'100px'"); |
| 79 |
shouldBe("getWidth('input-image-td-width-percent')", "'490px'"); |
| 80 |
shouldBe("getHeight('input-image-td-width-percent')", "'100px'"); |
| 81 |
|
| 82 |
shouldBeTrue("getWidth('input-radio-td-height-percent') != '0px'"); |
| 83 |
shouldBeTrue("getHeight('input-radio-td-height-percent') != '0px'"); |
| 84 |
shouldBeTrue("getWidth('input-radio-td-width-percent') != '0px'"); |
| 85 |
shouldBeTrue("getHeight('input-radio-td-width-percent') != '0px'"); |
| 86 |
|
| 87 |
shouldBeTrue("getWidth('select-td-height-percent') != '0px'"); |
| 88 |
shouldBeTrue("getHeight('select-td-height-percent') != '0px'"); |
| 89 |
shouldBeTrue("getWidth('select-td-width-percent') != '0px'"); |
| 90 |
shouldBeTrue("getHeight('select-td-width-percent') != '0px'"); |
| 91 |
|
| 92 |
var elements = document.getElementsByTagName('table'); |
| 93 |
while (elements.length > 0) { |
| 94 |
elements[0].parentNode.removeChild(elements[0]); |
| 95 |
elements = document.getElementsByTagName('table'); |
| 96 |
} |
| 97 |
|
| 98 |
isSuccessfullyParsed(); |
| 99 |
} |
| 100 |
</script> |
| 101 |
|
| 102 |
<style> |
| 103 |
.height100percent { |
| 104 |
height: 100%; |
| 105 |
} |
| 106 |
table { |
| 107 |
font-family: ahem; |
| 108 |
width: 600px; |
| 109 |
} |
| 110 |
</style> |
| 111 |
|
| 112 |
</head> |
| 113 |
<body onload="test()"> |
| 114 |
|
| 115 |
<p>Test for Bugzilla <a href="https://bugs.webkit.org/show_bug.cgi?id=81084">Bug 81084</a>: Fix rendering of replaced elements with relative dimensions within a table cell.</p> |
| 116 |
|
| 117 |
<!-- Canvas --> |
| 118 |
<table><tr><td height="100%" id="canvas-td-height-percent"><canvas class="height100percent"></canvas></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 119 |
<table><tr><td width="100%" id="canvas-td-width-percent"><canvas class="height100percent"></canvas></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 120 |
|
| 121 |
<!-- Embed --> |
| 122 |
<!-- Fails on Firefox --> |
| 123 |
<table><tr><td height="100%" id="embed-td-height-percent"><embed class="height100percent"></embed></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 124 |
<table><tr><td width="100%" id="embed-td-width-percent"><embed class="height100percent"></embed></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 125 |
|
| 126 |
<!-- Image --> |
| 127 |
<table><tr><td height="100%" id="img-td-height-percent"><img src="resources/square-blue-100x100.png" class="height100percent"></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 128 |
<table><tr><td width="100%" id="img-td-width-percent"><img src="resources/square-blue-100x100.png" class="height100percent"></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 129 |
|
| 130 |
<!-- Nested image --> |
| 131 |
<table><tr><td height="100%" id="img-td-height-percent-nested"><div><img src="resources/square-blue-100x100.png" class="height100percent"></div></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 132 |
<table><tr><td width="100%" id="img-td-width-percent-nested"><div><img src="resources/square-blue-100x100.png" class="height100percent"></div></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 133 |
|
| 134 |
<!-- Object --> |
| 135 |
<!-- Fails on Firefox --> |
| 136 |
<table><tr><td height="100%" id="object-td-height-percent"><object class="height100percent"></object></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 137 |
<table><tr><td width="100%" id="object-td-width-percent"><object class="height100percent"></object></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 138 |
|
| 139 |
<!-- Button --> |
| 140 |
<table><tr><td height="100%" id="button-td-height-percent"><button class="height100percent" value="Button"></button></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 141 |
<table><tr><td width="100%" id="button-td-width-percent"><button class="height100percent" value="Button"></button></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 142 |
|
| 143 |
<!-- Input Button --> |
| 144 |
<table><tr><td height="100%" id="input-button-td-height-percent"><input type="button" class="height100percent"></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 145 |
<table><tr><td width="100%" id="input-button-td-width-percent"><input type="button" class="height100percent"></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 146 |
|
| 147 |
<!-- Input checkbox --> |
| 148 |
<table><tr><td height="100%" id="input-checkbox-td-height-percent"><input type="checkbox" class="height100percent"></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 149 |
<table><tr><td width="100%" id="input-checkbox-td-width-percent"><input type="checkbox" class="height100percent"></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 150 |
|
| 151 |
<!-- Input file --> |
| 152 |
<table><tr><td height="100%" id="input-file-td-height-percent"><input type="file" class="height100percent"></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 153 |
<table><tr><td width="100%" id="input-file-td-width-percent"><input type="file" class="height100percent"></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 154 |
|
| 155 |
<!-- Input image --> |
| 156 |
<table><tr><td height="100%" id="input-image-td-height-percent"><input type="image" src="resources/square-blue-100x100.png" class="height100percent"></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 157 |
<table><tr><td width="100%" id="input-image-td-width-percent"><input type="image" src="resources/square-blue-100x100.png" class="height100percent"></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 158 |
|
| 159 |
<!-- Input radio --> |
| 160 |
<table><tr><td height="100%" id="input-radio-td-height-percent"><input type="radio" class="height100percent"></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 161 |
<table><tr><td width="100%" id="input-radio-td-width-percent"><input type="radio" class="height100percent"></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 162 |
|
| 163 |
<!-- Select --> |
| 164 |
<table><tr><td height="100%" id="select-td-height-percent"><select class="height100percent"><option>Option</option></select></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 165 |
<table><tr><td width="100%" id="select-td-width-percent"><select class="height100percent"><option>Option</option></select></td><td><span>This is the second table cell</span></td><td width="100%"></td></tr></table> |
| 166 |
|
| 167 |
<p id="description"></p> |
| 168 |
<div id="console"></div> |
| 169 |
</body> |
| 170 |
</html> |