8000 [css-tables] Added some row-measure tests · w3c/csswg-test@c682b3c · GitHub
Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit c682b3c

Browse files
committed
[css-tables] Added some row-measure tests
1 parent 3ac8b4c commit c682b3c

File tree

5 files changed

+352
-55
lines changed

5 files changed

+352
-55
lines changed

work-in-progress/microsoft/css-tables/height-distribution/computing-row-measure-0.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel='stylesheet' href='../base.css' />
66

77
<link rel="author" title="Greg Whitworth" href="gwhit@microsoft.com" />
8-
<link rel="help" href="file:///C:/csswg-drafts/css-tables-3/Overview.html#computing-column-measures" />
8+
<link rel="help" href="https://drafts.csswg.org/css-tables-3/#computing-column-measures" />
99
<main>
1010
<h4>"Computing row measures"</h4>
1111
<p>This is testing that the table root's minimum is max(table-root width, capmin, gridmin) <a href="https://drafts.csswg.org/css-tables-3/#computing-the-table-width">Spec Text</a></p>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<!doctype html>
2+
<script src='/resources/testharness.js'></script>
3+
<script src='/resources/testharnessreport.js'></script>
4+
<link rel='stylesheet' href='/resources/testharness.css'>
5+
<link rel='stylesheet' href='../base.css' />
6+
7+
<link rel="author" title="Greg Whitworth" href="gwhit@microsoft.com" />
8+
<link rel="help" href="https://drafts.csswg.org/css-tables-3/#computing-column-measures" />
9+
<main>
10+
<h1>Width Distribution</h1>
11+
<h4>"Computing column measures"</h4>
12+
<p>This is testing intermediate min-content width for span 2</p>
13+
14+
<hr/>
15+
<table cellspacing="0" cellpadding="0">
16+
<colgroup style="width: auto;">
17+
<col style="width: 10px;"></col>
18+
<col style="width: 20px;"></col>
19+
</colgroup>
20+
<tr>
21+
<td id="one" style="width: 1px;"></td>
22+
<td style="width: 2px;"></td>
23+
</tr>
24+
<tr>
25+
<td colspan="2" style="width: 51px;"></td>
26+
</tr>
27+
</table>
28+
29+
<table cellspacing="0" cellpadding="0">
30+
<colgroup style="width: auto;">
31+
<col style="width: 10px;"></col>
32+
<col style="width: auto;"></col>
33+
</colgroup>
34+
<tr>
35+
<td id="two" style="width: 1px;"></td>
36+
<td style="width: auto;"></td>
37+
</tr>
38+
<tr>
39+
<td colspan="2" style="width: 51px;"></td>
40+
</tr>
41+
</table>
42+
43+
<table cellspacing="0" cellpadding="0">
44+
<colgroup style="width: 51px;">
45+
<col style="width: 10px;"></col>
46+
<col style="width: 20px;"></col>
47+
</colgroup>
48+
<tr>
49+
<td id="three" style="width: 1px;"></td>
50+
<td style="width: 2px;"></td>
51+
</tr>
52+
</table>
53+
54+
<table cellspacing="0" cellpadding="0">
55+
<colgroup style="width: 51px;">
56+
<col style="width: 20px;"></col>
57+
<col style="width: auto;"></col>
58+
</colgroup>
59+
<tr>
60+
<td style="width: 10px;"></td>
61+
<td id="four" style="width: 20px;"></td>
62+
</tr>
63+
</table>
64+
</main>
65+
66+
<style>
67+
table { margin-bottom: 10px; height: 50px; }
68+
td { outline: 1px solid red; outline-offset: -1px; }
69+
</style>
70+
<script>
71+
var i = 1;
72+
generate_tests(assert_equals, [
73+
[
74+
"Checking intermediate min-content width for span 2 (1)",
75+
document.getElementById('one').offsetWidth,
76+
17
77+
],
78+
[
79+
"Checking intermediate min-content width for span 2 (2)",
80+
document.getElementById('two').offsetWidth,
81+
10
82+
],
83+
[
84+
"Checking intermediate min-content width for span 2 (3)",
85+
document.getElementById('three').offsetWidth,
86+
10
87+
],
88+
[
89+
"Checking intermediate min-content width for span 2 (4)",
90+
document.getElementById('four').offsetWidth,
91+
51
92+
]
93+
]);
94+
</script>
95+
</html>
Lines changed: 200 additions & 0 deletions
< A2DC /tr>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
<!doctype html>
2+
<link rel="stylesheet" href="base.css" />
3+
<aside style="position:absolute"><!-- THIS IS WHERE WE RUN THE EXPERIMENTS --></aside>
4+
<main><textarea style="display: none; width: 100%"></textarea><script>
5+
6+
var textarea = document.querySelector('textarea');
7+
var testingBorderAttributes = true;
8+
var seed = 0;
9+
10+
// This is not meant to be a good random number generator; I literally don't care
11+
function XorshiftMath(seed) {
12+
var x = 1;
13+
var y = 2;
14+
var z = 3;
15+
var w = seed|0;
16+
this.random = function random() {
17+
var t = x;
18+
t ^= t << 11;
19+
t ^= t >> 8;
20+
x = y; y = z; z = w;
21+
w ^= w >> 19;
22+
w ^= t;
23+
return (w%1024)/1024;
24+
}
25+
}
26+
27+
var rndGen = new XorshiftMath(seed);
28+
function rnd(x) {
29+
return x > rndGen.random();
30+
}
31+
function pickInList(list) {
32+
var i = list.length; while(i>1 && rnd(1/i)) { i--; }
33+
return list[i-1];
34+
}
35+
36+
function generateMarkup(root) {
37+
if(rnd(0.99)) {
38+
39+
//
40+
// the table has a <table> element
41+
//
42+
var table = document.createElement('table');
43+
44+
//
45+
if(testingBorderAttributes) {
46+
if(rnd(0.3)) { table.setAttribute('border',pickInList(['0','10','yes'])); }
47+
if(rnd(0.3)) { table.setAttribute('frame',pickInList(['box','vsides','none'])); }
48+
if(rnd(0.3)) { table.setAttribute('rules',pickInList(['all','rows','groups'])); }
49+
table.setAttribute("cellspacing","0");
50+
}
51+
52+
53+
generateRowGroups(table);
54+
root.appendChild(table);
55+
56+
} else {
57+
58+
//
59+
// the table has no <table> element
60+
//
61+
62+
generateRowGroup(root);
63+
64+
}
65+
}
66+
67+
function generateRowGroups(root) {
68+
if(rnd(0.5)) {
69+
70+
generateRowGroup(root);
71+
while(rnd(0.25)) {
72+
generateRowGroup(root);
73+
}
74+
75+
} else {
76+
77+
generateRows(root);
78+
79+
}
80+
}
81+
82+
function generateRowGroup(root) {
83+
84+
var tbody; if(rnd(0.7)) {
85+
tbody = document.createElement('tbody');
86+
} else if (rnd(0.5)) {
87+
tbody = document.createElement('thead');
88+
} else {
89+
tbody = document.createElement('tfoot');
90+
}
91+
92+
generateRows(tbody);
93+
root.appendChild(tbody);
94+
95+
}
96+
97+
function generateRows(root) {
98+
99+
while(rnd(0.9)) {
100+
if(rnd(0.9)) {
101+
generateRow(root);
102+
} else {
103+
generateCells(root);
104+
}
105+
}
106+
107+
}
108+
109+
function generateRow(root) {
110+
111+
var tr = document.createElement('tr');
112+
generateCells(tr);
113+
root.appendChild(tr);
114+
115+
}
116+
117+
function generateCells(root) {
118+
119+
while(rnd(0.9)) {
120+
if(rnd(0.9)) {
121+
generateCell(root);
122+
} else {
123+
generateCellContent(root);
124+
}
125+
}
126+
127+
}
128+
129+
function generateCell(root) {
130+
131+
var td = document.createElement( rnd(0.9) ? 'td' : 'th' );
132+
generateCellContent(td);
133+
root.appendChild(td);
134+
135+
}
136+
137+
function generateCellContent() {
138+
// for now, do nothing
139+
}
140+
141+
for(var i = 10; i--;) {
142+
//document.write("<textarea style='width: 100%; display: none'>");
143+
var div = document.createElement('div');
144+
generateMarkup(div);
145+
appendReportFor(div);
146+
//document.write(div.innerHTML);
147+
//document.write("</textarea>");
148+
}
149+
150+
if(navigator.userAgent.indexOf("Edge") == -1) {
151+
var downloadLink = document.createElement('a');
152+
downloadLink.setAttribute("download","report.txt");
153+
downloadLink.href = "data:," + escape(textarea.value);
154+
downloadLink.textContent = "download";
155+
document.body.appendChild(downloadLink);
156+
}
157+
158+
function appendReportFor(markup) {
159+
var report = markup.innerHTML + '\r\n\r\n';
160+
161+
//
162+
// append markup to the dom
163+
//
164+
var root = document.querySelector('aside');
165+
root.innerHTML = '';
166+
root.appendChild(markup);
167+
168+
//
169+
// output box stats
170+
//
171+
var boxes = markup.getElementsByTagName("*");
172+
for(var i = 0; i<boxes.length; i++) {
173+
174+
var box = boxes[i];
175+
report += '' + i + ': ' + box.tagName + '\r\n';
176+
report += 'offsetWidth: ' + box.offsetWidth + '\r\n';
177+
report += 'offsetHeight: ' + box.offsetHeight + '\r\n';
178+
report += 'offsetLeft: ' + box.offsetLeft + '\r\n';
179+
report += 'offsetTop: ' + box.offsetTop + '\r\n';
180+
report += 'borderTopWidth: ' + getComputedStyle(box).borderTopWidth + '\r\n';
181+
report += 'borderTopStyle: ' + getComputedStyle(box).borderTopStyle + '\r\n';
182+
report += 'borderTopColor: ' + getComputedStyle(box).borderTopColor + '\r\n';
183+
report += 'borderLeftWidth: ' + getComputedStyle(box).borderLeftWidth + '\r\n';
184+
report += 'borderLeftStyle: ' + getComputedStyle(box).borderLeftStyle + '\r\n';
185+
report += 'borderLeftColor: ' + getComputedStyle(box).borderLeftColor + '\r\n';
186+
report += '\r\n';
187+
188+
}
189+
190+
report += '\r\n';
191+
report += '=====================================================================\r\n';
192+
report += '\r\n';
193+
194+
textarea.value += report;
195+
196+
root.innerHTML = '';
197+
198+
}
199+
200+
</script></main>

work-in-progress/microsoft/css-tables/width-distribution/computing-column-measure-0.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel='stylesheet' href='../base.css' />
66

77
<link rel="author" title="Greg Whitworth" href="gwhit@microsoft.com" />
8-
<link rel="help" href="file:///C:/csswg-drafts/css-tables-3/Overview.html#computing-column-measures" />
8+
<link rel="help" href="https://drafts.csswg.org/css-tables-3/#computing-column-measures" />
99
<main>
1010
<h1>Width Distribution</h1>
1111
<h4>"Computing column measures"</h4>

0 commit comments

Comments
 (0)