layout/style/test/test_rule_serialization.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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 type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/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">
    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 ];
    28 var style = document.getElementById("style");
    29 var style_text = document.createTextNode("");
    30 style.appendChild(style_text);
    32 for (var i in rules) {
    33   var obj = rules[i];
    34   var rule = obj.rule;
    36   style_text.data = rule;
    37   is(style.sheet.cssRules.length, 1, "should have one rule");
    38   var ser1 = style.sheet.cssRules[0].cssText;
    39   if ("is_canonical" in obj) {
    40     is(ser1, rule, "rule '" + rule + "' should serialize to itself");
    41   }
    43   style_text.data = ser1;
    44   is(style.sheet.cssRules.length, 1, "should have one rule");
    45   var ser2 = style.sheet.cssRules[0].cssText;
    46   is(ser2, ser1,
    47      "parse+serialize for rule '" + rule + "' should be idempotent");
    48 }
    50 </script>
    51 </pre>
    52 </body>
    53 </html>

mercurial