Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / style / test / test_mq_hover_and_pointer.html
blob40eaed5d0b5730ef59445ca31e1ad35957204df3
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=1035774
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 1035774</title>
9 <script src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1035774">Mozilla Bug 1035774</a>
14 <p id="display"></p>
15 <div id="content" style="display: none">
17 </div>
18 <pre id="test">
19 </pre>
20 <script>
22 const NO_POINTER = 0x00;
23 const COARSE_POINTER = 0x01;
24 const FINE_POINTER = 0x02;
25 const HOVER_CAPABLE_POINTER = 0x04;
27 var isAndroid = navigator.appVersion.includes("Android");
29 add_task(async () => {
30 await SpecialPowers.pushPrefEnv({
31 set: [ ['privacy.resistFingerprinting', true] ]
32 });
34 // When resistFingerprinting is enabled, we pretend that the system has a
35 // mouse pointer (or finger on mobile).
36 let invertIfAndroid = function(b) { return isAndroid ? !b : b; };
38 ok(!matchMedia("(pointer: none)").matches,
39 "Doesn't match (pointer: none)");
41 ok(matchMedia("(pointer)").matches, "Matches (pointer)");
43 ok(invertIfAndroid(!matchMedia("(pointer: coarse)").matches),
44 "Doesn't match (pointer: coarse)");
45 ok(invertIfAndroid(matchMedia("(pointer: fine)").matches), "Matches (pointer: fine)");
47 ok(invertIfAndroid(!matchMedia("(hover: none)").matches), "Doesn't match (hover: none)");
48 ok(invertIfAndroid(matchMedia("(hover: hover)").matches), "Matches (hover: hover)");
49 ok(invertIfAndroid(matchMedia("(hover)").matches), "Matches (hover)");
51 await SpecialPowers.flushPrefEnv();
52 });
54 add_task(async () => {
55 // No pointer.
56 await SpecialPowers.pushPrefEnv({
57 set: [ ['ui.primaryPointerCapabilities', NO_POINTER] ]
58 });
60 ok(matchMedia("(pointer: none)").matches, "Matches (pointer: none)");
61 ok(!matchMedia("(pointer: coarse)").matches,
62 "Doesn't match (pointer: coarse)");
63 ok(!matchMedia("(pointer: fine)").matches, "Doesn't match (pointer: fine)");
64 ok(!matchMedia("(pointer)").matches, "Matches (pointer)");
66 ok(matchMedia("(hover: none)").matches, "Matches (hover: none)");
67 ok(!matchMedia("(hover: hover)").matches, "Doesn't match (hover: hover)");
68 ok(!matchMedia("(hover)").matches, "Doesn't match (hover)");
69 });
71 add_task(async () => {
72 // Mouse type pointer.
73 await SpecialPowers.pushPrefEnv({
74 set: [ ['ui.primaryPointerCapabilities', FINE_POINTER | HOVER_CAPABLE_POINTER] ]
75 });
77 ok(!matchMedia("(pointer: none)").matches,
78 "Doesn't match (pointer: none)");
79 ok(!matchMedia("(pointer: coarse)").matches,
80 "Doesn't match (pointer: coarse)");
81 ok(matchMedia("(pointer: fine)").matches, "Matches (pointer: fine)");
82 ok(matchMedia("(pointer)").matches, "Matches (pointer)");
84 ok(!matchMedia("(hover: none)").matches, "Doesn't match (hover: none)");
85 ok(matchMedia("(hover: hover)").matches, "Matches (hover: hover)");
86 ok(matchMedia("(hover)").matches, "Matches (hover)");
87 });
89 add_task(async () => {
90 // Mouse type pointer.
91 await SpecialPowers.pushPrefEnv({
92 set: [ ['ui.primaryPointerCapabilities',
93 FINE_POINTER |
94 HOVER_CAPABLE_POINTER] ]
95 });
97 ok(!matchMedia("(pointer: none)").matches,
98 "Doesn't match (pointer: none)");
99 ok(!matchMedia("(pointer: coarse)").matches,
100 "Doesn't match (pointer: coarse)");
101 ok(matchMedia("(pointer: fine)").matches, "Matches (pointer: fine)");
102 ok(matchMedia("(pointer)").matches, "Matches (pointer)");
104 ok(!matchMedia("(hover: none)").matches, "Doesn't match (hover: none)");
105 ok(matchMedia("(hover: hover)").matches, "Matches (hover: hover)");
106 ok(matchMedia("(hover)").matches, "Matches (hover)");
109 add_task(async () => {
110 // Touch screen.
111 await SpecialPowers.pushPrefEnv({
112 set: [ ['ui.primaryPointerCapabilities', COARSE_POINTER] ]
115 ok(!matchMedia("(pointer: none)").matches, "Doesn't match (pointer: none)");
116 ok(matchMedia("(pointer: coarse)").matches, "Matches (pointer: coarse)");
117 ok(!matchMedia("(pointer: fine)").matches, "Doesn't match (pointer: fine)");
118 ok(matchMedia("(pointer)").matches, "Matches (pointer)");
120 ok(matchMedia("(hover: none)").matches, "Match (hover: none)");
121 ok(!matchMedia("(hover: hover)").matches, "Doesn't match (hover: hover)");
122 ok(!matchMedia("(hover)").matches, "Doesn't match (hover)");
125 </script>
126 </body>
127 </html>