Skip to content

Truly independent web browser

LibWeb: Test a universal selector after another simple selector

Andreas Kling5e9b902f769f
diff --git a/Tests/LibWeb/Text/expected/css/selector-universal-after-another-simple-selector.txt b/Tests/LibWeb/Text/expected/css/selector-universal-after-another-simple-selector.txt
new file mode 100644
index 00000000000..d47a855a131
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/selector-universal-after-another-simple-selector.txt
@@ -0,0 +1,23 @@
+*: parses, supports true
+*|*: parses, supports true
+|*: parses, supports true
+*.a: parses, supports true
+*[id]: parses, supports true
+*:first-child: parses, supports true
+*::before: parses, supports true
+**: parses, supports true
+div*: parses, supports true
+*div: SyntaxError, supports false
+*|**: parses, supports true
+*|*|*: parses, supports true
+|*|*: parses, supports true
+*|div*: parses, supports true
+.a*: parses, supports true
+#target*: parses, supports true
+[id]*: parses, supports true
+:first-child*: parses, supports true
+*[id]*: parses, supports true
+::before*: parses, supports true
+div *: parses, supports true
+div > *: parses, supports true
+color rgb(1, 0, 0), background-color rgb(2, 0, 0), margin-left 3px, margin-right 4px
diff --git a/Tests/LibWeb/Text/input/css/selector-universal-after-another-simple-selector.html b/Tests/LibWeb/Text/input/css/selector-universal-after-another-simple-selector.html
new file mode 100644
index 00000000000..51f304d5ba8
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/selector-universal-after-another-simple-selector.html
@@ -0,0 +1,24 @@
+<!doctype html>
+<style>
+ div* { color: rgb(1, 0, 0); }
+ .a* { background-color: rgb(2, 0, 0); }
+ ** { margin-left: 3px; }
+ *.a { margin-right: 4px; }
+</style>
+<div id="target" class="a"></div>
+<script src="../include.js"></script>
+<script>
+ test(() => {
+ for (const selector of ["*", "*|*", "|*", "*.a", "*[id]", "*:first-child", "*::before", "**", "div*", "*div", "*|**", "*|*|*", "|*|*", "*|div*", ".a*", "#target*", "[id]*", ":first-child*", "*[id]*", "::before*", "div *", "div > *"]) {
+ let parsed = "parses";
+ try {
+ document.querySelector(selector);
+ } catch (error) {
+ parsed = error.name;
+ }
+ println(`${selector}: ${parsed}, supports ${CSS.supports(`selector(${selector})`)}`);
+ }
+ const style = getComputedStyle(document.getElementById("target"));
+ println(`color ${style.color}, background-color ${style.backgroundColor}, margin-left ${style.marginLeft}, margin-right ${style.marginRight}`);
+ });
+</script>