bug453896_iframe.html (2209B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" 2 "http://www.w3.org/TR/html4/strict.dtd"> 3 <html lang="en-US"> 4 <head> 5 <title>Bug 453896 Test middle frame</title> 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 7 <meta http-equiv="Content-Style-Type" content="text/css"> 8 <script type="application/javascript"> 9 10 function run(test_window) 11 { 12 var subdoc = document.getElementById("subdoc").contentDocument; 13 var subwin = document.getElementById("subdoc").contentWindow; 14 var style = subdoc.getElementById("style"); 15 var iframe_style = document.getElementById("subdoc").style; 16 var body_cs = subdoc.defaultView.getComputedStyle(subdoc.body); 17 18 function query_applies(q) { 19 style.setAttribute("media", q); 20 return body_cs.getPropertyValue("text-decoration-line") == "underline"; 21 } 22 23 function should_apply(q) { 24 test_window.ok(query_applies(q), q + " should apply"); 25 } 26 27 function should_not_apply(q) { 28 test_window.ok(!query_applies(q), q + " should not apply"); 29 } 30 31 // in this test, assume the common underlying implementation is correct 32 let width_val = 157; // pick two not-too-round numbers 33 let height_val = 182; 34 iframe_style.width = width_val + "px"; 35 iframe_style.height = height_val + "px"; 36 for (let [feature, value] of 37 Object.entries({ "width": width_val, "height": height_val })) { 38 should_apply("all and (" + feature + ": " + value + "px)"); 39 should_not_apply("all and (" + feature + ": " + (value + 1) + "px)"); 40 should_not_apply("all and (" + feature + ": " + (value - 1) + "px)"); 41 } 42 43 iframe_style.width = "0"; 44 should_apply("all and (height)"); 45 should_not_apply("all and (width)"); 46 iframe_style.height = "0"; 47 should_not_apply("all and (height)"); 48 should_not_apply("all and (width)"); 49 should_apply("all and (device-height)"); 50 should_apply("all and (device-width)"); 51 iframe_style.width = width_val + "px"; 52 should_not_apply("all and (height)"); 53 should_apply("all and (width)"); 54 iframe_style.height = height_val + "px"; 55 should_apply("all and (height)"); 56 should_apply("all and (width)"); 57 } 58 59 </script> 60 </head> 61 <body> 62 63 <iframe id="subdoc" src="media_queries_iframe.html"></iframe> 64 65 </body> 66 </html>