layout/style/test/test_rule_serialization.html

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

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

mercurial