layout/style/test/test_selectors_on_anonymous_content.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <title>Test for CSS Selectors</title>
     5   <!--
     6       Separate from test_selectors.html so we don't need to deal with
     7       waiting for the binding document to load.
     8     -->
     9   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    11   <style type="text/css">
    13   #display { -moz-binding: url(xbl_bindings.xml#onedivchild); }
    15   </style>
    16 </head>
    17 <body onload="run()">
    18 <div id="display"></div>
    19 <pre id="test">
    20 <script class="testbody" type="text/javascript">
    22 SimpleTest.waitForExplicitFinish();
    24 function run() {
    26     function setup_style() {
    27         var style_elem = document.createElement("style");
    28         style_elem.setAttribute("type", "text/css");
    29         document.getElementsByTagName("head")[0].appendChild(style_elem);
    30         var style_text = document.createTextNode("");
    31         style_elem.appendChild(style_text);
    32         return style_text;
    33     }
    35     var style_text = setup_style();
    37     var gCounter = 0;
    39     function test_selector(selector, matches_docdiv, matches_anondiv)
    40     {
    41         var zi = ++gCounter;
    42         style_text.data = selector + "{ z-index: " + zi + " }";
    44         var doc_div = document.getElementById("display");
    45         var anon_div = SpecialPowers.wrap(document).getAnonymousNodes(doc_div)[0];
    46         var should_match = [];
    47         var should_not_match = [];
    48         (matches_docdiv ? should_match : should_not_match).push(doc_div);
    49         (matches_anondiv ? should_match : should_not_match).push(anon_div);
    51         for (var i = 0; i < should_match.length; ++i) {
    52             var e = should_match[i];
    53             is(SpecialPowers.wrap(window).getComputedStyle(e, "").zIndex, zi,
    54                "element matched " + selector);
    55         }
    56         for (var i = 0; i < should_not_match.length; ++i) {
    57             var e = should_not_match[i];
    58             is(SpecialPowers.wrap(window).getComputedStyle(e, "").zIndex, "auto",
    59                "element did not match " + selector);
    60         }
    62         style_text.data = "";
    63     }
    65     // Test that the root of an XBL1 anonymous content subtree doesn't
    66     // match :nth-child().
    67     test_selector("div.anondiv", false, true);
    68     test_selector("div:nth-child(odd)", true, false);
    69     test_selector("div:nth-child(even)", false, false);
    71     SimpleTest.finish();
    72 }
    74 </script>
    75 </pre>
    76 </body>
    77 </html>

mercurial