| OLD | NEW |
| 1 var ParsingUtils = (function() { | 1 var ParsingUtils = (function() { |
| 2 function testInlineStyle(value, expected) { | 2 function testInlineStyle(value, expected) { |
| 3 var div = document.createElement('div'); | 3 var div = document.createElement('div'); |
| 4 div.style.setProperty('shape-outside', value); | 4 div.style.setProperty('shape-outside', value); |
| 5 var actual = div.style.getPropertyValue('shape-outside'); | 5 var actual = div.style.getPropertyValue('shape-outside'); |
| 6 assert_equals(actual, expected); | 6 assert_equals(actual, expected); |
| 7 } | 7 } |
| 8 | 8 |
| 9 function testComputedStyle(value, expected) { | 9 function testComputedStyle(value, expected) { |
| 10 var div = document.createElement('div'); | 10 var div = document.createElement('div'); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 assert_equals(actual, !expected ? '0' : expected); | 91 assert_equals(actual, !expected ? '0' : expected); |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Builds an array of test cases to send to testharness.js where one test case i
s: [name, actual, expected] | 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() | 96 // These test cases will verify results from testInlineStyle() or testComputedSt
yle() |
| 97 function buildTestCases(testCases, testType) { | 97 function buildTestCases(testCases, testType) { |
| 98 var results = []; | 98 var results = []; |
| 99 | 99 |
| 100 // If test_type isn't specified, test inline style | 100 // If test_type isn't specified, test inline style |
| 101 var type = typeof testType == 'undefined' ? 'invalid': testType; | 101 var type = typeof testType == 'undefined' ? 'empty_string': testType; |
| 102 | 102 |
| 103 testCases.forEach(function(test) { | 103 testCases.forEach(function(test) { |
| 104 oneTestCase = []; | 104 oneTestCase = []; |
| 105 | 105 |
| 106 // name - annotated by type (inline vs. computed) | 106 // name - annotated by type (empty_string vs. computed) |
| 107 if ( test.hasOwnProperty('name') ) { | 107 if ( test.hasOwnProperty('name') ) { |
| 108 oneTestCase.push(test['name'] +' - '+ type); | 108 oneTestCase.push(test['name'] +' - '+ type); |
| 109 } else { | 109 } else { |
| 110 // If test_name isn't specified, use the actual | 110 // If test_name isn't specified, use the actual |
| 111 oneTestCase.push(test['actual'] +' - '+ type); | 111 oneTestCase.push(test['actual'] +' - '+ type); |
| 112 } | 112 } |
| 113 | 113 |
| 114 // actual | 114 // actual |
| 115 oneTestCase.push(test['actual']) | 115 oneTestCase.push(test['actual']) |
| 116 | 116 |
| 117 // expected | 117 // expected |
| 118 if( type.indexOf('invalid') != -1 ){ | 118 if( type.indexOf('empty_string') != -1 ){ |
| 119 oneTestCase.push(null) | 119 oneTestCase.push('') |
| 120 } else if( type == 'inline' ) { | 120 } else if( type == 'inline' ) { |
| 121 oneTestCase.push(test['expected_inline']); | 121 oneTestCase.push(test['expected_inline']); |
| 122 } else if( type == 'computed' ){ | 122 } else if( type == 'computed' ){ |
| 123 oneTestCase.push( convertToPx(test['expected_computed']) ); | 123 oneTestCase.push( convertToPx(test['expected_computed']) ); |
| 124 } | 124 } |
| 125 results.push(oneTestCase); | 125 results.push(oneTestCase); |
| 126 }); | 126 }); |
| 127 return results; | 127 return results; |
| 128 } | 128 } |
| 129 | 129 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 testCase.push(expected); | 167 testCase.push(expected); |
| 168 results.push(testCase); | 168 results.push(testCase); |
| 169 } | 169 } |
| 170 }); | 170 }); |
| 171 } else { | 171 } else { |
| 172 invalidPositions.forEach(function(test) { | 172 invalidPositions.forEach(function(test) { |
| 173 var testValue = shape + '(at ' + setUnit(test, false, units) +')
'; | 173 var testValue = shape + '(at ' + setUnit(test, false, units) +')
'; |
| 174 testCase = new Array(); | 174 testCase = new Array(); |
| 175 testCase.push(testValue + ' is invalid'); | 175 testCase.push(testValue + ' is invalid'); |
| 176 testCase.push(testValue); | 176 testCase.push(testValue); |
| 177 testCase.push(null); | 177 testCase.push(""); |
| 178 results.push(testCase); | 178 results.push(testCase); |
| 179 }); | 179 }); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 return unique(results); | 182 return unique(results); |
| 183 } | 183 } |
| 184 | 184 |
| 185 function buildRadiiTests(shape, type, units) { | 185 function buildRadiiTests(shape, type, units) { |
| 186 var results = new Array(); | 186 var results = new Array(); |
| 187 var testUnits = typeof units == 'undefined' ? 'px': units; | 187 var testUnits = typeof units == 'undefined' ? 'px': units; |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 buildPositionTests: buildPositionTests, | 857 buildPositionTests: buildPositionTests, |
| 858 buildInsetTests: buildInsetTests, | 858 buildInsetTests: buildInsetTests, |
| 859 buildPolygonTests: buildPolygonTests, | 859 buildPolygonTests: buildPolygonTests, |
| 860 generateInsetRoundCases: generateInsetRoundCases, | 860 generateInsetRoundCases: generateInsetRoundCases, |
| 861 buildCalcTests: buildCalcTests, | 861 buildCalcTests: buildCalcTests, |
| 862 validUnits: validUnits, | 862 validUnits: validUnits, |
| 863 calcTestValues: calcTestValues, | 863 calcTestValues: calcTestValues, |
| 864 roundResultStr: roundResultStr | 864 roundResultStr: roundResultStr |
| 865 } | 865 } |
| 866 })(); | 866 })(); |
| OLD | NEW |