Skip to content

Commit 3a700f0

Browse files
lilleschromium-wpt-export-bot
authored andcommitted
Make readonly attributes on CSSFontFeatureValuesRule [SameObject]
This is based on the proposal in [1] and makes it straightforward to keep the CSSOM wrappers work for setting/getting including wrapper reattachments that happen when shared stylesheets are decoupled on modifications. [1] w3c/csswg-drafts#13953 Bug: 514445398, 515494291 Change-Id: I5436e4feeff3935f1999630d775ad34a8a26194f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7865910 Reviewed-by: Dominik Röttsches <drott@chromium.org> Commit-Queue: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1636821}
1 parent 16ae773 commit 3a700f0

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<title>CSS Fonts Test: CSSFontFeatureValuesMap is live and reflect changes</title>
3+
<link rel="help" href="https://drafts.csswg.org/css-fonts/#cssfontfeaturevaluesmap">
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<style>
7+
@font-feature-values MyFamily {
8+
@annotation { black-boxed: 3 }
9+
}
10+
</style>
11+
<!-- Two identical stylesheets exposes a stylesheet sharing issue in Chrome -->
12+
<style>
13+
@font-feature-values MyFamily {
14+
@annotation { circled: 1; black-boxed: 3; }
15+
}
16+
</style>
17+
<script>
18+
test(() => {
19+
const a1 = document.styleSheets[0].cssRules[0].annotation;
20+
a1.set("black-boxed", 42);
21+
const a2 = document.styleSheets[0].cssRules[0].annotation;
22+
assert_array_equals(a1.get("black-boxed"), [42]);
23+
assert_array_equals(a2.get("black-boxed"), [42]);
24+
}, "Two retreived maps for CSSFontFeatureValuesRule.annotation should reflect the same values");
25+
26+
test(() => {
27+
assert_array_equals(document.styleSheets[1].cssRules[0].annotation.get("black-boxed"), [3]);
28+
}, "The second stylesheet should not be affected by modifications in the first");
29+
30+
</script>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<title>CSS Fonts Test: CSSFontFeatureValuesRule SameObject test</title>
3+
<link rel="help" href="https://drafts.csswg.org/css-fonts/#om-fontfeaturevalues">
4+
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/13953">
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<style id="style">
8+
@font-feature-values TestFont {
9+
@annotation { a: 1; }
10+
@ornaments { b: 2; }
11+
@stylistic { c: 3; }
12+
@swash { d: 4; }
13+
@character-variant { e: 5; }
14+
@styleset { f: 6; }
15+
}
16+
</style>
17+
<script>
18+
test(() => {
19+
const style = document.getElementById('style');
20+
const rule = style.sheet.cssRules[0];
21+
assert_true(rule instanceof CSSFontFeatureValuesRule, "Should be CSSFontFeatureValuesRule");
22+
23+
const attributes = [
24+
'annotation',
25+
'ornaments',
26+
'stylistic',
27+
'swash',
28+
'characterVariant',
29+
'styleset'
30+
];
31+
32+
for (const attr of attributes) {
33+
const map1 = rule[attr];
34+
const map2 = rule[attr];
35+
assert_equals(map1, map2, `${attr} should return the same object`);
36+
}
37+
}, "CSSFontFeatureValuesMap attributes in CSSFontFeatureValuesRule should be [SameObject]");
38+
39+
</script>
40+

0 commit comments

Comments
 (0)