Skip to content

Commit 205a47a

Browse files
andruudmoz-wptsync-bot
authored andcommitted
Bug 1945776 [wpt PR 50483] - [functions] Detect cycles between local variables, a=testonly
Automatic update from web-platform-tests [functions] Detect cycles between local variables This is now fairly easy to do by extending the CycleElem type introduced in CL:6176920. Both attributes (used by attr()) and locals need the AtomicString type; we can distinguish between the two cases using a StrongAlias. Note that this CL follows the behavior described in Issue 11500, not what the spec currently says. Therefore, the test is marked as tentative. w3c/csswg-drafts#11500 Bug: 325504770 Change-Id: I5a00e03175f0446a0ec6e6ba771253b4ea5f48e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6190327 Commit-Queue: Anders Hartvoll Ruud <[email protected]> Reviewed-by: Munira Tursunova <[email protected]> Cr-Commit-Position: refs/heads/main@{#1415484} -- wpt-commits: c5dda19e7580e26e7f5e538af095fdff241c9301 wpt-pr: 50483
1 parent 672837c commit 205a47a

File tree

1 file changed

+178
-0
lines changed

1 file changed

+178
-0
lines changed
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<!DOCTYPE html>
2+
<title>Custom Functions: Handling cycles</title>
3+
<link rel="help" href="https://drafts.csswg.org/css-mixins-1/#cycles">
4+
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/11500">
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="resources/utils.js"></script>
8+
9+
<div id=target></div>
10+
<div id=main></div>
11+
12+
<!-- To pass, a test must produce matching computed values for --actual and
13+
--expected on #target. -->
14+
15+
<!-- Locals / Arguments -->
16+
17+
<template data-name="Local with self-cycle">
18+
<style>
19+
@function --f() {
20+
--x: var(--x);
21+
result: var(--x, PASS);
22+
}
23+
#target {
24+
--actual: --f();
25+
--expected: PASS;
26+
}
27+
</style>
28+
</template>
29+
30+
<template data-name="Cycle reference without fallback makes result invalid">
31+
<style>
32+
@function --f() {
33+
--x: var(--x);
34+
result: var(--x);
35+
}
36+
#target {
37+
--actual: --f();
38+
/* --expected: <guaranteed-invalid> */
39+
}
40+
</style>
41+
</template>
42+
43+
<template data-name="Local with self-cycle in fallback">
44+
<style>
45+
@function --f() {
46+
--y: FAIL;
47+
--x: var(--y, var(--x));
48+
result: var(--x, PASS);
49+
}
50+
#target {
51+
--actual: --f();
52+
--expected: PASS;
53+
}
54+
</style>
55+
</template>
56+
57+
<template data-name="Local shadowing cyclic property --x">
58+
<style>
59+
/* The _properties_ --x and --y are in a cycle.
60+
However, the _local_ --x is not a cycle with anything. */
61+
@function --f() {
62+
--x: var(--y, PASS);
63+
result: var(--x);
64+
}
65+
#target {
66+
--x: var(--y);
67+
--y: var(--x);
68+
--actual: --f();
69+
--expected: PASS;
70+
}
71+
</style>
72+
</template>
73+
74+
<template data-name="Local shadowing cyclic outer local --x ">
75+
<style>
76+
/* The locals --x and --y are in a cycle in --f(). */
77+
@function --f() {
78+
--x: var(--y);
79+
--y: var(--x);
80+
result: --g();
81+
}
82+
@function --g() {
83+
--x: var(--y, PASS); /* Shadows outer --x. */
84+
result: var(--x);
85+
}
86+
#target {
87+
--actual: --f();
88+
--expected: PASS;
89+
}
90+
</style>
91+
</template>
92+
93+
<template data-name="Arguments shadowing cyclic properties">
94+
<style>
95+
@function --f(--x, --y) {
96+
result: var(--x) var(--y);
97+
}
98+
#target {
99+
--x: var(--y);
100+
--y: var(--x);
101+
--actual: --f(PASS-x, PASS-y);
102+
--expected: PASS-x PASS-y;
103+
}
104+
</style>
105+
</template>
106+
107+
<template data-name="Observing property cycle locally">
108+
<style>
109+
@function --f() {
110+
result: var(--x, PASS-x) var(--x, PASS-y);
111+
}
112+
#target {
113+
--x: var(--y);
114+
--y: var(--x);
115+
--actual: --f();
116+
--expected: PASS-x PASS-y;
117+
}
118+
</style>
119+
</template>
120+
121+
<template data-name="Using cyclic values with no fallback">
122+
<style>
123+
@function --f() {
124+
--y: var(--x, 1);
125+
--x: var(--y, 3);
126+
result: var(--x) var(--y);
127+
}
128+
#target {
129+
--actual: --f();
130+
/* --expected: <guaranteed-invalid> */
131+
}
132+
</style>
133+
</template>
134+
135+
<template data-name="Self-cycle in non-used local variable">
136+
<style>
137+
@function --f() {
138+
--x: var(--x);
139+
result: PASS;
140+
}
141+
#target {
142+
--actual: --f();
143+
--expected: PASS;
144+
}
145+
</style>
146+
</template>
147+
148+
<template data-name="Using cyclic value in unused fallback">
149+
<style>
150+
@function --f() {
151+
--x: PASS;
152+
result: var(--x, var(--y));
153+
}
154+
#target {
155+
--y: var(--y);
156+
--actual: --f();
157+
--expected: PASS;
158+
}
159+
</style>
160+
</template>
161+
162+
<template data-name="Using cyclic value in unused fallback (local)">
163+
<style>
164+
@function --f() {
165+
--x: PASS;
166+
--y: var(--y);
167+
result: var(--x, var(--y));
168+
}
169+
#target {
170+
--actual: --f();
171+
--expected: PASS;
172+
}
173+
</style>
174+
</template>
175+
176+
<script>
177+
test_all_templates();
178+
</script>

0 commit comments

Comments
 (0)