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