style_media.html (1372B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>HTML Test: The style information must be applied to the environment specified by the media attribute</title> 6 <link rel="author" title="Intel" href="http://www.intel.com/"> 7 <link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-style-media"> 8 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-style-element"> 9 <script src="/resources/testharness.js"></script> 10 <script src="/resources/testharnessreport.js"></script> 11 <style> 12 #test { 13 width: 100px; 14 } 15 </style> 16 <style id="style"> 17 #test { 18 width: 50px; 19 } 20 </style> 21 </head> 22 <body> 23 <div id="log"></div> 24 <div id="test"></div> 25 <script> 26 test(function() { 27 var testElement = document.getElementById("test"); 28 var style = document.getElementById("style"); 29 var width1, width2; 30 31 width1 = window.getComputedStyle(testElement)["width"]; 32 assert_equals(width1, "50px", "The style should be applied."); 33 34 style.media = "print"; 35 width2 = window.getComputedStyle(testElement)["width"]; 36 assert_equals(width2, "100px", "The style should not be applied."); 37 }, "The style information must be applied to the environment specified by the media attribute"); 38 </script> 39 </body> 40 </html>