Skip to content

Commit

Permalink
[css-typed-om] CSSUnitValue.unit should be readonly
Browse files Browse the repository at this point in the history
CSSUnitValue.unit should be immutable to prevent cyclic references

Bug: 803687
Change-Id: I35f79ec2491277fcb2d02ce85a2e9c6ecd8c3a07
  • Loading branch information
hwanseung authored and chromium-wpt-export-bot committed Feb 2, 2018
1 parent e9fad52 commit 0fecc3b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,10 @@
assert_equals(result.toString(), '3.14px');
}, 'CSSKeywordValue from DOMString modified by "value" setter serializes correctly');

test(() => {
let result = CSSStyleValue.parse('width', '1px');
result.unit = 's';
assert_equals(result.toString(), '1s');
}, 'CSSKeywordValue from DOMString modified by "unit" setter serializes correctly');

test(t => {
let result = createInlineStyleMap(t, 'width: 1px').get('width');
result.value = 3.14;
assert_equals(result.toString(), '3.14px');
}, 'CSSKeywordValue from CSSOM modified by "value" setter serializes correctly');

test(t => {
let result = createInlineStyleMap(t, 'width: 1px').get('width');
result.unit = 's';
assert_equals(result.toString(), '1s');
}, 'CSSKeywordValue from CSSOM modified by "unit" setter serializes correctly');

</script>
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,12 @@
}, 'Constructing CSSUnitValue with ' + desc + ' as the unit throws a TypeError');
}

for (const {unit, desc} of gInvalidTestUnits) {
test(() => {
let result = new CSSUnitValue(0, 'px');
assert_throws(new TypeError(), () => result.unit = unit);
assert_equals(result.unit, 'px');
}, 'Updating CSSUnitValue.unit with ' + desc + ' throws a TypeError');
}

for (const unit of gValidUnits) {
test(() => {
const result = new CSSUnitValue(-3.14, unit);
assert_equals(result.value, -3.14);
assert_equals(result.unit, unit.toLowerCase());
}, 'CSSUnitValue can be constructed with ' + unit);

test(() => {
let result = new CSSUnitValue(-3.14, 'px');
result.unit = unit
assert_equals(result.unit, unit.toLowerCase());
}, 'CSSUnitValue.unit can be updated to ' + unit);
}

</script>

0 comments on commit 0fecc3b

Please sign in to comment.