summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-cascade/scope-visited-cssom.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-cascade/scope-visited-cssom.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-cascade/scope-visited-cssom.html')
-rw-r--r--testing/web-platform/tests/css/css-cascade/scope-visited-cssom.html314
1 files changed, 314 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-cascade/scope-visited-cssom.html b/testing/web-platform/tests/css/css-cascade/scope-visited-cssom.html
new file mode 100644
index 0000000000..aba4b752b2
--- /dev/null
+++ b/testing/web-platform/tests/css/css-cascade/scope-visited-cssom.html
@@ -0,0 +1,314 @@
+<!DOCTYPE html>
+<title>@scope - :visited and CSSOM</title>
+<link rel="help" href="https://drafts.csswg.org/css-cascade-6/#scoped-styles">
+<link rel="help" href="https://drafts.csswg.org/selectors-4/#link">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<main id=main></main>
+
+<style>
+ :where(:visited, :link), :where(div) {
+ background-color: white;
+ }
+</style>
+
+<!--
+ Both #visited and #unvisited should appear to be in an unvisited state
+ through getComputedStyle.
+-->
+
+<!-- :visited/:link in scoped selector -->
+
+<template id=test_link>
+ <style>
+ @scope (main) {
+ :link { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""></a>
+ <a id=unvisited href="x"></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_link.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)');
+ assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)');
+}, ':link as scoped selector');
+</script>
+
+<template id=test_visited>
+ <style>
+ @scope (main) {
+ :visited { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""></a>
+ <a id=unvisited href="x"></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_visited.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)');
+ assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)');
+}, ':visited as scoped selector');
+</script>
+
+<template id=test_not_link>
+ <style>
+ @scope (main) {
+ :not(:link) { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""></a>
+ <a id=unvisited href="x"></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_not_link.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)');
+ assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)');
+}, ':not(:link) as scoped selector');
+</script>
+
+<template id=test_not_visited>
+ <style>
+ @scope (main) {
+ :not(:visited) { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""></a>
+ <a id=unvisited href="x"></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_not_visited.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)');
+ assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)');
+}, ':not(:visited) as scoped selector');
+</script>
+
+<!-- :visited/:link in root -->
+
+<template id=test_link_root>
+ <style>
+ @scope (main :link) {
+ div { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""><div></div></a>
+ <a id=unvisited href="x"><div></div></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_link_root.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited.firstElementChild).backgroundColor, 'rgb(0, 128, 0)');
+ assert_equals(getComputedStyle(unvisited.firstElementChild).backgroundColor, 'rgb(0, 128, 0)');
+}, ':link as scoping root');
+</script>
+
+<template id=test_visited_root>
+ <style>
+ @scope (main :visited) {
+ div { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""><div></div></a>
+ <a id=unvisited href="x"><div></div></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_visited_root.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited.firstElementChild).backgroundColor, 'rgb(255, 255, 255)');
+ assert_equals(getComputedStyle(unvisited.firstElementChild).backgroundColor, 'rgb(255, 255, 255)');
+}, ':visited as scoping root');
+</script>
+
+<template id=test_not_visited_root>
+ <style>
+ @scope (main :not(:visited)) {
+ div { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""><div></div></a>
+ <a id=unvisited href="x"><div></div></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_not_visited_root.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited.firstElementChild).backgroundColor, 'rgb(0, 128, 0)');
+ assert_equals(getComputedStyle(unvisited.firstElementChild).backgroundColor, 'rgb(0, 128, 0)');
+}, ':not(:visited) as scoping root');
+</script>
+
+<template id=test_not_link_root>
+ <style>
+ @scope (main :not(:link)) {
+ div { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""><div></div></a>
+ <a id=unvisited href="x"><div></div></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_not_link_root.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited.firstElementChild).backgroundColor, 'rgb(255, 255, 255)');
+ assert_equals(getComputedStyle(unvisited.firstElementChild).backgroundColor, 'rgb(255, 255, 255)');
+}, ':not(:link) as scoping root');
+</script>
+
+<!-- :visited/:link in scoping root, with inner :scope -->
+
+<template id=test_link_root_scope>
+ <style>
+ @scope (main :link) {
+ :scope { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""></a>
+ <a id=unvisited href="x"></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_link_root_scope.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)');
+ assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)');
+}, ':link as scoping root, :scope');
+</script>
+
+<template id=test_visited_root_scope>
+ <style>
+ @scope (main :visited) {
+ :scope { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""></a>
+ <a id=unvisited href="x"></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_visited_root_scope.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)');
+ assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)');
+}, ':visited as scoping root, :scope');
+</script>
+
+<template id=test_not_visited_root_scope>
+ <style>
+ @scope (main :not(:visited)) {
+ :scope { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""></a>
+ <a id=unvisited href="x"></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_not_visited_root_scope.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)');
+ assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)');
+}, ':not(:visited) as scoping root, :scope');
+</script>
+
+<template id=test_not_link_root_scope>
+ <style>
+ @scope (main :not(:link)) {
+ :scope { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""></a>
+ <a id=unvisited href="x"></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_not_link_root_scope.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)');
+ assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)');
+}, ':not(:link) as scoping root, :scope');
+</script>
+
+<!-- :visited/:link in scoping limit -->
+
+<template id=test_link_scoping_limit>
+ <style>
+ @scope (main) to (:link) {
+ * { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""></a>
+ <a id=unvisited href="x"></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_link_scoping_limit.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)');
+ assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)');
+}, ':link as scoping limit');
+</script>
+
+<template id=test_visited_scoping_limit>
+ <style>
+ @scope (main) to (:visited) {
+ * { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""></a>
+ <a id=unvisited href="x"></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_visited_scoping_limit.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)');
+ assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)');
+}, ':visited as scoping limit');
+</script>
+
+<template id=test_not_link_scoping_limit>
+ <style>
+ @scope (main) to (:not(:link)) {
+ * { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""></a>
+ <a id=unvisited href="x"></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_not_link_scoping_limit.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(0, 128, 0)');
+ assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(0, 128, 0)');
+}, ':not(:link) as scoping limit');
+</script>
+
+<template id=test_not_visited_scoping_limit>
+ <style>
+ @scope (main) to (:not(:visited)) {
+ * { background-color: green; }
+ }
+ </style>
+ <a id=visited href=""></a>
+ <a id=unvisited href="x"></a>
+</template>
+<script>
+test((t) => {
+ main.append(test_not_visited_scoping_limit.content.cloneNode(true));
+ t.add_cleanup(() => main.replaceChildren());
+ assert_equals(getComputedStyle(visited).backgroundColor, 'rgb(255, 255, 255)');
+ assert_equals(getComputedStyle(unvisited).backgroundColor, 'rgb(255, 255, 255)');
+}, ':not(:visited) as scoping limit');
+</script>