Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/quirks-mode/table-cell-width-calculation.html

Issue 1974833002: Import quirks-mode tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add separate Release and Debug entries Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <title>The table cell width 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><table><tr><td id=test></table><tabl e><tr><td id=ref></table><table><tr><td id=s_ref></table>";
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 q.title = 'quirks mode';
43 a.title = 'almost standards mode';
44 s.title = 'standards mode';
45
46 var tests = [
47 {desc:"baseline",
48 style:'table { width:8px }', // cell content width should be 2px (2px ce ll-spacing, 1px padding)
49 test:'<img src="{png}">',
50 ref:'<img src="{png}">',
51 s_ref:'<img src="{png}">'},
52
53 {desc:"basic",
54 style:'table { width:8px }',
55 test:'<img src="{png}"><img src="{png}"><img src="{png}">',
56 ref:'<nobr><img src="{png}"><img src="{png}"><img src="{png}"></nobr>',
57 s_ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></no br>'},
58
59 {desc:"inline-block",
60 style:'table { width:8px } img { display:inline-block }',
61 test:'<img src="{png}"><img src="{png}"><img src="{png}">',
62 ref:'<nobr><img src="{png}"><img src="{png}"><img src="{png}"></nobr>',
63 s_ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></no br>'},
64
65 {desc:"img in span",
66 style:'table { width:8px }',
67 test:'<span><img src="{png}"><img src="{png}"><img src="{png}"></span>',
68 ref:'<nobr><img src="{png}"><img src="{png}"><img src="{png}"></nobr>',
69 s_ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></no br>'},
70
71 {desc:"the don't-wrap rule is only for the purpose of calculating the wi dth of the cell",
72 style:'table { width:8px }',
73 test:'<img src="{png}"><wbr><img src="{png}"><img src="{png}"><img src=" {png}">',
74 ref:'<nobr><img src="{png}"><img src="{png}"><img src="{png}"><br><img s rc="{png}"></nobr>',
75 s_ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"><img src="{png}"></nobr>'},
76
77 {desc:"the quirk only applies when the cell is the containing block",
78 style:'table { width:8px }',
79 test:'<div><img src="{png}"><img src="{png}"><img src="{png}"></div>',
80 ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"><img s rc="{png}"></nobr>',
81 s_ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"><img src="{png}"></nobr>'},
82
83 {desc:"the quirk shouldn't apply for generated content",
84 style:'table { width:8px } #test::before { content:url("{png}") url("{pn g}") url("{png}") }',
85 test:'',
86 ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></nobr >',
87 s_ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></no br>'},
88
89 {desc:"the quirk shouldn't apply for <input>",
90 style:'table { width:8px }',
91 test:'<input type=image src="{png}"><input type=image src="{png}"><input type=image src="{png}">',
92 ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></nobr >',
93 s_ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></no br>'},
94
95 {desc:"the quirk shouldn't apply for <object>",
96 style:'table { width:8px }',
97 test:'<object data="{png}"></object><object data="{png}"></object><objec t data="{png}"></object>',
98 ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></nobr >',
99 s_ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></no br>'},
100
101 {desc:"the quirk shouldn't apply for <embed>",
102 style:'table { width:8px }',
103 test:'<embed src="{png}"><embed src="{png}"><embed src="{png}">',
104 ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></nobr >',
105 s_ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></no br>'},
106
107 {desc:"the quirk shouldn't apply for <video poster>",
108 style:'table { width:8px }',
109 test:'<video poster="{png}"></video><video poster="{png}"></video><video poster="{png}"></video>',
110 ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></nobr >',
111 s_ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></no br>'},
112
113 {desc:"non-auto width on cell",
114 style:'td { width:2px }',
115 test:'<img src="{png}"><img src="{png}"><img src="{png}">',
116 ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></nobr >',
117 s_ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></no br>'},
118
119 {desc:"zero width on cell, specified with on table",
120 style:'table { width:8px } td { width:0 }',
121 test:'<img src="{png}"><img src="{png}"><img src="{png}">',
122 ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></nobr >',
123 s_ref:'<nobr><img src="{png}"><img src="{png}"><br><img src="{png}"></no br>'},
124
125 // tests below use overwrite body.innerHTML so tests using test/ref/s_re f props need to be above
126 {desc:"display:table-cell on span",
127 style:'div { display:table; width:2px } span { display:table-cell }',
128 body:'<div><span id=test><img src="{png}"><img src="{png}"><img src="{pn g}"></span></div>'+
129 '<div><span id=ref><nobr><img src="{png}"><img src="{png}"><img src="{pn g}"></nobr></span></div>'+
130 '<div><span id=s_ref><nobr><img src="{png}"><img src="{png}"><br><img sr c="{png}"></nobr></span></div>'},
131
132 {desc:"display:table-cell on span, wbr",
133 style:'div { display:table; width:2px } span { display:table-cell }',
134 body:'<div><span id=test><img src="{png}"><wbr><img src="{png}"><img src ="{png}"><img src="{png}"></span></div>'+
135 '<div><span id=ref><nobr><img src="{png}"><img src="{png}"><img src="{pn g}"><br><img src="{png}"></nobr></span></div>'+
136 '<div><span id=s_ref><nobr><img src="{png}"><img src="{png}"><br><img sr c="{png}"><img src="{png}"></nobr></span></div>'},
137 ];
138
139 tests.forEach(function(t) {
140 test(function() {
141 var style = t.style.replace(/\{png\}/g, png);
142 var test = t.test && t.test.replace(/\{png\}/g, png);
143 var ref = t.ref && t.ref.replace(/\{png\}/g, png);
144 var s_ref = t.s_ref && t.s_ref.replace(/\{png\}/g, png);
145 var body = t.body && t.body.replace(/\{png\}/g, png);
146 [q, a, s].forEach(function(win) {
147 win.style.textContent = style;
148 if (body !== undefined) {
149 win.document.body.innerHTML = body;
150 } else {
151 win.test.innerHTML = test;
152 win.ref.innerHTML = ref;
153 win.s_ref.innerHTML = s_ref;
154 }
155 assert_equals(win.getComputedStyle(win.test).width,
156 win.getComputedStyle(win == q ? win.ref : win. s_ref).width,
157 'cell width, '+win.title);
158 var test_imgs = win.test.querySelectorAll('img');
159 var ref_imgs = win.ref.querySelectorAll('img');
160 var s_ref_imgs = win.s_ref.querySelectorAll('img');
161 for (var i = 0; i < test_imgs.length; ++i) {
162 assert_equals(test_imgs[i].offsetLeft,
163 win == q ? ref_imgs[i].offsetLeft : s_ref_ imgs[i].offsetLeft,
164 'img '+i+' offsetLeft, '+win.title);
165 }
166 });
167 }, document.title+', '+t.desc);
168 });
169
170 done();
171 }
172 </script>
173 </body>
174 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698