Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
|
eseidel
2014/03/25 13:37:13
We haven't historically had license headers on our
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 window.expect = (function() { | |
| 5 var testElement = document.getElementById('target'); | |
| 6 | |
| 7 function assert_equals_or_matches(actual, expected, description) { | |
| 8 return expected instanceof RegExp ? | |
| 9 assert_regexp_match(actual, expected, description) : | |
| 10 assert_equals(actual, expected, description); | |
| 11 } | |
| 12 return function expect(property, camelProperty, input) { | |
| 13 return { | |
| 14 parsesAs: function(output) { | |
| 15 test(function() { | |
| 16 assert_true(CSS.supports(property, input), 'CSS.supports'); | |
| 17 testElement.style[camelProperty] = input; | |
| 18 assert_equals(testElement.style[camelProperty], output); | |
| 19 }, '"' + property + ': ' + input + ';" should parse as "' + output + '"' ); | |
| 20 return this; | |
| 21 }, | |
| 22 isComputedTo: function(output) { | |
| 23 test(function() { | |
| 24 testElement.style[camelProperty] = input; | |
| 25 assert_equals_or_matches(getComputedStyle(testElement)[camelProperty], output); | |
| 26 }, '"' + property + ': ' + input + ';" should be computed to "' + output + '"'); | |
| 27 }, | |
| 28 isInvalid: function() { | |
| 29 test(function() { | |
| 30 assert_false(CSS.supports(property, input), 'CSS.supports'); | |
| 31 }, '"' + property + ': ' + input + ';" should be invalid'); | |
| 32 }, | |
| 33 }; | |
| 34 } | |
| 35 })(); | |
| OLD | NEW |