diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /layout/inspector/tests/chrome/test_visited_style.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/inspector/tests/chrome/test_visited_style.html')
-rw-r--r-- | layout/inspector/tests/chrome/test_visited_style.html | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/layout/inspector/tests/chrome/test_visited_style.html b/layout/inspector/tests/chrome/test_visited_style.html new file mode 100644 index 0000000000..619e739959 --- /dev/null +++ b/layout/inspector/tests/chrome/test_visited_style.html @@ -0,0 +1,81 @@ +<!DOCTYPE html> +<html> +<head> +<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> +<style> +#target:visited, div { + color: lime; +} + +#target:link, div { + color: pink; +} +</style> +</head> +<body> + <a href="test" id="target">test-target</a> + + <script> + const VISITED_SELECTOR = "#target:visited"; + const LINK_SELECTOR = "#target:link"; + + const TEST_DATA = [ + { + description: "Test for visited style", + isVisitedTest: true, + validSelector: VISITED_SELECTOR, + invalidSelector: LINK_SELECTOR, + }, + { + description: "Test for unvisited style", + isVisitedTest: false, + validSelector: LINK_SELECTOR, + invalidSelector: VISITED_SELECTOR, + }, + ]; + + function start() { + const target = document.getElementById("target"); + + for (const { description, isVisitedTest, + validSelector, invalidSelector } of TEST_DATA) { + info(description); + + const rules = + InspectorUtils.getCSSStyleRules(target, undefined, isVisitedTest); + ok(getRule(rules, validSelector), + `Rule of ${validSelector} is in rules`); + ok(!getRule(rules, invalidSelector), + `Rule of ${invalidSelector} is not in rules`); + + const targetRule = getRule(rules, validSelector); + const isTargetSelectorMatched = InspectorUtils.selectorMatchesElement( + target, targetRule, 0, undefined, isVisitedTest + ); + const isDivSelectorMatched = InspectorUtils.selectorMatchesElement( + target, targetRule, 1, undefined, isVisitedTest + ); + ok(isTargetSelectorMatched, + `${validSelector} selector is matched for the rule`); + ok(!isDivSelectorMatched, + "div selector is not matched for the rule"); + } + + SimpleTest.finish(); + } + + function getRule(rules, selector) { + for (const rule of rules) { + if (rule.selectorText.startsWith(selector)) { + return rule; + } + } + return null; + } + + SimpleTest.waitForExplicitFinish(); + document.addEventListener('DOMContentLoaded', start); + </script> +</body> +</html> |