Test passes if there is a filled green square and no red.
+
+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/mediaqueries/negation-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/mediaqueries/negation-001.html
new file mode 100644
index 00000000000..eccfaa4338b
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/mediaqueries/negation-001.html
@@ -0,0 +1,41 @@
+
+
+
+ Test: support for negated conditions in Media Queries
+
+
+
+
+
+
+
+
Test passes if there is a filled green square and no red.
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/mediaqueries/negation-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/mediaqueries/negation-002.html
new file mode 100644
index 00000000000..ca5fb74dfbf
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/mediaqueries/negation-002.html
@@ -0,0 +1,44 @@
+
+
+
+ Test: It is invalid to mix "and" and "or" and "not" at the same level of a media query.
+
+
+
+
+
+
+
+
Test passes if there is a filled green square and no red.
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/mediaqueries/viewport-script-dynamic.html b/Tests/LibWeb/Ref/input/wpt-import/css/mediaqueries/viewport-script-dynamic.html
new file mode 100644
index 00000000000..57d06ecfcf3
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/mediaqueries/viewport-script-dynamic.html
@@ -0,0 +1,20 @@
+
+
+CSS Test: Meta viewport after a script and stylesheets
+
+
+
+
+
+
+
+
+
Should be green
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini
index f108ecc40e9..9f52a2eb34b 100644
--- a/Tests/LibWeb/TestConfig.ini
+++ b/Tests/LibWeb/TestConfig.ini
@@ -99,6 +99,38 @@ Ref/input/wpt-import/css/CSS2/floats/floats-wrap-bfc-001-right-overflow.xht
Ref/input/wpt-import/css/CSS2/floats/floats-placement-003.html
Ref/input/wpt-import/css/CSS2/floats/floats-wrap-top-below-bfc-003l.xht
+; WPT media queries ref-tests that currently fail
+Ref/input/wpt-import/css/mediaqueries/aspect-ratio-001.html
+Ref/input/wpt-import/css/mediaqueries/aspect-ratio-002.html
+Ref/input/wpt-import/css/mediaqueries/aspect-ratio-003.html
+Ref/input/wpt-import/css/mediaqueries/aspect-ratio-004.html
+Ref/input/wpt-import/css/mediaqueries/aspect-ratio-005.html
+Ref/input/wpt-import/css/mediaqueries/aspect-ratio-006.html
+Ref/input/wpt-import/css/mediaqueries/device-aspect-ratio-002.html
+Ref/input/wpt-import/css/mediaqueries/device-aspect-ratio-003.html
+Ref/input/wpt-import/css/mediaqueries/device-aspect-ratio-004.html
+Ref/input/wpt-import/css/mediaqueries/device-aspect-ratio-006.html
+Ref/input/wpt-import/css/mediaqueries/min-width-001.xht
+Ref/input/wpt-import/css/mediaqueries/min-width-tables-001.html
+Ref/input/wpt-import/css/mediaqueries/mq-calc-sign-function-003.html
+Ref/input/wpt-import/css/mediaqueries/mq-deprecated-001.html
+Ref/input/wpt-import/css/mediaqueries/mq-gamut-001.html
+Ref/input/wpt-import/css/mediaqueries/mq-gamut-002.html
+Ref/input/wpt-import/css/mediaqueries/mq-gamut-003.html
+Ref/input/wpt-import/css/mediaqueries/mq-gamut-004.html
+Ref/input/wpt-import/css/mediaqueries/mq-gamut-005.html
+Ref/input/wpt-import/css/mediaqueries/mq-invalid-media-type-002.html
+Ref/input/wpt-import/css/mediaqueries/mq-invalid-media-type-003.html
+Ref/input/wpt-import/css/mediaqueries/mq-invalid-media-type-004.html
+Ref/input/wpt-import/css/mediaqueries/mq-invalid-media-type-layer-001.html
+Ref/input/wpt-import/css/mediaqueries/mq-negative-range-001.html
+Ref/input/wpt-import/css/mediaqueries/mq-negative-range-002.html
+Ref/input/wpt-import/css/mediaqueries/mq-range-001.html
+Ref/input/wpt-import/css/mediaqueries/negation-001.html
+Ref/input/wpt-import/css/mediaqueries/negation-002.html
+Ref/input/wpt-import/css/mediaqueries/prefers-color-scheme-svg-as-image.html
+Ref/input/wpt-import/css/mediaqueries/viewport-script-dynamic.html
+
; WPT ref-tests that are flaky due to unknown reasons
Ref/input/wpt-import/css/css-contain/contain-size-replaced-006.html
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/aspect-ratio-serialization.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/aspect-ratio-serialization.txt
new file mode 100644
index 00000000000..e1a324894b9
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/aspect-ratio-serialization.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass serializes with spaces around the integer.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/display-mode.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/display-mode.txt
new file mode 100644
index 00000000000..c6d1c03e499
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/display-mode.txt
@@ -0,0 +1,23 @@
+Harness status: OK
+
+Found 17 tests
+
+11 Pass
+6 Fail
+Pass Should be known: '(display-mode)'
+Pass Should be known: '(display-mode: standalone)'
+Pass Should be known: '(display-mode: browser)'
+Pass Should be known: '(display-mode: minimal-ui)'
+Pass Should be known: '(display-mode: fullscreen)'
+Fail Should be known: '(display-mode: picture-in-picture)'
+Fail Should be parseable: '(display-mode: 0)'
+Pass Should be unknown: '(display-mode: 0)'
+Fail Should be parseable: '(display-mode: none)'
+Pass Should be unknown: '(display-mode: none)'
+Fail Should be parseable: '(display-mode: random)'
+Pass Should be unknown: '(display-mode: random)'
+Fail Should be parseable: '(display-mode: 10px)'
+Pass Should be unknown: '(display-mode: 10px)'
+Fail Should be parseable: '(display-mode: 1%)'
+Pass Should be unknown: '(display-mode: 1%)'
+Pass Check that display-mode evaluates to true in the boolean context
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/dynamic-range.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/dynamic-range.txt
new file mode 100644
index 00000000000..fc36c49cd02
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/dynamic-range.txt
@@ -0,0 +1,29 @@
+Harness status: OK
+
+Found 23 tests
+
+15 Pass
+8 Fail
+Pass Should be known: '(dynamic-range: standard)'
+Pass Should be known: '(dynamic-range: high)'
+Pass Should be known: '(video-dynamic-range: standard)'
+Pass Should be known: '(video-dynamic-range: high)'
+Pass Should be known: '(dynamic-range)'
+Pass Should be known: '(video-dynamic-range)'
+Fail Should be parseable: '(dynamic-range: 0)'
+Pass Should be unknown: '(dynamic-range: 0)'
+Fail Should be parseable: '(dynamic-range: 10px)'
+Pass Should be unknown: '(dynamic-range: 10px)'
+Fail Should be parseable: '(dynamic-range: invalid)'
+Pass Should be unknown: '(dynamic-range: invalid)'
+Fail Should be parseable: '(video-dynamic-range: 0)'
+Pass Should be unknown: '(video-dynamic-range: 0)'
+Fail Should be parseable: '(video-dynamic-range: 10px)'
+Pass Should be unknown: '(video-dynamic-range: 10px)'
+Fail Should be parseable: '(video-dynamic-range: invalid)'
+Pass Should be unknown: '(video-dynamic-range: invalid)'
+Fail Check that dynamic-range evaluates to false in the boolean context
+Fail Check that video-dynamic-range evaluates to false in the boolean context
+Pass Check that dynamic-range always matches 'standard'
+Pass Check that video-dynamic-range always matches 'standard'
+Pass Check that video-dynamic-range is not 'invalid'
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/forced-colors.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/forced-colors.txt
new file mode 100644
index 00000000000..b69202d4358
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/forced-colors.txt
@@ -0,0 +1,22 @@
+Harness status: OK
+
+Found 16 tests
+
+10 Pass
+6 Fail
+Pass Should be known: '(forced-colors)'
+Pass Should be known: '(forced-colors: none)'
+Pass Should be known: '(forced-colors: active)'
+Fail Should be parseable: '(forced-colors: 0)'
+Pass Should be unknown: '(forced-colors: 0)'
+Fail Should be parseable: '(forced-colors: no-preference)'
+Pass Should be unknown: '(forced-colors: no-preference)'
+Fail Should be parseable: '(forced-colors: 10px)'
+Pass Should be unknown: '(forced-colors: 10px)'
+Fail Should be parseable: '(forced-colors: active 0)'
+Pass Should be unknown: '(forced-colors: active 0)'
+Fail Should be parseable: '(forced-colors: none active)'
+Pass Should be unknown: '(forced-colors: none active)'
+Fail Should be parseable: '(forced-colors: active/none)'
+Pass Should be unknown: '(forced-colors: active/none)'
+Pass Check that none evaluates to false in the boolean context
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/inverted-colors.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/inverted-colors.txt
new file mode 100644
index 00000000000..aa05b8dc624
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/inverted-colors.txt
@@ -0,0 +1,21 @@
+Harness status: OK
+
+Found 15 tests
+
+10 Pass
+5 Fail
+Pass Should be known: '(inverted-colors)'
+Pass Should be known: '(inverted-colors: none)'
+Pass Should be known: '(inverted-colors: inverted)'
+Fail Should be parseable: '(inverted-colors: 0)'
+Pass Should be unknown: '(inverted-colors: 0)'
+Fail Should be parseable: '(inverted-colors: no-preference)'
+Pass Should be unknown: '(inverted-colors: no-preference)'
+Fail Should be parseable: '(inverted-colors: 10px)'
+Pass Should be unknown: '(inverted-colors: 10px)'
+Fail Should be parseable: '(inverted-colors: none inverted)'
+Pass Should be unknown: '(inverted-colors: none inverted)'
+Fail Should be parseable: '(inverted-colors: none/inverted)'
+Pass Should be unknown: '(inverted-colors: none/inverted)'
+Pass Check that none evaluates to false in the boolean context
+Pass Check that invalid evaluates to false
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/mq-dynamic-empty-children.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/mq-dynamic-empty-children.txt
new file mode 100644
index 00000000000..84afd867d85
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/mq-dynamic-empty-children.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Fail
+Fail Dynamic evaluation of media queries works fine in presence of empty media rule
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/mq-invalid-media-type-005.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/mq-invalid-media-type-005.txt
new file mode 100644
index 00000000000..a96cd9d760f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/mq-invalid-media-type-005.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass syntactical MQ keywords used as media types are a syntax error
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/mq-invalid-media-type-layer-002.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/mq-invalid-media-type-layer-002.txt
new file mode 100644
index 00000000000..32e9a03b93c
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/mq-invalid-media-type-layer-002.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass 'layer' used as media types is a syntax error
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/mq-unknown-feature-custom-property.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/mq-unknown-feature-custom-property.txt
new file mode 100644
index 00000000000..7aebb50e173
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/mq-unknown-feature-custom-property.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Fail
+Fail Serialization of : with custom property feature name and ident value
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/overflow-media-features.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/overflow-media-features.txt
new file mode 100644
index 00000000000..92f04bcb46d
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/overflow-media-features.txt
@@ -0,0 +1,34 @@
+Harness status: OK
+
+Found 28 tests
+
+20 Pass
+8 Fail
+Pass Should be known: '(overflow-inline)'
+Pass Should be known: '(overflow-inline: none)'
+Pass Should be known: '(overflow-inline: scroll)'
+Pass Should be parseable: 'overflow-inline'
+Fail Should be unknown: 'overflow-inline'
+Fail Should be parseable: '(overflow-inline: ?)'
+Pass Should be unknown: '(overflow-inline: ?)'
+Fail Should be parseable: '(overflow-inline: 10px)'
+Pass Should be unknown: '(overflow-inline: 10px)'
+Fail Should be parseable: '(overflow-inline: 0)'
+Pass Should be unknown: '(overflow-inline: 0)'
+Pass Should be known: '(overflow-block)'
+Pass Should be known: '(overflow-block: none)'
+Pass Should be known: '(overflow-block: scroll)'
+Pass Should be known: '(overflow-block: paged)'
+Pass Should be parseable: 'overflow-block'
+Fail Should be unknown: 'overflow-block'
+Fail Should be parseable: '(overflow-block: ?)'
+Pass Should be unknown: '(overflow-block: ?)'
+Fail Should be parseable: '(overflow-block: 10px)'
+Pass Should be unknown: '(overflow-block: 10px)'
+Fail Should be parseable: '(overflow-block: 0)'
+Pass Should be unknown: '(overflow-block: 0)'
+Pass Check that overflow-inline: scroll always matches non printing documents
+Pass Check that overflow-block: scroll always matches non printing documents
+Pass Check that overflow-inline: none doesn't match non printing documents
+Pass Check that overflow-block: none doesn't match non printing documents
+Pass Check that overflow-block: paged doesn't match non printing documents
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-color-scheme.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-color-scheme.txt
new file mode 100644
index 00000000000..06811477c49
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-color-scheme.txt
@@ -0,0 +1,24 @@
+Harness status: OK
+
+Found 18 tests
+
+11 Pass
+7 Fail
+Pass Should be known: '(prefers-color-scheme)'
+Pass Should be known: '(prefers-color-scheme: light)'
+Pass Should be known: '(prefers-color-scheme: dark)'
+Fail Should be parseable: '(prefers-color-scheme: 0)'
+Pass Should be unknown: '(prefers-color-scheme: 0)'
+Fail Should be parseable: '(prefers-color-scheme: none)'
+Pass Should be unknown: '(prefers-color-scheme: none)'
+Fail Should be parseable: '(prefers-color-scheme: 10px)'
+Pass Should be unknown: '(prefers-color-scheme: 10px)'
+Fail Should be parseable: '(prefers-color-scheme: dark 0)'
+Pass Should be unknown: '(prefers-color-scheme: dark 0)'
+Fail Should be parseable: '(prefers-color-scheme: dark light)'
+Pass Should be unknown: '(prefers-color-scheme: dark light)'
+Fail Should be parseable: '(prefers-color-scheme: light/dark)'
+Pass Should be unknown: '(prefers-color-scheme: light/dark)'
+Fail Should be parseable: '(prefers-color-scheme: no-preference)'
+Pass Should be unknown: '(prefers-color-scheme: no-preference)'
+Pass Check that prefer-color-scheme evaluates to true in the boolean context
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-contrast.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-contrast.txt
new file mode 100644
index 00000000000..294fe9f9a6d
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-contrast.txt
@@ -0,0 +1,32 @@
+Harness status: OK
+
+Found 26 tests
+
+18 Pass
+8 Fail
+Pass Should be known: '(prefers-contrast)'
+Pass Should be known: '(prefers-contrast: no-preference)'
+Pass Should be known: '(prefers-contrast: more)'
+Pass Should be known: '(prefers-contrast: less)'
+Pass Should be known: '(prefers-contrast: custom)'
+Fail Should be parseable: '(prefers-contrast: increase)'
+Pass Should be unknown: '(prefers-contrast: increase)'
+Fail Should be parseable: '(prefers-contrast: none)'
+Pass Should be unknown: '(prefers-contrast: none)'
+Fail Should be parseable: '(prefers-contrast: forced high)'
+Pass Should be unknown: '(prefers-contrast: forced high)'
+Fail Should be parseable: '(prefers-contrast: forced low)'
+Pass Should be unknown: '(prefers-contrast: forced low)'
+Fail Should be parseable: '(prefers-contrast > increase)'
+Pass Should be unknown: '(prefers-contrast > increase)'
+Pass Should be parseable: '(prefers-increased-contrast)'
+Pass Should be unknown: '(prefers-increased-contrast)'
+Pass Should be parseable: '(prefers-decreased-contrast)'
+Pass Should be unknown: '(prefers-decreased-contrast)'
+Fail Should be parseable: '(prefers-contrast: high)'
+Pass Should be unknown: '(prefers-contrast: high)'
+Fail Should be parseable: '(prefers-contrast: low)'
+Pass Should be unknown: '(prefers-contrast: low)'
+Fail Should be parseable: '(prefers-contrast: forced)'
+Pass Should be unknown: '(prefers-contrast: forced)'
+Pass Check boolean context evaluation.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-reduced-data.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-reduced-data.txt
new file mode 100644
index 00000000000..5ef984b6d25
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-reduced-data.txt
@@ -0,0 +1,23 @@
+Harness status: OK
+
+Found 17 tests
+
+11 Pass
+6 Fail
+Pass Should be known: '(prefers-reduced-data)'
+Pass Should be known: '(prefers-reduced-data: no-preference)'
+Pass Should be known: '(prefers-reduced-data: reduce)'
+Fail Should be parseable: '(prefers-reduced-data: 0)'
+Pass Should be unknown: '(prefers-reduced-data: 0)'
+Fail Should be parseable: '(prefers-reduced-data: none)'
+Pass Should be unknown: '(prefers-reduced-data: none)'
+Fail Should be parseable: '(prefers-reduced-data: 10px)'
+Pass Should be unknown: '(prefers-reduced-data: 10px)'
+Fail Should be parseable: '(prefers-reduced-data: no-preference reduce)'
+Pass Should be unknown: '(prefers-reduced-data: no-preference reduce)'
+Fail Should be parseable: '(prefers-reduced-data: reduced)'
+Pass Should be unknown: '(prefers-reduced-data: reduced)'
+Fail Should be parseable: '(prefers-reduced-data: no-preference/reduce)'
+Pass Should be unknown: '(prefers-reduced-data: no-preference/reduce)'
+Pass Check that no-preference evaluates to false in the boolean context
+Pass Check that invalid evaluates to false
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-reduced-motion.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-reduced-motion.txt
new file mode 100644
index 00000000000..48284135edf
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-reduced-motion.txt
@@ -0,0 +1,22 @@
+Harness status: OK
+
+Found 16 tests
+
+10 Pass
+6 Fail
+Pass Should be known: '(prefers-reduced-motion)'
+Pass Should be known: '(prefers-reduced-motion: no-preference)'
+Pass Should be known: '(prefers-reduced-motion: reduce)'
+Fail Should be parseable: '(prefers-reduced-motion: 0)'
+Pass Should be unknown: '(prefers-reduced-motion: 0)'
+Fail Should be parseable: '(prefers-reduced-motion: none)'
+Pass Should be unknown: '(prefers-reduced-motion: none)'
+Fail Should be parseable: '(prefers-reduced-motion: 10px)'
+Pass Should be unknown: '(prefers-reduced-motion: 10px)'
+Fail Should be parseable: '(prefers-reduced-motion: no-preference reduce)'
+Pass Should be unknown: '(prefers-reduced-motion: no-preference reduce)'
+Fail Should be parseable: '(prefers-reduced-motion: reduced)'
+Pass Should be unknown: '(prefers-reduced-motion: reduced)'
+Fail Should be parseable: '(prefers-reduced-motion: no-preference/reduce)'
+Pass Should be unknown: '(prefers-reduced-motion: no-preference/reduce)'
+Pass Check that no-preference evaluates to false in the boolean context
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-reduced-transparency.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-reduced-transparency.txt
new file mode 100644
index 00000000000..889d1cc6a64
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/prefers-reduced-transparency.txt
@@ -0,0 +1,23 @@
+Harness status: OK
+
+Found 17 tests
+
+11 Pass
+6 Fail
+Pass Should be known: '(prefers-reduced-transparency)'
+Pass Should be known: '(prefers-reduced-transparency: no-preference)'
+Pass Should be known: '(prefers-reduced-transparency: reduce)'
+Fail Should be parseable: '(prefers-reduced-transparency: 0)'
+Pass Should be unknown: '(prefers-reduced-transparency: 0)'
+Fail Should be parseable: '(prefers-reduced-transparency: none)'
+Pass Should be unknown: '(prefers-reduced-transparency: none)'
+Fail Should be parseable: '(prefers-reduced-transparency: 10px)'
+Pass Should be unknown: '(prefers-reduced-transparency: 10px)'
+Fail Should be parseable: '(prefers-reduced-transparency: no-preference reduce)'
+Pass Should be unknown: '(prefers-reduced-transparency: no-preference reduce)'
+Fail Should be parseable: '(prefers-reduced-transparency: reduced)'
+Pass Should be unknown: '(prefers-reduced-transparency: reduced)'
+Fail Should be parseable: '(prefers-reduced-transparency: no-preference/reduce)'
+Pass Should be unknown: '(prefers-reduced-transparency: no-preference/reduce)'
+Pass Check that no-preference evaluates to false in the boolean context
+Pass Check that invalid evaluates to false
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/relative-units-005.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/relative-units-005.txt
new file mode 100644
index 00000000000..46a7ffad522
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/relative-units-005.txt
@@ -0,0 +1,9 @@
+Harness status: OK
+
+Found 3 tests
+
+2 Pass
+1 Fail
+Pass ex unit in media queries should match initial font
+Pass ch unit in media queries should match initial font
+Fail ic unit in media queries should match initial font
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/scripting.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/scripting.txt
new file mode 100644
index 00000000000..f9397db2df0
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/scripting.txt
@@ -0,0 +1,18 @@
+Harness status: OK
+
+Found 12 tests
+
+9 Pass
+3 Fail
+Pass Should be known: '(scripting)'
+Pass Should be known: '(scripting: enabled)'
+Pass Should be known: '(scripting: initial-only)'
+Pass Should be known: '(scripting: none)'
+Fail Should be parseable: '(scripting: 0)'
+Pass Should be unknown: '(scripting: 0)'
+Fail Should be parseable: '(scripting: 10px)'
+Pass Should be unknown: '(scripting: 10px)'
+Fail Should be parseable: '(scripting: invalid)'
+Pass Should be unknown: '(scripting: invalid)'
+Pass Check that scripting currently matches 'enabled'
+Pass Check that scripting currently evaluates to true in the boolean context
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/update-media-feature.txt b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/update-media-feature.txt
new file mode 100644
index 00000000000..0dd1901c8dc
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/mediaqueries/update-media-feature.txt
@@ -0,0 +1,20 @@
+Harness status: OK
+
+Found 14 tests
+
+11 Pass
+3 Fail
+Pass Should be known: '(update)'
+Pass Should be known: '(update: none)'
+Pass Should be known: '(update: slow)'
+Pass Should be known: '(update: fast)'
+Fail Should be parseable: '(update: ?)'
+Pass Should be unknown: '(update: ?)'
+Fail Should be parseable: '(update: 10px)'
+Pass Should be unknown: '(update: 10px)'
+Fail Should be parseable: '(update: 0)'
+Pass Should be unknown: '(update: 0)'
+Pass Check that update: fast always matches fast displays
+Pass Check that update: slow doesn't match fast displays
+Pass Check that update: none doesn't match fast displays
+Pass Check that update always matches non printing documents
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/aspect-ratio-serialization.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/aspect-ratio-serialization.html
new file mode 100644
index 00000000000..1cdefb6e3ab
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/aspect-ratio-serialization.html
@@ -0,0 +1,13 @@
+
+
+CSS Media Queries Test: 'aspect-ratio' serializes with spaces around ' / '.
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/display-mode.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/display-mode.html
new file mode 100644
index 00000000000..fcc03618d8f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/display-mode.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/dynamic-range.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/dynamic-range.html
new file mode 100644
index 00000000000..1d6ee19328e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/dynamic-range.html
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/forced-colors.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/forced-colors.html
new file mode 100644
index 00000000000..3e5f4238914
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/forced-colors.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/inverted-colors.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/inverted-colors.html
new file mode 100644
index 00000000000..3233a526793
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/inverted-colors.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/mq-dynamic-empty-children.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/mq-dynamic-empty-children.html
new file mode 100644
index 00000000000..32aa055fc91
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/mq-dynamic-empty-children.html
@@ -0,0 +1,40 @@
+
+Dynamic evaluation of media queries works fine in presence of empty media rule
+
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/mq-invalid-media-type-005.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/mq-invalid-media-type-005.html
new file mode 100644
index 00000000000..dd614732230
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/mq-invalid-media-type-005.html
@@ -0,0 +1,45 @@
+
+
+
+Mediaqueries-3 test: parsing hanging-punctuation with invalid values
+
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/mq-invalid-media-type-layer-002.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/mq-invalid-media-type-layer-002.html
new file mode 100644
index 00000000000..9520ec95c42
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/mq-invalid-media-type-layer-002.html
@@ -0,0 +1,27 @@
+
+
+
+Mediaqueries-3 test: parsing hanging-punctuation with invalid values
+
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/mq-unknown-feature-custom-property.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/mq-unknown-feature-custom-property.html
new file mode 100644
index 00000000000..fca38bfb1d1
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/mq-unknown-feature-custom-property.html
@@ -0,0 +1,13 @@
+
+Media Queries Test: Custom property name as media feature name
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/overflow-media-features.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/overflow-media-features.html
new file mode 100644
index 00000000000..25547b24c0f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/overflow-media-features.html
@@ -0,0 +1,53 @@
+
+CSS Media Queries Test: overflow media features
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-color-scheme.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-color-scheme.html
new file mode 100644
index 00000000000..2c7a6119414
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-color-scheme.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-contrast.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-contrast.html
new file mode 100644
index 00000000000..8681c05151d
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-contrast.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-reduced-data.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-reduced-data.html
new file mode 100644
index 00000000000..2bcdf85bf8b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-reduced-data.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-reduced-motion.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-reduced-motion.html
new file mode 100644
index 00000000000..821d7d58602
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-reduced-motion.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-reduced-transparency.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-reduced-transparency.html
new file mode 100644
index 00000000000..6ce6f60385b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/prefers-reduced-transparency.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/relative-units-005.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/relative-units-005.html
new file mode 100644
index 00000000000..46689824ad3
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/relative-units-005.html
@@ -0,0 +1,29 @@
+
+CSS Media Queries Test: ex, ch, and ic from initial font
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/resources/matchmedia-utils.js b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/resources/matchmedia-utils.js
new file mode 100644
index 00000000000..327e8f69fe2
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/resources/matchmedia-utils.js
@@ -0,0 +1,76 @@
+'use strict';
+
+function query_is_css_parseable(query) {
+ const style = document.createElement('style');
+ style.type = 'text/css';
+ document.head.appendChild(style);
+
+ const sheet = style.sheet;
+ try {
+ sheet.insertRule("@media " + query + "{}", 0);
+ return sheet.cssRules.length == 1 &&
+ sheet.cssRules[0].media.mediaText != "not all";
+ } finally {
+ while (sheet.cssRules.length)
+ sheet.deleteRule(0);
+ style.remove();
+ }
+}
+
+function query_should_be_css_parseable(query) {
+ test(() => {
+ assert_true(query_is_css_parseable(query));
+ }, "Should be parseable in a CSS stylesheet: '" + query + "'");
+}
+
+function query_should_not_be_css_parseable(query) {
+ test(() => {
+ assert_false(query_is_css_parseable(query));
+ }, "Should not be parseable in a CSS stylesheet: '" + query + "'");
+}
+
+function query_is_js_parseable(query) {
+ // We cannot rely on whether a given feature is on or off, so only check the
+ // 'media' member of the result.
+ const match = window.matchMedia(query);
+ return match.media == query;
+}
+
+function query_should_be_js_parseable(query) {
+ test(() => {
+ assert_true(query_is_js_parseable(query));
+ }, "Should be parseable in JS: '" + query + "'");
+}
+
+function query_should_not_be_js_parseable(query) {
+ test(() => {
+ assert_false(query_is_js_parseable(query));
+ }, "Should not be parseable in JS: '" + query + "'");
+}
+
+function query_is_known(query) {
+ return window.matchMedia(`${query}, not all and ${query}`).matches;
+}
+
+function query_is_unknown(query) {
+ return !window.matchMedia(`${query}, not all and ${query}`).matches;
+}
+
+function query_should_be_known(query) {
+ test(() => {
+ assert_true(query_is_js_parseable(query), "Can parse with JS");
+ assert_true(query_is_css_parseable(query), "Can parse with CSS");
+ assert_true(query_is_known(query));
+ }, "Should be known: '" + query + "'");
+}
+
+function query_should_be_unknown(query) {
+ test(() => {
+ assert_true(query_is_js_parseable(query), "Can parse with JS");
+ assert_true(query_is_css_parseable(query), "Can parse with CSS");
+ }, "Should be parseable: '" + query + "'");
+
+ test(() => {
+ assert_true(query_is_unknown(query));
+ }, "Should be unknown: '" + query + "'");
+}
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/scripting.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/scripting.html
new file mode 100644
index 00000000000..d29497371c7
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/scripting.html
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/update-media-feature.html b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/update-media-feature.html
new file mode 100644
index 00000000000..0f39519a8e2
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/mediaqueries/update-media-feature.html
@@ -0,0 +1,38 @@
+
+CSS Media Query Test: update media feature
+
+
+
+
+
+
+