Tue, 06 Jan 2015 21:39:09 +0100
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.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=806506 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for ShadowRoot styles with multiple ShadowRoot on host.</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <div class="tall" id="bodydiv"></div> |
michael@0 | 13 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=806506">Bug 806506</a> |
michael@0 | 14 | <script> |
michael@0 | 15 | // Create ShadowRoot. |
michael@0 | 16 | var elem = document.createElement("div"); |
michael@0 | 17 | var firstRoot = elem.createShadowRoot(); |
michael@0 | 18 | var secondRoot = elem.createShadowRoot(); |
michael@0 | 19 | var thirdRoot = elem.createShadowRoot(); |
michael@0 | 20 | |
michael@0 | 21 | // A style element that will be appended into the ShadowRoot. |
michael@0 | 22 | var firstStyle = document.createElement("style"); |
michael@0 | 23 | firstRoot.appendChild(firstStyle); |
michael@0 | 24 | is(firstRoot.styleSheets.length, 1, "firstStyle should be the only style in firstRoot."); |
michael@0 | 25 | is(firstRoot.styleSheets[0].ownerNode, firstStyle, "firstStyle should in the ShadowRoot styleSheets."); |
michael@0 | 26 | |
michael@0 | 27 | var secondStyle = document.createElement("style"); |
michael@0 | 28 | secondRoot.appendChild(secondStyle); |
michael@0 | 29 | is(secondRoot.styleSheets.length, 1, "secondStyle should be the only style in secondRoot."); |
michael@0 | 30 | is(secondRoot.styleSheets[0].ownerNode, secondStyle, "secondStyle should in the ShadowRoot styleSheets."); |
michael@0 | 31 | |
michael@0 | 32 | var thirdStyle = document.createElement("style"); |
michael@0 | 33 | thirdRoot.appendChild(thirdStyle); |
michael@0 | 34 | is(thirdRoot.styleSheets.length, 1, "thirdStyle should be the only style in thirdRoot."); |
michael@0 | 35 | is(thirdRoot.styleSheets[0].ownerNode, thirdStyle, "thirdStyle should in the ShadowRoot styleSheets."); |
michael@0 | 36 | |
michael@0 | 37 | // Check the stylesheet counts again to make sure that none of the style sheets leaked into the older ShadowRoots. |
michael@0 | 38 | is(firstRoot.styleSheets.length, 1, "Adding a stylesheet to a younger ShadowRoot should not affect stylesheets in the older ShadowRoot."); |
michael@0 | 39 | is(secondRoot.styleSheets.length, 1, "Adding a stylesheet to a younger ShadowRoot should not affect stylesheets in the older ShadowRoot."); |
michael@0 | 40 | |
michael@0 | 41 | // Remove styles and make sure they are removed from the correct ShadowRoot. |
michael@0 | 42 | firstRoot.removeChild(firstStyle); |
michael@0 | 43 | is(firstRoot.styleSheets.length, 0, "firstRoot should no longer have any styles."); |
michael@0 | 44 | |
michael@0 | 45 | thirdRoot.removeChild(thirdStyle); |
michael@0 | 46 | is(thirdRoot.styleSheets.length, 0, "thirdRoot should no longer have any styles."); |
michael@0 | 47 | |
michael@0 | 48 | secondRoot.removeChild(secondStyle); |
michael@0 | 49 | is(secondRoot.styleSheets.length, 0, "secondRoot should no longer have any styles."); |
michael@0 | 50 | |
michael@0 | 51 | </script> |
michael@0 | 52 | </body> |
michael@0 | 53 | </html> |
michael@0 | 54 |