Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/css/resources/font-variation-settings-css-support.js |
| diff --git a/third_party/WebKit/LayoutTests/fast/css/resources/font-variation-settings-css-support.js b/third_party/WebKit/LayoutTests/fast/css/resources/font-variation-settings-css-support.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b549e6cfddb9175daf8a61ced8d5de52dbd00728 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/css/resources/font-variation-settings-css-support.js |
| @@ -0,0 +1,75 @@ |
| +var validWriteExpectations = [ "normal", |
| + "'abcd' 1", |
| + "'abcd' 0, 'efgh' 1", |
| + "'abcd' 0.3, 'efgh' 1.4", |
|
Timothy Loh
2016/12/08 03:36:05
Let's have at least one test with a negative value
drott
2016/12/09 10:25:49
Added.
|
| + "'abcd' 0.3, 'abcd' 0.4, 'abcd' 0.5, 'abcd' 0.6, 'abcd' 0.7" ]; |
| + |
| +var writeInvalidExpectations = ["none", |
| + "'abc' 1", |
| + "'abcde' 1", |
| + "", |
| + "'abc¡' 1", |
| + "normal, 'abcd' 0", |
| + "'abcd'", |
| + "'abcd' 1 2", |
| + "1 1", |
| + "0 0", |
| + "a a"]; |
| + |
| +setup({ explicit_done: true }); |
| + |
| +function styleAndComputedStyleReadback() { |
| + |
| + var testContainer = document.createElement("div"); |
| + document.body.appendChild(testContainer); |
| + |
| + for (validValue of validWriteExpectations) { |
| + testContainer.style.fontVariationSettings = validValue; |
| + test(function() { |
| + assert_equals(testContainer.style.fontVariationSettings, validValue); |
| + assert_equals(getComputedStyle(testContainer).fontVariationSettings, validValue); |
| + }, 'font-variation-settings value ' + validValue + ' should be equal when reading it back from style and getComputedstyle.'); |
| + } |
| + |
| + document.body.removeChild(testContainer); |
| +} |
| + |
| +function testInheritance() { |
| + var testContainer = document.createElement('div'); |
| + var testContainerChild = document.createElement('div'); |
| + testContainer.appendChild(testContainerChild); |
| + document.body.appendChild(testContainer); |
| + |
| + for (validValue of validWriteExpectations) { |
| + testContainer.style.fontVariationSettings = validValue; |
| + test(function() { |
| + assert_equals(testContainerChild.style.fontVariationSettings, ''); |
| + assert_equals(getComputedStyle(testContainerChild).fontVariationSettings, validValue); |
| + }, 'font-variation-settings value ' + validValue + ' should be inherited to computed style of child.'); |
| + } |
| + document.body.removeChild(testContainer); |
| +} |
| + |
| +function validWriteTests() { |
| + for (validValue of validWriteExpectations) { |
| + test(function() { |
| + assert_true(CSS.supports('font-variation-settings', validValue)); |
| + }, 'Value ' + validValue + ' valid for property font-variation-settings'); |
| + } |
| +} |
| + |
| +function invalidWriteTests() { |
| + for (invalidValue of writeInvalidExpectations) { |
| + test(function() { |
| + assert_false(CSS.supports('font-variation-settings', invalidValue)); |
| + }, 'Value ' + invalidValue + ' invalid for property font-variation-settings'); |
| + } |
| +} |
| + |
| +window.addEventListener('load', function() { |
| + validWriteTests(); |
| + invalidWriteTests(); |
| + styleAndComputedStyleReadback(); |
| + testInheritance(); |
| + done(); |
| +}); |