summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/cssom-view/matchMedia.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/cssom-view/matchMedia.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/cssom-view/matchMedia.html')
-rw-r--r--testing/web-platform/tests/css/cssom-view/matchMedia.html79
1 files changed, 79 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/cssom-view/matchMedia.html b/testing/web-platform/tests/css/cssom-view/matchMedia.html
new file mode 100644
index 0000000000..0a94c9850c
--- /dev/null
+++ b/testing/web-platform/tests/css/cssom-view/matchMedia.html
@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<meta name="flags" content="dom">
+<title>CSS Test: CSSOM View matchMedia and MediaQueryList</title>
+<link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com">
+<link rel="help" href="https://www.w3.org/TR/cssom-view-1/#dom-window-matchmedia">
+<link rel="help" href="https://www.w3.org/TR/cssom-view-1/#the-mediaquerylist-interface">
+<link rel="help" href="https://www.w3.org/TR/cssom-1/#serializing-media-queries">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/matchMedia.js"></script>
+<div id="log"></div>
+<script>
+"use strict";
+
+test(() => {
+ assert_equals(
+ typeof window.matchMedia,
+ "function",
+ "FATAL ERROR: The window.matchMedia function is not present. The rest of the testsuite will fail to run."
+ );
+}, "window.matchMedia is a function");
+
+test(() => {
+ const mql = window.matchMedia("all");
+ assert_equals(mql.media, "all");
+ assert_true(mql.matches);
+}, 'window.matchMedia("all") matches');
+
+test(() => {
+ const mql = window.matchMedia("");
+ assert_equals(mql.media, "");
+ assert_true(mql.matches);
+}, 'window.matchMedia("") matches');
+
+test(() => {
+ const mql = window.matchMedia("(min-width: 1px)");
+ assert_equals(mql.media, "(min-width: 1px)");
+ assert_true(mql.matches);
+}, 'window.matchMedia("(min-width: 1px)") matches');
+
+test(() => {
+ const mql = window.matchMedia("::");
+ assert_true(mql instanceof MediaQueryList);
+ assert_equals(mql.media, "not all");
+ assert_false(mql.matches);
+}, 'media query with syntax error is serialized as "not all"');
+
+promise_test(async t => {
+ const iframe = await createIFrame(t, 200);
+ const mql = iframe.contentWindow.matchMedia("(max-width: 199px), all and (min-width: 200px)");
+ assert_equals(mql.media, "(max-width: 199px), (min-width: 200px)");
+ assert_true(mql.matches);
+}, 'iframe.matchMedia("(max-width: 199px), all and (min-width: 200px)") is serialized w/o "all"');
+
+promise_test(async t => {
+ const iframe = await createIFrame(t);
+ const mql = iframe.contentWindow.matchMedia("(min-aspect-ratio: 1/1)");
+ assert_true(mql.matches);
+}, 'iframe.matchMedia("(min-aspect-ratio: 1/1)") matches');
+
+promise_test(async t => {
+ const iframe = await createIFrame(t, 200);
+ const mql = iframe.contentWindow.matchMedia("(width: 200px)");
+ assert_true(mql.matches);
+}, 'iframe.matchMedia("(width: 200px)") matches');
+
+promise_test(async t => {
+ const iframe = await createIFrame(t, 200, 100);
+ const mql = iframe.contentWindow.matchMedia("(max-height: 50px)");
+ assert_false(mql.matches);
+}, 'iframe.matchMedia("(max-height: 50px)") matches');
+
+promise_test(async t => {
+ const iframe = await createIFrame(t, 200, 100);
+ const mql = iframe.contentWindow.matchMedia("(min-width: 150px)");
+ assert_true(mql.matches);
+}, 'iframe.matchMedia("(min-width: 150px)") matches');
+</script>