matchMedia-display-none-iframe.html (941B)
1 <!doctype html> 2 <title>CSS Test: matchMedia works on display: none iframes</title> 3 <link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-window-matchmedia"> 4 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> 5 <link rel="author" title="Mozilla" href="https://mozilla.org"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script> 9 function frameLoaded(frame) { 10 test(function() { 11 assert_true(frame.contentWindow.matchMedia("all").matches); 12 }, "matchMedia should work in display: none iframes"); 13 test(function() { 14 assert_true(frame.contentWindow.matchMedia("(min-width: 0)").matches); 15 assert_true(!frame.contentWindow.matchMedia("(min-width: 1px)").matches); 16 }, "matchMedia should assume a 0x0 viewport in display: none iframes"); 17 } 18 </script> 19 <iframe style="display: none" onload="frameLoaded(this)"></iframe>