blob: c9289ce31cb68c21340a1b4f7fb7ff2c093d1290 [file] [log] [blame]
Simon Pieters9e2f4cd2012-10-12 14:22:041<!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 Pieters9e2f4cd2012-10-12 14:22:0416 onload = function() {
Simon Pietersce449df2014-12-15 11:48:1717 var html = "<style id=style></style>";
18 var png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==";
19 var preload = new Image();
20 preload.src = png;
21 var a_doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
22 var s_doctype = '<!DOCTYPE HTML>';
23 var q = document.getElementById('quirks').contentWindow;
24 var a = document.getElementById('almost').contentWindow;
25 var s = document.getElementById('standards').contentWindow;
26 q.document.open();
27 q.document.write(html);
28 q.document.close();
29 a.document.open();
30 a.document.write(a_doctype + html);
31 a.document.close();
32 s.document.open();
33 s.document.write(s_doctype + html);
34 s.document.close();
Simon Pieters9e2f4cd2012-10-12 14:22:0435 [q, a, s].forEach(function(win) {
36 ['style', 'test', 'ref', 's_ref'].forEach(function(id) {
37 win.__proto__.__defineGetter__(id, function() { return win.document.getElementById(id); });
38 });
39 });
Simon Pieters6a20ee02014-04-30 09:53:5540
Simon Pieters9e2f4cd2012-10-12 14:22:0441 var tests = [
42 {style:'', body:'<div id=test><img src="{png}"></div><img id=ref src="{png}"><div id=s_ref>x</div>'},
43 {style:'', body:'<div id=test><img src="{png}"> <img src="{png}"></div><div id=ref>x</div><div id=s_ref>x</div>'},
44 {style:'', body:'<table><tr><td id=test><img src="{png}"><tr><td><img id=ref src="{png}"><tr><td id=s_ref>x</table>'},
45 {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 Pieters9e2f4cd2012-10-12 14:22:0446 {style:'', body:'<pre id=test><img src="{png}"></pre><img id=ref src="{png}"><pre id=s_ref>x</pre>'},
47 {style:'', body:'<pre id=test><img src="{png}"> </pre><pre id=ref>x</pre><pre id=s_ref>x</pre>'},
48 {style:'span { margin:1px }', body:'<div id=test><span></span></div><div id=ref></div><div id=s_ref>x</div>'},
49 {style:'span { padding:1px 0 }', body:'<div id=test><span></span></div><div id=ref></div><div id=s_ref></div>'},
50 {style:'span { margin:0 1px }', body:'<div id=test><span></span></div><div id=ref></div><div id=s_ref>x</div>'},
51 {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>'},
52 {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>'},
53 {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>'},
54 {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>'},
55 {style:'span { border-right:1px solid }', body:'<div id=test><span></span></div><div id=ref>x</div><div id=s_ref>x</div>'},
56 {style:'span { border-left:1px solid }', body:'<div id=test><span></span></div><div id=ref>x</div><div id=s_ref>x</div>'},
57 {style:'span { padding-right:1px }', body:'<div id=test><span></span></div><div id=ref>x</div><div id=s_ref>x</div>'},
58 {style:'span { padding-left:1px }', body:'<div id=test><span></span></div><div id=ref>x</div><div id=s_ref>x</div>'},
59 {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." */
60 {style:'', body:'<div id=test><img src="{png}" border=1></div><img id=ref src="{png}" height=3><div id=s_ref>x</div>'},
61 {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>'},
62 {style:'iframe { height:1px }', body:'<div id=test><iframe></iframe></div><img id=ref src="{png}" height=5><div id=s_ref>x</div>'},
63 {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 Pieters8cec91c2013-03-01 15:30:4464 {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 Pieters9e2f4cd2012-10-12 14:22:0465 ];
66
67 tests.forEach(function(t) {
68 test(function() {
69 var style = t.style.replace(/\{png\}/g, png);
70 var body = t.body.replace(/\{png\}/g, png);
71 q.style.textContent = style;
72 a.style.textContent = style;
73 s.style.textContent = style;
74 q.document.body.innerHTML = body;
75 a.document.body.innerHTML = body;
76 s.document.body.innerHTML = body;
Simon Pieters6a20ee02014-04-30 09:53:5577
Simon Pieters9e2f4cd2012-10-12 14:22:0478 assert_equals(q.getComputedStyle(q.test).height,
79 q.getComputedStyle(q.ref).height,
80 'quirks mode');
81 assert_equals(a.getComputedStyle(a.test).height,
82 a.getComputedStyle(a.ref).height,
83 'almost standards mode');
84 assert_equals(s.getComputedStyle(s.test).height,
85 s.getComputedStyle(s.s_ref).height,
86 'standards mode');
87 }, document.title+', '+t.style+t.body);
88 });
89
90 done();
91 }
92 </script>
93 </body>
Simon Pieters6a20ee02014-04-30 09:53:5594</html>