summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-cascade/layer-cssom-order-reverse-at-property.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/css-cascade/layer-cssom-order-reverse-at-property.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-cascade/layer-cssom-order-reverse-at-property.html')
-rw-r--r--testing/web-platform/tests/css/css-cascade/layer-cssom-order-reverse-at-property.html94
1 files changed, 94 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-cascade/layer-cssom-order-reverse-at-property.html b/testing/web-platform/tests/css/css-cascade/layer-cssom-order-reverse-at-property.html
new file mode 100644
index 0000000000..dfa6bbfcfb
--- /dev/null
+++ b/testing/web-platform/tests/css/css-cascade/layer-cssom-order-reverse-at-property.html
@@ -0,0 +1,94 @@
+<!DOCTYPE html>
+<title>CSS Cascade Layers: @property rule invalidation on layer order changes</title>
+<link rel="help" href="https://drafts.csswg.org/css-cascade-5/#layering">
+<link rel="author" href="mailto:xiaochengh@chromium.org">
+<link rel="stylesheet" href="/fonts/ahem.css">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+#reference {
+ color: green;
+ --foo: green;
+}
+</style>
+
+<div id=target>Lorem ipsum</div>
+<div id=reference>Lorem ipsum</div>
+
+<script>
+const testCases = [
+ {
+ title: 'Insert layer invalidates @property',
+ sheets: [
+ '',
+ `
+ @layer first {
+ @property --foo {
+ syntax: '<color>';
+ inherits: false;
+ initial-value: green;
+ }
+ }
+ @layer second {
+ @property --foo {
+ syntax: '<color>';
+ inherits: false;
+ initial-value: red;
+ }
+ }
+ `,
+ ],
+ update: function(sheets) {
+ sheets[0].insertRule('@layer second {}', 0);
+ },
+ property: '--foo',
+ },
+ {
+ title: 'Delete layer invalidates @property',
+ sheets: [
+ '@layer second {}',
+ `
+ @layer first {
+ @property --foo {
+ syntax: '<color>';
+ inherits: false;
+ initial-value: red;
+ }
+ }
+ @layer second {
+ @property --foo {
+ syntax: '<color>';
+ inherits: false;
+ initial-value: green;
+ }
+ }
+ `,
+ ],
+ update: function(sheets) {
+ sheets[0].deleteRule(0);
+ },
+ property: '--foo',
+ },
+];
+
+for (let testCase of testCases) {
+ test(testObj => {
+ const styleElements = testCase.sheets.map(sheet => {
+ const element = document.createElement('style');
+ element.appendChild(document.createTextNode(sheet));
+ document.head.appendChild(element);
+ return element;
+ });
+ testObj.add_cleanup(() => {
+ for (let element of styleElements)
+ element.remove();
+ });
+
+ const sheets = styleElements.map(element => element.sheet);
+ testCase.update(sheets);
+ const actual = getComputedStyle(target).getPropertyValue(testCase.property);
+ const expected = getComputedStyle(reference).getPropertyValue(testCase.property);
+ assert_equals(actual, expected);
+ }, testCase.title);
+}
+</script>