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=557726 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 557726</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 id="pseudo-style"> |
michael@0 | 11 | #div1 { |
michael@0 | 12 | color: blue; |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | #div1:first-letter { |
michael@0 | 16 | font-weight: bold; |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | #div1:before { |
michael@0 | 20 | content: '"'; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | #div1:after { |
michael@0 | 24 | content: '"'; |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | #div1:after, #div1:before { |
michael@0 | 28 | color: red; |
michael@0 | 29 | } |
michael@0 | 30 | </style> |
michael@0 | 31 | </head> |
michael@0 | 32 | <body> |
michael@0 | 33 | |
michael@0 | 34 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=557726">Mozilla Bug 557726</a> |
michael@0 | 35 | |
michael@0 | 36 | <div id="div1"> |
michael@0 | 37 | text with :before, :after, and :first-letter pseudo-elements |
michael@0 | 38 | </div> |
michael@0 | 39 | |
michael@0 | 40 | <script type="application/javascript"> |
michael@0 | 41 | |
michael@0 | 42 | /** Test for Bug 557726 **/ |
michael@0 | 43 | |
michael@0 | 44 | function getSelectors (rules) { |
michael@0 | 45 | var styleElement = document.getElementById("pseudo-style"); |
michael@0 | 46 | var selectors = []; |
michael@0 | 47 | for (var i = 0; i < rules.Count(); i++) { |
michael@0 | 48 | var rule = rules.GetElementAt(i).QueryInterface(SpecialPowers.Ci.nsIDOMCSSStyleRule); |
michael@0 | 49 | if (SpecialPowers.unwrap(rule.parentStyleSheet.ownerNode) == styleElement) // no user agent rules |
michael@0 | 50 | selectors.push(rule.selectorText); |
michael@0 | 51 | } |
michael@0 | 52 | return selectors; |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"] |
michael@0 | 56 | .getService(SpecialPowers.Ci.inIDOMUtils); |
michael@0 | 57 | |
michael@0 | 58 | var div = document.getElementById("div1"); |
michael@0 | 59 | |
michael@0 | 60 | /* empty or missing pseudo-element argument */ |
michael@0 | 61 | var selectors = getSelectors(domUtils.getCSSStyleRules(div)); |
michael@0 | 62 | is(selectors.length, 1, "psuedo-element argument should be optional"); |
michael@0 | 63 | is(selectors[0], "#div1", "should only have the non-pseudo element rule"); |
michael@0 | 64 | |
michael@0 | 65 | selectors = getSelectors(domUtils.getCSSStyleRules(div, null)); |
michael@0 | 66 | is(selectors.length, 1, "pseudo-element argument can be null"); |
michael@0 | 67 | is(selectors[0], "#div1", "should only have the non pseudo-element rule"); |
michael@0 | 68 | |
michael@0 | 69 | selectors = getSelectors(domUtils.getCSSStyleRules(div, "")); |
michael@0 | 70 | is(selectors.length, 1, "pseudo-element argument can be empty string"); |
michael@0 | 71 | is(selectors[0], "#div1", "should only have the non pseudo-element rule"); |
michael@0 | 72 | |
michael@0 | 73 | |
michael@0 | 74 | /* invalid pseudo-element argument */ |
michael@0 | 75 | var rules = domUtils.getCSSStyleRules(div, "not a valid pseudo element"); |
michael@0 | 76 | is(rules, null, "invalid pseudo-element returns no rules list"); |
michael@0 | 77 | |
michael@0 | 78 | |
michael@0 | 79 | /* valid pseudo-element argument */ |
michael@0 | 80 | selectors = getSelectors(domUtils.getCSSStyleRules(div, ":first-letter")); |
michael@0 | 81 | is(selectors.length, 1, "pseudo-element argument can be used"); |
michael@0 | 82 | is(selectors[0], "#div1:first-letter", "should only have the :first-letter rule"); |
michael@0 | 83 | |
michael@0 | 84 | selectors = getSelectors(domUtils.getCSSStyleRules(div, ":before")); |
michael@0 | 85 | is(selectors.length, 2, ":before pseudo-element has two matching rules"); |
michael@0 | 86 | isnot(selectors.indexOf("#div1:after, #div1:before"), -1, "fetched rule for :before") |
michael@0 | 87 | isnot(selectors.indexOf("#div1:before"), -1, "fetched rule for :before") |
michael@0 | 88 | |
michael@0 | 89 | selectors = getSelectors(domUtils.getCSSStyleRules(div, ":first-line")); |
michael@0 | 90 | is(selectors.length, 0, "valid pseudo-element but no matching rules"); |
michael@0 | 91 | |
michael@0 | 92 | </script> |
michael@0 | 93 | </pre> |
michael@0 | 94 | </body> |
michael@0 | 95 | </html> |