1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/style/test/test_rule_serialization.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id= 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug </title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 + <style type="text/css" id="style"></style> 1.14 +</head> 1.15 +<body> 1.16 +<pre id="test"> 1.17 +<script type="application/javascript"> 1.18 + 1.19 +var rules = [ 1.20 + { rule: "@-moz-document url(http://www.example.com/) {}" }, 1.21 + { rule: "@-moz-document url('http://www.example.com/') {}" }, 1.22 + { rule: '@-moz-document url("http://www.example.com/") {}' }, 1.23 + { rule: "@-moz-document url-prefix('http://www.example.com/') {}" }, 1.24 + { rule: '@-moz-document url-prefix("http://www.example.com/") {}' }, 1.25 + { rule: "@-moz-document domain('example.com') {}" }, 1.26 + { rule: '@-moz-document domain("example.com") {}' }, 1.27 + { rule: "@-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {}" }, 1.28 + { rule: '@-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {}' }, 1.29 +]; 1.30 + 1.31 +var style = document.getElementById("style"); 1.32 +var style_text = document.createTextNode(""); 1.33 +style.appendChild(style_text); 1.34 + 1.35 +for (var i in rules) { 1.36 + var obj = rules[i]; 1.37 + var rule = obj.rule; 1.38 + 1.39 + style_text.data = rule; 1.40 + is(style.sheet.cssRules.length, 1, "should have one rule"); 1.41 + var ser1 = style.sheet.cssRules[0].cssText; 1.42 + if ("is_canonical" in obj) { 1.43 + is(ser1, rule, "rule '" + rule + "' should serialize to itself"); 1.44 + } 1.45 + 1.46 + style_text.data = ser1; 1.47 + is(style.sheet.cssRules.length, 1, "should have one rule"); 1.48 + var ser2 = style.sheet.cssRules[0].cssText; 1.49 + is(ser2, ser1, 1.50 + "parse+serialize for rule '" + rule + "' should be idempotent"); 1.51 +} 1.52 + 1.53 +</script> 1.54 +</pre> 1.55 +</body> 1.56 +</html>