| Simon Pieters | 9e2f4cd | 2012-10-12 14:22:04 | [diff] [blame] | 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}); | 
| Simon Pieters | ebc53e7 | 2015-01-13 16:47:02 | [diff] [blame] | 16 |  | 
|  | 17 | var png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="; | 
|  | 18 | var preload = new Image(); | 
|  | 19 | preload.src = png; | 
|  | 20 |  | 
| Simon Pieters | 9e2f4cd | 2012-10-12 14:22:04 | [diff] [blame] | 21 | onload = function() { | 
| Simon Pieters | ce449df | 2014-12-15 11:48:17 | [diff] [blame] | 22 | var html = "<style id=style></style>"; | 
| Simon Pieters | ce449df | 2014-12-15 11:48:17 | [diff] [blame] | 23 | var a_doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//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(); | 
| Simon Pieters | 9e2f4cd | 2012-10-12 14:22:04 | [diff] [blame] | 37 | [q, a, s].forEach(function(win) { | 
|  | 38 | ['style', 'test', 'ref', 's_ref'].forEach(function(id) { | 
|  | 39 | win.__proto__.__defineGetter__(id, function() { return win.document.getElementById(id); }); | 
|  | 40 | }); | 
|  | 41 | }); | 
| Simon Pieters | 6a20ee0 | 2014-04-30 09:53:55 | [diff] [blame] | 42 |  | 
| Simon Pieters | 9e2f4cd | 2012-10-12 14:22:04 | [diff] [blame] | 43 | var tests = [ | 
|  | 44 | {style:'', body:'<div id=test><img src="{png}"></div><img id=ref src="{png}"><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>'}, | 
| Simon Pieters | 9e2f4cd | 2012-10-12 14:22:04 | [diff] [blame] | 48 | {style:'', body:'<pre id=test><img src="{png}"></pre><img id=ref src="{png}"><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><div 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:'<div 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></span></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></div><div id=ref>x</div><div id=s_ref>x</div>'}, | 
|  | 60 | {style:'span { padding-left:1px }', body:'<div id=test><span></span></div><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=ref 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></div><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>'}, | 
| Simon Pieters | 8cec91c | 2013-03-01 15:30:44 | [diff] [blame] | 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<span>x</span></div>'}, | 
| Simon Pieters | 9e2f4cd | 2012-10-12 14:22:04 | [diff] [blame] | 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; | 
| Simon Pieters | 6a20ee0 | 2014-04-30 09:53:55 | [diff] [blame] | 79 |  | 
| Simon Pieters | 9e2f4cd | 2012-10-12 14:22:04 | [diff] [blame] | 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> | 
| Simon Pieters | 6a20ee0 | 2014-04-30 09:53:55 | [diff] [blame] | 96 | </html> |