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=462789 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 462789</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 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=462789">Mozilla Bug 462789</a> |
michael@0 | 13 | <p id="display"><iframe id="bug462789_iframe" src="data:text/html,<html><head><style>*{color:black;}</style></head><body>xxx" style="display: none;"></iframe></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | |
michael@0 | 16 | </div> |
michael@0 | 17 | <pre id="test"> |
michael@0 | 18 | <script type="application/javascript"> |
michael@0 | 19 | |
michael@0 | 20 | /** Test for Bug 462789 **/ |
michael@0 | 21 | |
michael@0 | 22 | function do_test() { |
michael@0 | 23 | const ERROR_FAILURE = 0x80004005; |
michael@0 | 24 | const DOCUMENT_NODE_TYPE = 9; |
michael@0 | 25 | |
michael@0 | 26 | var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"] |
michael@0 | 27 | .getService(SpecialPowers.Ci.inIDOMUtils); |
michael@0 | 28 | |
michael@0 | 29 | var iframe = document.getElementById("bug462789_iframe"); |
michael@0 | 30 | var docElement = iframe.contentDocument.documentElement; |
michael@0 | 31 | var body = docElement.children[1]; |
michael@0 | 32 | var rule = iframe.contentDocument.styleSheets[0].cssRules[0]; |
michael@0 | 33 | var text = body.firstChild; |
michael@0 | 34 | |
michael@0 | 35 | try { |
michael@0 | 36 | var res = utils.getCSSStyleRules(docElement); |
michael@0 | 37 | is(res, null, "getCSSStyleRules"); |
michael@0 | 38 | res = utils.getCSSStyleRules(body); |
michael@0 | 39 | is(res, null, "getCSSStyleRules"); |
michael@0 | 40 | } |
michael@0 | 41 | catch(e) { ok(false, "got an unexpected exception:" + e); } |
michael@0 | 42 | |
michael@0 | 43 | try { |
michael@0 | 44 | var res = utils.getRuleLine(rule); |
michael@0 | 45 | is(res, 1, "getRuleLine"); |
michael@0 | 46 | } |
michael@0 | 47 | catch(e) { ok(false, "got an unexpected exception:" + e); } |
michael@0 | 48 | |
michael@0 | 49 | try { |
michael@0 | 50 | var res = utils.isIgnorableWhitespace(text); |
michael@0 | 51 | is(res, false, "isIgnorableWhitespace"); |
michael@0 | 52 | } |
michael@0 | 53 | catch(e) { ok(false, "got an unexpected exception:" + e); } |
michael@0 | 54 | |
michael@0 | 55 | try { |
michael@0 | 56 | var res = utils.getParentForNode(docElement, true); |
michael@0 | 57 | is(res.nodeType, DOCUMENT_NODE_TYPE, "getParentForNode(docElement, true)"); |
michael@0 | 58 | res = utils.getParentForNode(text, true); |
michael@0 | 59 | is(res.tagName, "BODY", "getParentForNode(text, true)"); |
michael@0 | 60 | } |
michael@0 | 61 | catch(e) { ok(false, "got an unexpected exception:" + e); } |
michael@0 | 62 | |
michael@0 | 63 | try { |
michael@0 | 64 | var res = utils.getBindingURLs(docElement); |
michael@0 | 65 | ok(SpecialPowers.call_Instanceof(res, SpecialPowers.Ci["nsIArray"]), "getBindingURLs result type"); |
michael@0 | 66 | is(res.length, 0, "getBindingURLs array length"); |
michael@0 | 67 | } |
michael@0 | 68 | catch(e) { ok(false, "got an unexpected exception:" + e); } |
michael@0 | 69 | |
michael@0 | 70 | try { |
michael@0 | 71 | utils.getContentState(docElement); |
michael@0 | 72 | ok(true, "Should not throw"); |
michael@0 | 73 | } |
michael@0 | 74 | catch(e) { ok(false, "Got an exception: " + e); } |
michael@0 | 75 | |
michael@0 | 76 | try { |
michael@0 | 77 | utils.setContentState(docElement, false); |
michael@0 | 78 | ok(false, "expected an exception"); |
michael@0 | 79 | } |
michael@0 | 80 | catch(e) { |
michael@0 | 81 | e = SpecialPowers.wrap(e); |
michael@0 | 82 | is(e.result, ERROR_FAILURE, "got the expected exception"); |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | SimpleTest.finish(); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 89 | addLoadEvent(do_test); |
michael@0 | 90 | |
michael@0 | 91 | </script> |
michael@0 | 92 | </pre> |
michael@0 | 93 | </body> |
michael@0 | 94 | </html> |