Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[css-typed-om] Add per-property test for 'opacity'.
This patch adds tests for opacity, which only takes a <number> and whose computed value is clamped to [0, 1]. This is the <number> property so we had to add to the test harness. Bug: 545318 Change-Id: I5689843188811c8c14c062a60deb0a8c580de3d9
- Loading branch information
1 parent
3023e57
commit 8c62741
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
css/css-typed-om/the-stylepropertymap/properties/opacity.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>'opacity' property</title> | ||
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-get"> | ||
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-set"> | ||
<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#property-stle-value-normalization"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="../../resources/testhelper.js"></script> | ||
<script src="resources/testsuite.js"></script> | ||
<body> | ||
<div id="log"></div> | ||
<script> | ||
'use strict'; | ||
|
||
function assert_is_equal_with_clamping(input, result) { | ||
const number = input.to('number'); | ||
|
||
if (number.value < 0) | ||
assert_style_value_equals(result, new CSSUnitValue(0, 'number')); | ||
else if (number.value > 1) | ||
assert_style_value_equals(result, new CSSUnitValue(1, 'number')); | ||
else | ||
assert_style_value_equals(result, input); | ||
} | ||
|
||
runPropertyTests('opacity', [ | ||
{ | ||
syntax: '<number>', | ||
computed: assert_is_equal_with_clamping | ||
}, | ||
]); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters