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

Side by Side Diff: LayoutTests/imported/csswg-test/css-shapes-1/shape-outside/values/support/parsing-utils.js

Issue 816533002: Import CSSWG Shapes tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: One more test expectations update Created 6 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 var ParsingUtils = (function() {
2 function testInlineStyle(value, expected) {
3 var div = document.createElement('div');
4 div.style.setProperty('shape-outside', value);
5 var actual = div.style.getPropertyValue('shape-outside');
6 assert_equals(actual, expected);
7 }
8
9 function testComputedStyle(value, expected) {
10 var div = document.createElement('div');
11 div.style.setProperty('shape-outside', value);
12 document.body.appendChild(div);
13 var style = getComputedStyle(div);
14 var actual = style.getPropertyValue('shape-outside');
15 actual = roundResultStr(actual);
16 document.body.removeChild(div);
17
18 // Some of the tests in this suite have either/or expected results
19 // so this check allows for testing that at least one of them passes.
20 // Description of the 2 expecteds is below near calcTestValues.
21 if(Object.prototype.toString.call( expected ) === '[object Array]' && expect ed.length == 2) {
22 assert_true(expected[0] == actual || expected[1] == actual)
23 } else {
24 assert_equals(actual, typeof expected !== 'undefined' ? expected : value );
25 }
26 }
27
28 function testShapeMarginInlineStyle(value, expected) {
29 var div = document.createElement('div');
30 div.style.setProperty('shape-outside', "border-box inset(10px)");
31 div.style.setProperty('shape-margin', value);
32 var actual = div.style.getPropertyValue('shape-margin');
33 assert_equals(actual, expected);
34 }
35
36 function testShapeMarginComputedStyle(value, expected) {
37
38 var outerDiv = document.createElement('div');
39 outerDiv.style.setProperty('width', '100px');
40
41 var innerDiv = document.createElement('div');
42 innerDiv.style.setProperty('shape-outside', "border-box inset(10px)");
43 innerDiv.style.setProperty('shape-margin', value);
44
45 outerDiv.appendChild(innerDiv);
46 document.body.appendChild(outerDiv);
47
48 var style = getComputedStyle(innerDiv);
49 var actual = style.getPropertyValue('shape-margin');
50
51 assert_not_equals(actual, null);
52 if(actual.indexOf('calc') == -1 )
53 actual = roundResultStr(actual);
54 document.body.removeChild(outerDiv);
55
56 // See comment above about multiple expected results
57 if(Object.prototype.toString.call( expected ) === '[object Array]' && expect ed.length == 2) {
58 assert_true(expected[0] == actual || expected[1] == actual)
59 } else {
60 assert_equals(actual, !expected ? '0px' : expected);
61 }
62 }
63
64 function testShapeThresholdInlineStyle(value, expected) {
65 var div = document.createElement('div');
66 div.style.setProperty('shape-outside', 'url(someimage.png)');
67 div.style.setProperty('shape-image-threshold', value);
68 var actual = div.style.getPropertyValue('shape-image-threshold');
69 assert_equals(actual, expected);
70 }
71
72 function testShapeThresholdComputedStyle(value, expected) {
73
74 var div = document.createElement('div');
75 div.style.setProperty('shape-outside', 'url(someimage.png)');
76 div.style.setProperty('shape-image-threshold', value);
77 document.body.appendChild(div);
78
79 var style = getComputedStyle(div);
80 var actual = style.getPropertyValue('shape-image-threshold');
81
82 assert_not_equals(actual, null);
83 if(actual.indexOf('calc') == -1 )
84 actual = roundResultStr(actual);
85 document.body.removeChild(div);
86
87 // See comment above about multiple expected results
88 if(Object.prototype.toString.call( expected ) === '[object Array]' && expect ed.length == 2) {
89 assert_true(expected[0] == actual || expected[1] == actual)
90 } else {
91 assert_equals(actual, !expected ? '0' : expected);
92 }
93 }
94
95 // Builds an array of test cases to send to testharness.js where one test case i s: [name, actual, expected]
96 // These test cases will verify results from testInlineStyle() or testComputedSt yle()
97 function buildTestCases(testCases, testType) {
98 var results = [];
99
100 // If test_type isn't specified, test inline style
101 var type = typeof testType == 'undefined' ? 'invalid': testType;
102
103 testCases.forEach(function(test) {
104 oneTestCase = [];
105
106 // name - annotated by type (inline vs. computed)
107 if ( test.hasOwnProperty('name') ) {
108 oneTestCase.push(test['name'] +' - '+ type);
109 } else {
110 // If test_name isn't specified, use the actual
111 oneTestCase.push(test['actual'] +' - '+ type);
112 }
113
114 // actual
115 oneTestCase.push(test['actual'])
116
117 // expected
118 if( type.indexOf('invalid') != -1 ){
119 oneTestCase.push(null)
120 } else if( type == 'inline' ) {
121 oneTestCase.push(test['expected_inline']);
122 } else if( type == 'computed' ){
123 oneTestCase.push( convertToPx(test['expected_computed']) );
124 }
125 results.push(oneTestCase);
126 });
127 return results;
128 }
129
130
131 function buildPositionTests(shape, valid, type, units) {
132 var results = new Array();
133 var convert = type.indexOf('computed') != -1 ? true : false;
134
135 if(Object.prototype.toString.call( units ) === '[object Array]') {
136 units.forEach(function(unit) {
137 positionTests = buildPositionTests(shape, valid, type, unit);
138 results = results.concat(positionTests);
139 });
140 } else {
141 if (valid) {
142 validPositions.forEach(function(test) {
143 var testCase = [], testName, actual, expected;
144 // skip if this isn't explicitly testing length units
145 if( !(type.indexOf('lengthUnit') != -1 && test[0].indexOf("u1") == -1)) {
146 // actual
147 actual = shape + '(at ' + setUnit(test[0], false, units) +') ';
148
149 // expected
150 // if(convert && shape == 'circle')
151 // expected = shape + '(at ' + setUnit(test[1], convert, units) +')';
152 // else if(convert && shape == 'ellipse')
153 // expected = shape + '(at ' + setUnit(test[1], convert, units) +')';
154 // else
155 expected = shape + '(at ' + setUnit(test[1], convert, units) +')';
156
157 // name
158 if (type == 'lengthUnit + inline')
159 testName = 'test unit (inline): ' + units +' - '+ actual ;
160 else if (type == 'lengthUnit + computed')
161 testName = 'test unit (computed): ' + units +' - '+ act ual;
162 else
163 testName = (actual + ' serializes as ' + expected +' - ' + type);
164
165 testCase.push(testName)
166 testCase.push(actual);
167 testCase.push(expected);
168 results.push(testCase);
169 }
170 });
171 } else {
172 invalidPositions.forEach(function(test) {
173 var testValue = shape + '(at ' + setUnit(test, false, units) +') ';
174 testCase = new Array();
175 testCase.push(testValue + ' is invalid');
176 testCase.push(testValue);
177 testCase.push(null);
178 results.push(testCase);
179 });
180 }
181 }
182 return unique(results);
183 }
184
185 function buildRadiiTests(shape, type, units) {
186 var results = new Array();
187 var testUnits = typeof units == 'undefined' ? 'px': units;
188 var convert = type.indexOf('computed') != -1 ? true : false;
189
190 if(Object.prototype.toString.call( testUnits ) === '[object Array]') {
191 testUnits.forEach(function(unit) {
192 radiiTests = buildRadiiTests(shape, type, unit);
193 results = results.concat(radiiTests);
194 });
195 } else {
196 var validRadii = shape == 'circle' ? validCircleRadii : validEllipseRadi i;
197 validRadii.forEach(function(test) {
198 var testCase = [], name, actual, expected;
199
200 // skip if this isn't explicitly testing length units
201 if( !(type.indexOf('lengthUnit') != -1 && test[0].indexOf("u1") == - 1) ) {
202 actual = shape + '(' + setUnit(test[0], false, testUnits) +')';
203 // name
204 if (type.indexOf('lengthUnit') != -1) {
205 name = 'test unit: ' + units +' - '+ actual;
206 if(type.indexOf('computed') != -1)
207 name = name + ' - computed';
208 else
209 name = name + ' - inline';
210 }
211 else
212 name = actual +' - '+ type;
213
214 testCase.push(name);
215
216 // actual
217 testCase.push(actual);
218
219 // expected
220 if(type.indexOf('computed') != -1 && test.length == 3) {
221 expected = shape + '(' + setUnit(test[2], convert, testUnits ) +')';
222 } else {
223 expected = shape + '(' + setUnit(test[1], convert, testUnits ) +')';
224 }
225 testCase.push(expected);
226 results.push(testCase);
227 }
228 });
229 }
230 return unique(results);
231 }
232
233 function buildInsetTests(unit1, unit2, type) {
234 var results = new Array();
235 var convert = type == 'computed' ? true : false;
236
237 if(Object.prototype.toString.call( unit1 ) === '[object Array]') {
238 unit1.forEach(function(unit) {
239 insetTests = buildInsetTests(unit, unit2, type);
240 results = results.concat(insetTests);
241 });
242 } else {
243 validInsets.forEach(function(test) {
244 var testCase = [], name, actual, expected;
245
246 name = setUnit(test[0], false, unit1, unit2) +' - '+ type;
247 actual = 'inset(' + setUnit(test[1], convert, unit1, unit2) +')';
248 expected = actual;
249
250 testCase.push(name);
251 testCase.push(actual);
252 testCase.push(expected);
253
254 results.push(testCase);
255 });
256 }
257 return unique(results);
258 }
259
260 function buildPolygonTests(unitSet, type) {
261 var results = new Array();
262 var convert = type == 'computed' ? true : false;
263
264 unitSet.forEach(function(set) {
265 validPolygons.forEach(function(test) {
266 var testCase = [];
267 // name
268 testCase.push(setUnit(test[0], false, set[0], set[1], set[2]) +' - ' + type);
269 // actual
270 testCase.push('polygon(' + setUnit(test[1], false, set[0], set[1], s et[2]) +')');
271 // expected
272 testCase.push('polygon(' + setUnit(test[1], convert, set[0], set[1], set[2]) +')');
273 results.push(testCase);
274 });
275 });
276 return unique(results);
277 }
278
279 function buildCalcTests(testCases, type) {
280 var results = new Array();
281 testCases.forEach(function(test){
282 var testCase = [];
283 if(type == 'computed') {
284 testCase.push(test[0] + ' - computed style');
285 testCase.push(test[0]);
286 testCase.push(test[2]);
287 }
288 else {
289 testCase.push(test[0] + ' - inline style');
290 testCase.push(test[0]);
291 testCase.push(test[1]);
292 }
293 testCase.push(type);
294 results.push(testCase)
295 });
296 return unique(results);
297 }
298
299 function unique(tests) {
300 var list = tests.concat();
301 for(var i = 0; i< list.length; ++i) {
302 for(var j = i+1; j < list.length; ++j) {
303 if(list[i][0] === list[j][0])
304 list.splice(j--, 1);
305 }
306 }
307 return list;
308 }
309
310 function setUnit(str, convert, unit1, unit2, unit3) {
311 var retStr = str;
312 if(typeof unit1 !== 'undefined') {
313 retStr = retStr.replace(new RegExp('u1', 'g'), unit1);
314 }
315 if(typeof unit2 !== 'undefined') {
316 retStr = retStr.replace(new RegExp("u2", 'g'), unit2);
317 }
318 if(typeof unit3 !== 'undefined') {
319 retStr = retStr.replace(new RegExp("u3", 'g'), unit3);
320 }
321 retStr = convert ? convertToPx(retStr) : retStr;
322 return retStr;
323 }
324
325 function convertToPx(origValue) {
326
327 var valuesToConvert = origValue.match(/[0-9]+(\.[0-9]+)?([a-z]{2,4}|%)/g);
328 if(!valuesToConvert)
329 return origValue;
330
331 var retStr = origValue;
332 for(var i = 0; i < valuesToConvert.length; i++) {
333 var unit = valuesToConvert[i].match(/[a-z]{2,4}|%/).toString();
334 var numberStr = valuesToConvert[i].match(/[0-9]+(\.[0-9]+)?/)[0];
335
336 var number = parseFloat(numberStr);
337 var convertedUnit = 'px';
338 if( typeof number !== 'NaN' )
339 {
340 if (unit == 'in') {
341 number = (96 * number);
342 } else if (unit == 'cm') {
343 number = (37.795275591 * number);
344 } else if (unit == 'mm') {
345 number = (3.779527559 * number);
346 } else if (unit == 'pt') {
347 number = (1.333333333333 * number);
348 } else if (unit == 'pc') {
349 number = (16 * number);
350 } else if (unit == 'em') {
351 number = (16 * number);
352 } else if (unit == 'ex') {
353 number = (7.1796875 * number);
354 } else if (unit == 'ch') {
355 number = (8 * number);
356 } else if (unit == 'rem') {
357 number = (16 * number);
358 } else if (unit == 'vw') {
359 number = ((.01 * window.innerWidth) * number);
360 } else if (unit == 'vh') {
361 number = ((.01 * window.innerHeight) * number);
362 } else if (unit == 'vmin') {
363 number = Math.min( (.01 * window.innerWidth), (.01 * window.inn erHeight) ) * number;
364 } else if (unit == 'vmax') {
365 number = Math.max( (.01 * window.innerWidth), (.01 * window.inne rHeight) ) * number;
366 }
367 else {
368 convertedUnit = unit;
369 }
370 number = Math.round(number * 1000) / 1000;
371 var find = valuesToConvert[i];
372 var replace = number.toString() + convertedUnit;
373 retStr = retStr.replace(valuesToConvert[i], number.toString() + conv ertedUnit);
374 }
375 }
376 return retStr.replace(',,', ',');
377 }
378
379 function roundResultStr(str) {
380 if(Object.prototype.toString.call( str ) !== '[object String]')
381 return str;
382
383 var numbersToRound = str.match(/[0-9]+\.[0-9]+/g);
384 if(!numbersToRound)
385 return str;
386
387 var retStr = str;
388 for(var i = 0; i < numbersToRound.length; i++) {
389 num = parseFloat(numbersToRound[i]);
390 if( !isNaN(num) ) {
391 roundedNum = Math.round(num*1000)/1000;
392 retStr = retStr.replace(numbersToRound[i].toString(), roundedNum.toS tring());
393 }
394 }
395
396 return retStr;
397 }
398
399 function generateInsetRoundCases(units, testType) {
400 var convert = testType.indexOf('computed') != -1 ? true : false;
401 var testUnit = units;
402 var sizes = [
403 '10' + units,
404 '20' + units,
405 '30' + units,
406 '40' + units
407 ];
408
409 function insetRound(value) {
410 return 'inset(10' +testUnit+ ' round ' + value + ')';
411 }
412
413 function serializedInsetRound(lhsValues, rhsValues, convert) {
414 var retStr = '';
415 if(!rhsValues)
416 retStr = 'inset(10' +testUnit+ ' round ' + lhsValues +')';
417 else
418 retStr = 'inset(10' +testUnit+ ' round ' + lhsValues +' / '+ rhsValu es +')';
419
420 if(convert)
421 return convertToPx(retStr);
422
423 return retStr;
424 }
425
426 var results = [], left, lhs, right, rhs;
427 for (left = 1; left <= 4; left++) {
428 lhs = sizes.slice(0, left).join(' ');
429 results.push([insetRound(lhs) +' - '+ testType, insetRound(lhs), seriali zedInsetRound(lhs, null, convert)]);
430 for (right = 1; right <= 4; right++) {
431 rhs = sizes.slice(0, right).join(' ');
432 if(lhs == rhs)
433 results.push([insetRound(lhs + ' / ' + rhs) +' - '+ testType, in setRound(lhs + ' / ' + rhs), serializedInsetRound(lhs, null, convert)]);
434 else
435 results.push([insetRound(lhs + ' / ' + rhs) +' - '+ testType, in setRound(lhs + ' / ' + rhs), serializedInsetRound(lhs, rhs, convert)]);
436 }
437 }
438 return results;
439 }
440
441 var validUnits = [
442 "cm","mm","in","pt","pc", // Absolute length units (omittin g px b/c we default to that in all tests)
443 "em","ex","ch","rem", // Font relative length units
444 "vw","vh","vmin","vmax" // Viewport percentage units
445 ]
446
447 /// [actual, expected]
448 var validPositions = [
449
450 /// [ percent ], [ length ], [ percent | percent ], [ percent | length ], [ leng th | percent ], [ length | length ]
451 ["50%", "50% 50%"],
452 ["50u1", "50u1 50%"],
453 ["50% 50%", "50% 50%"],
454 ["50% 50u1", "50% 50u1"],
455 ["50u1 50%", "50u1 50%"],
456 ["50u1 50u1", "50u1 50u1"],
457
458 ///// [ keyword ], [ keyword keyword ] x 5 keywords
459 ["left", "0% 50%"],
460 ["top", "50% 0%"],
461 ["right", "100% 50%"],
462 ["bottom", "50% 100%"],
463 ["center", "50% 50%"],
464
465 ["left top", "0% 0%"],
466 ["left bottom", "0% 100%"],
467 ["left center", "0% 50%"],
468
469 ["top left", "0% 0%"],
470 ["top right", "100% 0%"],
471 ["top center", "50% 0%"],
472
473 ["right top", "100% 0%"],
474 ["right bottom", "100% 100%"],
475 ["right center", "100% 50%"],
476
477 ["bottom left", "0% 100%"],
478 ["bottom right", "100% 100%"],
479 ["bottom center", "50% 100%"],
480
481 ["center top", "50% 0%"],
482 ["center left", "0% 50%"],
483 ["center right", "100% 50%"],
484 ["center bottom", "50% 100%"],
485 ["center center", "50% 50%"],
486
487 ////// [ keyword | percent ], [ keyword | length ], [ percent | keyword ], [ len gth | keyword ] x 5 keywords
488 ["left 50%", "0% 50%"],
489 ["left 50u1", "0% 50u1"],
490
491 ["50% top", "50% 0%"],
492 ["50u1 top", "50u1 0%"],
493
494 ["right 80%", "100% 80%"],
495 ["right 80u1", "100% 80u1"],
496
497 ["70% bottom", "70% 100%"],
498 ["70u1 bottom", "70u1 100%"],
499
500 ["center 60%", "50% 60%"],
501 ["center 60u1", "50% 60u1"],
502 ["60% center", "60% 50%"],
503 ["60u1 center", "60u1 50%"],
504
505 ////// [ keyword | keyword percent ], [ keyword | keyword length ] x 5 keywords
506 ["center top 50%", "50% 50%"],
507 ["center top 50u1", "50% 50u1"],
508 ["center left 50%", "50% 50%"],
509 ["center left 50u1", "50u1 50%"],
510 ["center right 70%", "30% 50%"],
511 ["center right 70u1", "right 70u1 top 50%"],
512 ["center bottom 70%", "50% 30%"],
513 ["center bottom 70u1", "left 50% bottom 70u1"],
514
515 ["left top 50%", "0% 50%"],
516 ["left top 50u1", "0% 50u1"],
517 ["left bottom 70%", "0% 30%"],
518 ["left bottom 70u1", "left 0% bottom 70u1"],
519
520 ["top left 50%", "50% 0%"],
521 ["top left 50u1", "50u1 0%"],
522 ["top right 70%", "30% 0%"],
523 ["top right 70u1", "right 70u1 top 0%"],
524
525 ["bottom left 50%", "50% 100%"],
526 ["bottom left 50u1", "50u1 100%"],
527 ["bottom right 70%", "30% 100%"],
528 ["bottom right 70u1", "right 70u1 top 100%"],
529
530 ["right bottom 70%", "100% 30%"],
531 ["right bottom 70u1", "left 100% bottom 70u1"],
532 ["right top 50%", "100% 50%"],
533 ["right top 50u1", "100% 50u1"],
534
535 ////// [ keyword percent | keyword], [ keyword length | keyword ] x 5 keywords
536 ["left 50% center", "50% 50%"],
537 ["left 50u1 center", "50u1 50%"],
538 ["left 50% top", "50% 0%"],
539 ["left 50u1 top", "50u1 0%"],
540 ["left 50% bottom", "50% 100%"],
541 ["left 50u1 bottom", "50u1 100%"],
542
543 ["top 50% center", "50% 50%"],
544 ["top 50u1 center", "50% 50u1"],
545 ["top 50% left", "0% 50%"],
546 ["top 50u1 left", "0% 50u1"],
547 ["top 50% right", "100% 50%"],
548 ["top 50u1 right", "100% 50u1"],
549
550 ["bottom 70% center", "50% 30%"],
551 ["bottom 70u1 center", "left 50% bottom 70u1"],
552 ["bottom 70% left", "0% 30%"],
553 ["bottom 70u1 left", "left 0% bottom 70u1"],
554 ["bottom 70% right", "100% 30%"],
555 ["bottom 70u1 right", "left 100% bottom 70u1"],
556
557 ["right 80% center", "20% 50%"],
558 ["right 80u1 center", "right 80u1 top 50%"],
559 ["right 80% bottom", "20% 100%"],
560 ["right 80u1 bottom", "right 80u1 top 100%"],
561 ["right 80% top", "20% 0%"],
562 ["right 80u1 top", "right 80u1 top 0%"],
563
564 ////// [ keyword percent | keyword percent], [ keyword percent | keyword lengt h],
565 ////// [ keyword length | keyword length], [ keyword length | keyword percent] x 5 keywords
566 ["left 50% top 50%", "50% 50%"],
567 ["left 50% top 50u1", "50% 50u1"],
568 ["left 50% bottom 70%", "50% 30%"],
569 ["left 50% bottom 70u1", "left 50% bottom 70u1"],
570 ["left 50u1 top 50%", "50u1 50%"],
571 ["left 50u1 top 50u1", "50u1 50u1"],
572 ["left 50u1 bottom 70%", "50u1 30%"],
573 ["left 50u1 bottom 70u1", "left 50u1 bottom 70u1"],
574
575 ["top 50% left 50%", "50% 50%"],
576 ["top 50% left 50u1", "50u1 50%"],
577 ["top 50% right 80%", "20% 50%"],
578 ["top 50% right 80u1", "right 80u1 top 50%"],
579 ["top 50u1 left 50%", "50% 50u1"],
580 ["top 50u1 left 50u1", "50u1 50u1"],
581 ["top 50u1 right 80%", "20% 50u1"],
582 ["top 50u1 right 80u1", "right 80u1 top 50u1"],
583
584 ["bottom 70% left 50%", "50% 30%"],
585 ["bottom 70% left 50u1", "50u1 30%"],
586 ["bottom 70% right 80%", "20% 30%"],
587 ["bottom 70% right 80u1", "right 80u1 top 30%"],
588 ["bottom 70u1 left 50%", "left 50% bottom 70u1"],
589 ["bottom 70u1 left 50u1", "left 50u1 bottom 70u1"],
590 ["bottom 70u1 right 80%", "left 20% bottom 70u1"],
591 ["bottom 70u1 right 80u1", "right 80u1 bottom 70u1"],
592
593 ["right 80% top 50%", "20% 50%"],
594 ["right 80% top 50u1", "20% 50u1"],
595 ["right 80% bottom 70%", "20% 30%"],
596 ["right 80% bottom 70u1", "left 20% bottom 70u1"],
597 ["right 80u1 top 50%", "right 80u1 top 50%"],
598 ["right 80u1 top 50u1", "right 80u1 top 50u1"],
599 ["right 80u1 bottom 70%", "right 80u1 top 30%"],
600 ["right 80u1 bottom 70u1", "right 80u1 bottom 70u1"],
601 ];
602
603 var invalidPositions = [
604 ////// [ keyword | percent ], [ keyword | length ], [ percent | keyword ], [ len gth | keyword ] x 5 keywords
605 "50% left",
606 "50px left",
607 "top 50%",
608 "80% right",
609 "80px right",
610 "bottom 70%",
611 "bottom 70px",
612
613 ////// [ keyword | keyword percent ], [ keyword | keyword length ] x 5 keywords
614 "center center 60%",
615 "center center 60px",
616
617 "left center 60%",
618 "left center 60px",
619 "left right 80%",
620 "left right 80px",
621 "left left 50%",
622 "left left 50px",
623
624 "top center 60%",
625 "top center 60px",
626 "top bottom 80%",
627 "top bottom 80px",
628 "top top 50%",
629 "top top 50px",
630
631 "bottom center 60%",
632 "bottom center 60px",
633 "bottom top 50%",
634 "bottom top 50px",
635 "bottom bottom 50%",
636 "bottom bottom 50px",
637
638 "right center 60%",
639 "right center 60px",
640 "right left 50%",
641 "right left 50px",
642 "right right 70%",
643 "right right 70px",
644
645 ////// [ keyword percent | keyword], [ keyword length | keyword ] x 5 keywords
646 "center 60% top",
647 "center 60px top",
648 "center 60% bottom",
649 "center 60px bottom",
650 "center 60% left",
651 "center 60px left",
652 "center 60% right",
653 "center 60px right",
654 "center 60% center",
655 "center 60px center",
656
657 "left 50% right",
658 "left 50px right",
659 "left 50% left",
660 "left 50px left",
661
662 "top 50% bottom",
663 "top 50px bottom",
664 "top 50% top",
665 "top 50px top",
666
667 "bottom 70% top",
668 "bottom 70px top",
669 "bottom 70% bottom",
670 "bottom 70px bottom",
671
672 "right 80% left",
673 "right 80px left",
674
675 ////// [ keyword percent | keyword percent], [ keyword percent | keyword lengt h],
676 ////// [ keyword length | keyword length], [ keyword length | keyword percent] x 5 keywords
677 "center 60% top 50%",
678 "center 60% top 50px",
679 "center 60% bottom 70%",
680 "center 60% bottom 70px",
681 "center 60% left 50%",
682 "center 60% left 50px",
683 "center 60% right 70%",
684 "center 60% right 70px",
685 "center 60% center 65%",
686 "center 60% center 65px",
687 "center 60px top 50%",
688 "center 60px top 50px",
689 "center 60px bottom 70%",
690 "center 60px bottom 70px",
691 "center 60px left 50%",
692 "center 60px left 50px",
693 "center 60px right 70%",
694 "center 60px right 70px",
695 "center 60px center 65%",
696 "center 60px center 65px",
697
698 "left 50% center 60%",
699 "left 50% center 60px",
700 "left 50% right 80%",
701 "left 50% right 80px",
702 "left 50% left 50%",
703 "left 50% left 50px",
704 "left 50px center 60%",
705 "left 50px center 60px",
706 "left 50px right 80%",
707 "left 50px right 80px",
708 "left 50px left 50%",
709 "left 50px left 50px",
710
711 "top 50% center 60%",
712 "top 50% center 60px",
713 "top 50% bottom 50%",
714 "top 50% bottom 50px",
715 "top 50% top 50%",
716 "top 50% top 50px",
717 "top 50px center 60%",
718 "top 50px center 60px",
719 "top 50px bottom 70%",
720 "top 50px bottom 70px",
721 "top 50px top 50%",
722 "top 50px top 50px",
723
724 "bottom 70% center 60%",
725 "bottom 70% center 60px",
726 "bottom 70% top 50%",
727 "bottom 70% top 50px",
728 "bottom 70% bottom 50%",
729 "bottom 70% bottom 50px",
730 "bottom 70px center 60%",
731 "bottom 70px center 60px",
732 "bottom 70px top 50%",
733 "bottom 70px top 50px",
734 "bottom 70px bottom 50%",
735 "bottom 70px bottom 50px",
736
737 "right 80% center 60%",
738 "right 80% center 60px",
739 "right 80% left 50%",
740 "right 80% left 50px",
741 "right 80% right 85%",
742 "right 80% right 85px",
743 "right 80px center 60%",
744 "right 80px center 60px",
745 "right 80px left 50%",
746 "right 80px left 50px",
747 "right 80px right 85%",
748 "right 80px right 85px"
749 ];
750
751 // valid radii values for circle + ellipse
752 // [value, expected_inline, [expected_computed?]]
753 var validCircleRadii = [
754 ['', 'at 50% 50%', 'at 50% 50%'],
755 ['50u1', '50u1 at 50% 50%'],
756 ['50%', '50% at 50% 50%'],
757 ['closest-side', 'at 50% 50%'],
758 ['farthest-side', 'farthest-side at 50% 50%']
759 ]
760 var validEllipseRadii = [
761 ['', 'at 50% 50%', 'at 50% 50%'],
762 ['50u1', '50u1 at 50% 50%', '50u1 at 50% 50%'],
763 ['50%', '50% at 50% 50%', '50% at 50% 50%'],
764 ['closest-side', 'at 50% 50%', 'at 50% 50%'],
765 ['farthest-side', 'farthest-side at 50% 50%', 'farthest-side at 50% 50%'],
766 ['50u1 100u1', '50u1 100u1 at 50% 50%'],
767 ['100u1 100px', '100u1 100px at 50% 50%'],
768 ['25% 50%', '25% 50% at 50% 50%'],
769 ['50u1 25%', '50u1 25% at 50% 50%'],
770 ['25% 50u1', '25% 50u1 at 50% 50%'],
771 ['25% closest-side', '25% at 50% 50%'],
772 ['25u1 closest-side', '25u1 at 50% 50%'],
773 ['closest-side 75%', 'closest-side 75% at 50% 50%'],
774 ['closest-side 75u1', 'closest-side 75u1 at 50% 50%'],
775 ['25% farthest-side', '25% farthest-side at 50% 50%'],
776 ['25u1 farthest-side', '25u1 farthest-side at 50% 50%'],
777 ['farthest-side 75%', 'farthest-side 75% at 50% 50%'],
778 ['farthest-side 75u1', 'farthest-side 75u1 at 50% 50%'],
779 ['closest-side closest-side', 'at 50% 50%'],
780 ['farthest-side farthest-side', 'farthest-side farthest-side at 50% 50%'],
781 ['closest-side farthest-side', 'closest-side farthest-side at 50% 50%'],
782 ['farthest-side closest-side', 'farthest-side at 50% 50%']
783 ]
784
785 var validInsets = [
786 ["One arg - u1", "10u1"],
787 ["One arg - u2", "10u2"],
788 ["Two args - u1 u1", "10u1 20u1"],
789 ["Two args - u1 u2", "10u1 20u2"],
790 ["Two args - u2 u1", "10u2 20u1"],
791 ["Two args - u2 u2", "10u2 20u2"],
792 ["Three args - u1 u1 u1", "10u1 20u1 30u1"],
793 ["Three args - u1 u1 u2", "10u1 20u1 30u2"],
794 ["Three args - u1 u2 u1", "10u1 20u2 30u1"],
795 ["Three args - u1 u2 u2 ", "10u1 20u2 30u2"],
796 ["Three args - u2 u1 u1", "10u2 20u1 30u1"],
797 ["Three args - u2 u1 u2 ", "10u2 20u1 30u2"],
798 ["Three args - u2 u2 u1 ", "10u2 20u2 30u1"],
799 ["Three args - u2 u2 u2 ","10u2 20u2 30u2"],
800 ["Four args - u1 u1 u1 u1", "10u1 20u1 30u1 40u1"],
801 ["Four args - u1 u1 u1 u2", "10u1 20u1 30u1 40u2"],
802 ["Four args - u1 u1 u2 u1", "10u1 20u1 30u2 40u1"],
803 ["Four args - u1 u1 u2 u2", "10u1 20u1 30u2 40u2"],
804 ["Four args - u1 u2 u1 u1", "10u1 20u2 30u1 40u1"],
805 ["Four args - u1 u2 u1 u2", "10u1 20u2 30u1 40u2"],
806 ["Four args - u1 u2 u2 u1", "10u1 20u2 30u2 40u1"],
807 ["Four args - u1 u2 u2 u2", "10u1 20u2 30u2 40u2"],
808 ["Four args - u2 u1 u1 u1", "10u2 20u1 30u1 40u1"],
809 ["Four args - u2 u1 u1 u2", "10u2 20u1 30u1 40u2"],
810 ["Four args - u2 u1 u2 u1", "10u2 20u1 30u2 40u1"],
811 ["Four args - u2 u1 u2 u2", "10u2 20u1 30u2 40u2"],
812 ["Four args - u2 u2 u1 u1", "10u2 20u2 30u1 40u1"],
813 ["Four args - u2 u2 u1 u2", "10u2 20u2 30u1 40u2"],
814 ["Four args - u2 u2 u2 u1", "10u2 20u2 30u2 40u1"],
815 ["Four args - u2 u2 u2 u2", "10u2 20u2 30u2 40u2"]
816 ]
817
818 var validPolygons = [
819 ["One vertex - u1 u1", "10u1 20u1"],
820 ["One vertex - u1 u2", "10u1 20u2"],
821 ["Two vertices - u1 u1, u1 u1", "10u1 20u1, 30u1 40u1"],
822 ["Two vertices - u1 u1, u2 u2", "10u1 20u1, 30u2 40u2"],
823 ["Two vertices - u2 u2, u1 u1", "10u2 20u2, 30u1 40u1"],
824 ["Two vertices - u1 u2, u2 u1", "10u1 20u2, 30u2 40u1"],
825 ["Three vertices - u1 u1, u1 u1, u1 u1", "10u1 20u1, 30u1 40u1, 50u1 60u1"],
826 ["Three vertices - u2 u2, u2 u2, u2 u2", "10u2 20u2, 30u2 40u2, 50u2 60u2"],
827 ["Three vertices - u3 u3, u3 u3, u3 u3", "10u3 20u3, 30u3 40u3, 50u3 60u3"],
828 ["Three vertices - u1 u1, u2 u2, u3 u3", "10u1 20u1, 30u2 40u2, 50u3 60u3"],
829 ["Three vertices - u3 u3, u1, u1, u2 u2", "10u3 20u3, 30u1 40u1, 50u2 60u2"] ,
830 ]
831
832 // [test value, expected property value, expected computed style]
833 var calcTestValues = [
834 ["calc(10in)", "calc(10in)", "960px"],
835 ["calc(10in + 20px)", "calc(980px)", "980px"],
836 ["calc(30%)", "calc(30%)", "30%"],
837 ["calc(100%/4)", "calc(25%)", "25%"],
838 ["calc(25%*3)", "calc(75%)", "75%"],
839 // These following two test cases represent an either/or situation in the sp ec
840 // computed value is always supposed to be, at most, a tuple of a length and a percentage.
841 // the computed value of a ‘calc()’ expression can be represented as either a number or a tuple
842 // of a dimension and a percentage.
843 // http://www.w3.org/TR/css3-values/#calc-notation
844 ["calc(25%*3 - 10in)", "calc(75% - 10in)", ["calc(75% - 960px)", "calc(-960p x + 75%)"]],
845 ["calc((12.5%*6 + 10in) / 4)", "calc((75% + 10in) / 4)", ["calc((75% + 960px ) / 4)", "calc(240px + 18.75%)"]]
846 ]
847
848 return {
849 testInlineStyle: testInlineStyle,
850 testComputedStyle: testComputedStyle,
851 testShapeMarginInlineStyle: testShapeMarginInlineStyle,
852 testShapeMarginComputedStyle: testShapeMarginComputedStyle,
853 testShapeThresholdInlineStyle: testShapeThresholdInlineStyle,
854 testShapeThresholdComputedStyle: testShapeThresholdComputedStyle,
855 buildTestCases: buildTestCases,
856 buildRadiiTests: buildRadiiTests,
857 buildPositionTests: buildPositionTests,
858 buildInsetTests: buildInsetTests,
859 buildPolygonTests: buildPolygonTests,
860 generateInsetRoundCases: generateInsetRoundCases,
861 buildCalcTests: buildCalcTests,
862 validUnits: validUnits,
863 calcTestValues: calcTestValues,
864 roundResultStr: roundResultStr
865 }
866 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698