OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>@viewport CSSOM - set descriptor values</title> |
| 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script> |
| 8 if (window.testRunner) { |
| 9 testRunner.enableFixedLayoutMode(true); |
| 10 internals.settings.setViewportEnabled(true); |
| 11 } |
| 12 </script> |
| 13 <style> |
| 14 @viewport { |
| 15 width: 200px; |
| 16 } |
| 17 </style> |
| 18 </head> |
| 19 <body> |
| 20 <div id="log"></div> |
| 21 <script> |
| 22 test(function(){ |
| 23 assert_equals(document.styleSheets[0].cssRules.length, 1, "Rule is f
ound"); |
| 24 assert_equals(document.styleSheets[0].cssRules[0].type, CSSRule.VIEW
PORT_RULE, "Rule is of type @viewport"); |
| 25 }, "@viewport rule exists"); |
| 26 |
| 27 var rule = document.styleSheets[0].cssRules[0]; |
| 28 |
| 29 test(function(){ |
| 30 rule.style.width = "400px"; |
| 31 assert_equals(rule.style.minWidth, "400px", "min-width is now 400px"
); |
| 32 }, "Setting width shorthand sets min-width"); |
| 33 |
| 34 test(function(){ |
| 35 rule.style.height = "900px"; |
| 36 assert_equals(rule.style.maxHeight, "900px", "max-height is now 900p
x"); |
| 37 }, "Setting height shorthand sets max-height"); |
| 38 |
| 39 test(function(){ |
| 40 rule.style.cssText = "width: 300px; height: 700px"; |
| 41 assert_equals(rule.style.minWidth, "300px", "min-width is now 300px"
); |
| 42 assert_equals(rule.style.maxHeight, "700px", "max-height is now 700p
x"); |
| 43 }, "Setting cssText of ViewportRule.style parses width/height as shortha
nds"); |
| 44 |
| 45 test(function(){ |
| 46 document.styleSheets[0].insertRule("@viewport { width: 600px; height
: 200px }", 0); |
| 47 rule = document.styleSheets[0].cssRules[0]; |
| 48 assert_equals(rule.style.minWidth, "600px", "min-width is now 600px"
); |
| 49 assert_equals(rule.style.maxHeight, "200px", "max-height is now 200p
x"); |
| 50 }, "Inserting @viewport rule parses width/height as shorthands"); |
| 51 </script> |
| 52 </body> |
| 53 </html> |
OLD | NEW |