dom/tests/mochitest/webcomponents/test_dynamic_content_element_matching.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=806506
     5 -->
     6 <head>
     7   <title>Test for dynamic changes to content matching content elements</title>
     8   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    10 </head>
    11 <body>
    12 <div class="tall" id="bodydiv"></div>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=806506">Bug 806506</a>
    14 <script>
    15 // Create ShadowRoot.
    16 var elem = document.createElement("div");
    17 var root = elem.createShadowRoot();
    19 var redInsertionPoint = document.createElement("content");
    20 redInsertionPoint.select = "*[data-color=red]";
    22 var blueInsertionPoint = document.createElement("content");
    23 blueInsertionPoint.select = "*[data-color=blue]";
    25 root.appendChild(redInsertionPoint);
    26 root.appendChild(blueInsertionPoint);
    28 is(blueInsertionPoint.getDistributedNodes().length, 0, "Blue insertion point should have no distributed nodes.");
    29 is(redInsertionPoint.getDistributedNodes().length, 0, "Red insertion point should have no distrubted nodes.");
    31 var matchElement = document.createElement("div");
    32 matchElement.setAttribute("data-color", "red");
    33 elem.appendChild(matchElement);
    35 is(blueInsertionPoint.getDistributedNodes().length, 0, "Blue insertion point should have no distributed nodes.");
    36 is(redInsertionPoint.getDistributedNodes().length, 1, "Red insertion point should match recently inserted div.");
    38 matchElement.setAttribute("data-color", "blue");
    39 is(blueInsertionPoint.getDistributedNodes().length, 1, "Blue insertion point should match element after changing attribute value.");
    40 is(redInsertionPoint.getDistributedNodes().length, 0, "Red insertion point should not match element after changing attribute value.");
    42 matchElement.removeAttribute("data-color");
    44 is(blueInsertionPoint.getDistributedNodes().length, 0, "Blue insertion point should have no distributed nodes after removing the matching attribute.");
    45 is(redInsertionPoint.getDistributedNodes().length, 0, "Red insertion point should have no distrubted nodes after removing the matching attribute.");
    47 </script>
    48 </body>
    49 </html>

mercurial