Bug 1376931 Part 5: Add test to verify that media queries with a resolution set to window.devicePixelRatio dppx match for all zoom values exposed by the UI.
MozReview-Commit-ID: Kr7J4ZkZ1hZ
--- a/dom/tests/mochitest/general/mochitest.ini
+++ b/dom/tests/mochitest/general/mochitest.ini
@@ -97,16 +97,17 @@ subsuite = clipboard
skip-if = toolkit == 'android' #TIMED_OUT
[test_for_of.html]
[test_framedhistoryframes.html]
[test_frameElementWrapping.html]
[test_img_mutations.html]
[test_interfaces.html]
[test_interfaces_secureContext.html]
scheme = https
+[test_media_queries_with_zoom.html]
[test_navigation_timing.html]
[test_network_events.html]
skip-if = true
# Disable this test until bug 795711 is fixed.
[test_offsets.html]
support-files = test_offsets.js
[test_outerHTML.html]
[test_outerHTML.xhtml]
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/general/test_media_queries_with_zoom.html
@@ -0,0 +1,52 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Media Queries with Zoom</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
+</head>
+
+<body>
+
+<div>Testing media queries with different zoom levels</div>
+
+<script type="application/javascript">
+
+const originalDPR = window.devicePixelRatio;
+const originalZoom = SpecialPowers.getFullZoom(window);
+
+const zoomsToTest = [
+300,
+240,
+200,
+170,
+150,
+133,
+120,
+110,
+100,
+90,
+80,
+67,
+50,
+30,
+];
+
+for (let i = 0; i < zoomsToTest.length; ++i) {
+ let zoomPercent = zoomsToTest[i];
+
+ let relativeZoom = originalZoom * zoomPercent / 100;
+ SpecialPowers.setFullZoom(window, relativeZoom);
+ let actualZoom = SpecialPowers.getDeviceFullZoom(window);
+ let targetDPR = (originalDPR * actualZoom);
+ let actualDPR = window.devicePixelRatio;
+ let mql = window.matchMedia(`(resolution: ${targetDPR}dppx)`);
+ ok(mql.matches, `At ${zoomPercent}% zoom, target ${targetDPR}dppx matches ${actualDPR}dppx.`);
+}
+
+// Reset the zoom when the test is done.
+SpecialPowers.setFullZoom(window, originalZoom);
+</script>
+
+</body>
+</html>