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=393974 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 393974</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 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=393974">Mozilla Bug 393974</a> |
michael@0 | 13 | <p id="display"></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 class="testbody" type="text/javascript"> |
michael@0 | 19 | |
michael@0 | 20 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 21 | |
michael@0 | 22 | function test() |
michael@0 | 23 | { |
michael@0 | 24 | // Create a tree walker with a filter which creates a cycle... |
michael@0 | 25 | var tw = document.createTreeWalker(document, NodeFilter.SHOW_ALL, |
michael@0 | 26 | function(n) |
michael@0 | 27 | { |
michael@0 | 28 | // force the closure to contain the |
michael@0 | 29 | // global object, in case a future |
michael@0 | 30 | // optimization might minimize the |
michael@0 | 31 | // function's captured environment |
michael@0 | 32 | if ("foo" + window == "fooPIRATES!") |
michael@0 | 33 | return NodeFilter.FILTER_ACCEPT; |
michael@0 | 34 | return NodeFilter.FILTER_REJECT; |
michael@0 | 35 | }); |
michael@0 | 36 | |
michael@0 | 37 | // That should have been enough to create a leak, but we should do at least |
michael@0 | 38 | // a couple tests while we're here so that this document doesn't show up as |
michael@0 | 39 | // having no tests pass *or* fail. |
michael@0 | 40 | |
michael@0 | 41 | ok(tw.firstChild() === null, "shouldn't be a first child"); |
michael@0 | 42 | ok(tw.currentNode === document, "should be unchanged"); |
michael@0 | 43 | |
michael@0 | 44 | ok(tw.lastChild() === null, "shouldn't be a last child"); |
michael@0 | 45 | ok(tw.currentNode === document, "should be unchanged"); |
michael@0 | 46 | |
michael@0 | 47 | ok(tw.nextNode() === null, "shouldn't be a next node"); |
michael@0 | 48 | ok(tw.currentNode === document, "should be unchanged"); |
michael@0 | 49 | |
michael@0 | 50 | ok(tw.nextSibling() === null, "shouldn't be a next sibling"); |
michael@0 | 51 | ok(tw.currentNode === document, "should be unchanged"); |
michael@0 | 52 | |
michael@0 | 53 | ok(tw.parentNode() === null, "shouldn't be a parent node"); |
michael@0 | 54 | ok(tw.currentNode === document, "should be unchanged"); |
michael@0 | 55 | |
michael@0 | 56 | ok(tw.previousNode() === null, "shouldn't be a previous node"); |
michael@0 | 57 | ok(tw.currentNode === document, "should be unchanged"); |
michael@0 | 58 | |
michael@0 | 59 | ok(tw.previousSibling() === null, "shouldn't be a previous sibling"); |
michael@0 | 60 | ok(tw.currentNode === document, "should be unchanged"); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | addLoadEvent(test); |
michael@0 | 64 | addLoadEvent(SimpleTest.finish); |
michael@0 | 65 | </script> |
michael@0 | 66 | </pre> |
michael@0 | 67 | </body> |
michael@0 | 68 | </html> |