OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>The line height calculation quirk</title> |
| 5 <script src="../../../resources/testharness.js"></script> |
| 6 <script src="../../../resources/testharnessreport.js"></script> |
| 7 <style> iframe { width:200px; height:20px; } </style> |
| 8 </head> |
| 9 <body> |
| 10 <div id=log></div> |
| 11 <iframe id=quirks></iframe> |
| 12 <iframe id=almost></iframe> |
| 13 <iframe id=standards></iframe> |
| 14 <script> |
| 15 setup({explicit_done:true}); |
| 16 |
| 17 var png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcS
JAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="; |
| 18 var preload = new Image(); |
| 19 preload.src = png; |
| 20 |
| 21 onload = function() { |
| 22 var html = "<style id=style></style>"; |
| 23 var a_doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transition
al//EN" "http://www.w3.org/TR/html4/loose.dtd">'; |
| 24 var s_doctype = '<!DOCTYPE HTML>'; |
| 25 var q = document.getElementById('quirks').contentWindow; |
| 26 var a = document.getElementById('almost').contentWindow; |
| 27 var s = document.getElementById('standards').contentWindow; |
| 28 q.document.open(); |
| 29 q.document.write(html); |
| 30 q.document.close(); |
| 31 a.document.open(); |
| 32 a.document.write(a_doctype + html); |
| 33 a.document.close(); |
| 34 s.document.open(); |
| 35 s.document.write(s_doctype + html); |
| 36 s.document.close(); |
| 37 [q, a, s].forEach(function(win) { |
| 38 ['style', 'test', 'ref', 's_ref'].forEach(function(id) { |
| 39 win.__proto__.__defineGetter__(id, function() { return win.docum
ent.getElementById(id); }); |
| 40 }); |
| 41 }); |
| 42 |
| 43 var tests = [ |
| 44 {style:'', body:'<div id=test><img src="{png}"></div><img id=ref src="{p
ng}"><div id=s_ref>x</div>'}, |
| 45 {style:'', body:'<div id=test><img src="{png}"> <img src="{png}"></div><
div id=ref>x</div><div id=s_ref>x</div>'}, |
| 46 {style:'', body:'<table><tr><td id=test><img src="{png}"><tr><td><img id
=ref src="{png}"><tr><td id=s_ref>x</table>'}, |
| 47 {style:'', body:'<table><tr><td id=test><img src="{png}"> <img src="{png
}"><tr><td id=ref>x<tr><td id=s_ref>x</table>'}, |
| 48 {style:'', body:'<pre id=test><img src="{png}"></pre><img id=ref src="{p
ng}"><pre id=s_ref>x</pre>'}, |
| 49 {style:'', body:'<pre id=test><img src="{png}"> </pre><pre id=ref>x</pre
><pre id=s_ref>x</pre>'}, |
| 50 {style:'span { margin:1px }', body:'<div id=test><span></span></div><div
id=ref></div><div id=s_ref>x</div>'}, |
| 51 {style:'span { padding:1px 0 }', body:'<div id=test><span></span></div><
div id=ref></div><div id=s_ref></div>'}, |
| 52 {style:'span { margin:0 1px }', body:'<div id=test><span></span></div><d
iv id=ref></div><div id=s_ref>x</div>'}, |
| 53 {style:'span { margin:0 1px; padding:1px 0 }', body:'<div id=test><span>
</span></div><div id=ref></div><div id=s_ref>x</div>'}, |
| 54 {style:'span { border-width:1px 0; border-style:solid }', body:'<div id=
test><span></span></div><div id=ref></div><div id=s_ref></div>'}, |
| 55 {style:'span { border-width:1px; border-style:solid none }', body:'<div
id=test><span></span></div><div id=ref></div><div id=s_ref></div>'}, |
| 56 {style:'span { border-width:1px; border-style:solid hidden }', body:'<di
v id=test><span></span></div><div id=ref></div><div id=s_ref></div>'}, |
| 57 {style:'span { border-right:1px solid }', body:'<div id=test><span></spa
n></div><div id=ref>x</div><div id=s_ref>x</div>'}, |
| 58 {style:'span { border-left:1px solid }', body:'<div id=test><span></span
></div><div id=ref>x</div><div id=s_ref>x</div>'}, |
| 59 {style:'span { padding-right:1px }', body:'<div id=test><span></span></d
iv><div id=ref>x</div><div id=s_ref>x</div>'}, |
| 60 {style:'span { padding-left:1px }', body:'<div id=test><span></span></di
v><div id=ref>x</div><div id=s_ref>x</div>'}, |
| 61 {style:'span { display:inline-block; height:1px }', body:'<div id=test><
i><span></span> </i></div><span id=ref></span><div id=s_ref>x</div>'}, /* 16.6.1
: "If a space (U+0020) at the end of a line has 'white-space' set to 'normal', '
nowrap', or 'pre-line', it is also removed." */ |
| 62 {style:'', body:'<div id=test><img src="{png}" border=1></div><img id=re
f src="{png}" height=3><div id=s_ref>x</div>'}, |
| 63 {style:'#test img { padding:1px }', body:'<div id=test><img src="{png}">
</div><img id=ref src="{png}" height=3><div id=s_ref>x</div>'}, |
| 64 {style:'iframe { height:1px }', body:'<div id=test><iframe></iframe></di
v><img id=ref src="{png}" height=5><div id=s_ref>x</div>'}, |
| 65 {style:'#test::before { content:"" } #test::before, span { border:solid
}', body:'<div id=test></div><div id=ref><span>x</span></div><div id=s_ref><span
>x</span></div>'}, |
| 66 {style:'div { line-height: 0;} span { margin:0 1px; line-height: normal;
}', body:'<div id=test>x<span></span></div><div id=ref>x</div><div id=s_ref>x<s
pan>x</span></div>'}, |
| 67 ]; |
| 68 |
| 69 tests.forEach(function(t) { |
| 70 test(function() { |
| 71 var style = t.style.replace(/\{png\}/g, png); |
| 72 var body = t.body.replace(/\{png\}/g, png); |
| 73 q.style.textContent = style; |
| 74 a.style.textContent = style; |
| 75 s.style.textContent = style; |
| 76 q.document.body.innerHTML = body; |
| 77 a.document.body.innerHTML = body; |
| 78 s.document.body.innerHTML = body; |
| 79 |
| 80 assert_equals(q.getComputedStyle(q.test).height, |
| 81 q.getComputedStyle(q.ref).height, |
| 82 'quirks mode'); |
| 83 assert_equals(a.getComputedStyle(a.test).height, |
| 84 a.getComputedStyle(a.ref).height, |
| 85 'almost standards mode'); |
| 86 assert_equals(s.getComputedStyle(s.test).height, |
| 87 s.getComputedStyle(s.s_ref).height, |
| 88 'standards mode'); |
| 89 }, document.title+', '+t.style+t.body); |
| 90 }); |
| 91 |
| 92 done(); |
| 93 } |
| 94 </script> |
| 95 </body> |
| 96 </html> |
OLD | NEW |