diff options
author | WPT Sync Bot <josh+wptsync@joshmatthews.net> | 2020-04-21 08:21:40 +0000 |
---|---|---|
committer | WPT Sync Bot <josh+wptsync@joshmatthews.net> | 2020-04-21 11:23:54 +0000 |
commit | 906e45aab01239d9393fa09d68a783e543fae1dc (patch) | |
tree | 9615730f707c85e4f0d75867941ff4a810797d3e /tests/wpt/web-platform-tests/css/css-logical | |
parent | d77bf218fafe84dc0eb8c2f148e27e906ac3e8c7 (diff) | |
download | servo-906e45aab01239d9393fa09d68a783e543fae1dc.tar.gz servo-906e45aab01239d9393fa09d68a783e543fae1dc.zip |
Update web-platform-tests to revision 9a6026305062c90d84a567d81434010dde6c6c22
Diffstat (limited to 'tests/wpt/web-platform-tests/css/css-logical')
-rw-r--r-- | tests/wpt/web-platform-tests/css/css-logical/getComputedStyle-listing.html | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/css/css-logical/getComputedStyle-listing.html b/tests/wpt/web-platform-tests/css/css-logical/getComputedStyle-listing.html new file mode 100644 index 00000000000..5970bcea631 --- /dev/null +++ b/tests/wpt/web-platform-tests/css/css-logical/getComputedStyle-listing.html @@ -0,0 +1,106 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<title>CSS Logical Properties: computed style listing</title> +<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com" /> +<link rel="help" href="https://drafts.csswg.org/css-logical/#margin-properties"> +<meta name="assert" content="This test checks that the logical properties are properly exposed in a computed CSSStyleDeclaration." /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<div id="log"></div> + +<script> +function hasProperty(object, property) { + // This checks the [[HasProperty]] internal method. + return property in object; +} + +function hasPropertyValue(object, property) { + // This checks the [[Get]] internal method. + return object[property] !== undefined; +} + +function hasPropertyDescriptor(object, property) { + // This checks [[GetOwnProperty]], iterating the prototype chain. + while (object) { + if (Reflect.getOwnPropertyDescriptor(object, property)) { + return true; + } + object = Reflect.getPrototypeOf(object); + } + return false; +} + +function hasPropertyKey(object, property) { + // This checks [[OwnPropertyKeys]], iterating the prototype chain. + while (object) { + if (Reflect.ownKeys(object).includes(property)) { + return true; + } + object = Reflect.getPrototypeOf(object); + } + return false; +} + +function hasItem(object, item) { + // This checks the CSSStyleDeclaration::item WebIDL getter. + for (let i = 0; i < object.length; ++i) { + if (object.item(i) === item) { + return true; + } + } + return false; +} + +function check(property) { + const cs = getComputedStyle(document.body); + const camelCase = property.replace(/-(.)/g, (_, b) => b.toUpperCase()); + test(function() { + assert_true(hasProperty(cs, property) || hasProperty(cs, camelCase), + `The computed style has the property ${property} or ${camelCase}.`); + assert_true(hasPropertyValue(cs, property) || hasPropertyValue(cs, camelCase), + `The computed style has a value for for the property ${property} or ${camelCase}.`); + assert_true(hasPropertyDescriptor(cs, property) || hasPropertyDescriptor(cs, camelCase), + `The computed style has a property descriptor for ${property} or ${camelCase}.`); + assert_true(hasPropertyKey(cs, property) || hasPropertyKey(cs, camelCase), + `The computed style contains ${property} or ${camelCase} in the property list.`); + assert_true(hasItem(cs, property) || hasItem(cs, camelCase), + `The computed style contains the item ${property} or ${camelCase}.`); + }, property); +} + +check("border-block-end-color"); +check("border-block-end-style"); +check("border-block-end-width"); +check("border-block-start-color"); +check("border-block-start-style"); +check("border-block-start-width"); +check("border-inline-end-color"); +check("border-inline-end-style"); +check("border-inline-end-width"); +check("border-inline-start-color"); +check("border-inline-start-style"); +check("border-inline-start-width"); + +check("inset-block-start"); +check("inset-block-end"); +check("inset-inline-start"); +check("inset-inline-end"); + +check("margin-block-start"); +check("margin-block-end"); +check("margin-inline-start"); +check("margin-inline-end"); + +check("padding-block-start"); +check("padding-block-end"); +check("padding-inline-start"); +check("padding-inline-end"); + +check("block-size"); +check("inline-size"); +check("max-block-size"); +check("max-inline-size"); +check("min-block-size"); +check("min-inline-size"); +</script> |