test_moz_document_serialization.html (1846B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id= 5 --> 6 <head> 7 <title>Test for Bug </title> 8 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> 10 <style type="text/css" id="style"></style> 11 </head> 12 <body> 13 <pre id="test"> 14 <script type="application/javascript"> 15 16 var rules = [ 17 { rule: "@-moz-document url(http://www.example.com/) {}" }, 18 { rule: "@-moz-document url('http://www.example.com/') {}" }, 19 { rule: '@-moz-document url("http://www.example.com/") {}' }, 20 { rule: "@-moz-document url-prefix('http://www.example.com/') {}" }, 21 { rule: '@-moz-document url-prefix("http://www.example.com/") {}' }, 22 { rule: "@-moz-document domain('example.com') {}" }, 23 { rule: '@-moz-document domain("example.com") {}' }, 24 { rule: "@-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {}" }, 25 { rule: '@-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {}' }, 26 ]; 27 28 SimpleTest.waitForExplicitFinish(); 29 30 var style = document.getElementById("style"); 31 var style_text = document.createTextNode(""); 32 style.appendChild(style_text); 33 34 for (var i in rules) { 35 var obj = rules[i]; 36 var rule = obj.rule; 37 38 style_text.data = rule; 39 is(style.sheet.cssRules.length, 1, "should have one rule"); 40 var ser1 = style.sheet.cssRules[0].cssText; 41 if ("is_canonical" in obj) { 42 is(ser1, rule, "rule '" + rule + "' should serialize to itself"); 43 } 44 45 style_text.data = ser1; 46 is(style.sheet.cssRules.length, 1, "should have one rule"); 47 var ser2 = style.sheet.cssRules[0].cssText; 48 is(ser2, ser1, 49 "parse+serialize for rule '" + rule + "' should be idempotent"); 50 } 51 52 SimpleTest.finish(); 53 54 55 </script> 56 </pre> 57 </body> 58 </html>