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=476731 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 476731</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 | <script type="text/javascript" src="manifest.js"></script> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=476731">Mozilla Bug </a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content" style="display: none"> |
michael@0 | 16 | </div> |
michael@0 | 17 | <pre id="test"> |
michael@0 | 18 | <script type="application/javascript"> |
michael@0 | 19 | /** Test for Bug 476731 **/ |
michael@0 | 20 | |
michael@0 | 21 | var videos = []; |
michael@0 | 22 | |
michael@0 | 23 | function FinishedLoads() { |
michael@0 | 24 | if (videos.length == 0) |
michael@0 | 25 | return false; |
michael@0 | 26 | for (var i=0; i<videos.length; ++i) { |
michael@0 | 27 | if (videos[i]._loadedData) { |
michael@0 | 28 | // A video loadeddata, it should have 404'd. Signal the end of the test |
michael@0 | 29 | // so the error will be reported. |
michael@0 | 30 | return true; |
michael@0 | 31 | } |
michael@0 | 32 | if (!videos[i]._loadError) { |
michael@0 | 33 | return false; |
michael@0 | 34 | } |
michael@0 | 35 | } |
michael@0 | 36 | return true; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | function loadError(evt) { |
michael@0 | 40 | var v = evt.target; |
michael@0 | 41 | is(v._loadError, false, "Shouldn't receive multiple error events for " + v.src); |
michael@0 | 42 | v._loadError = true; |
michael@0 | 43 | is(v._loadStart, true, "Receive loadstart for " + v.src); |
michael@0 | 44 | is(v._loadedData, false, "Shouldn't receive loadeddata for " + v.src); |
michael@0 | 45 | if (FinishedLoads(videos)) |
michael@0 | 46 | SimpleTest.finish(); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | function loadedData(evt) { |
michael@0 | 50 | evt.target._loadedData = true; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | function loadStart(evt) { |
michael@0 | 54 | evt.target._loadStart = true; |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | // Create all video objects. |
michael@0 | 58 | for (var i=0; i<g404Tests.length; ++i) { |
michael@0 | 59 | var v = document.createElement("video"); |
michael@0 | 60 | v.preload = "auto"; |
michael@0 | 61 | var test = g404Tests[i]; |
michael@0 | 62 | if (!v.canPlayType(test.type)) { |
michael@0 | 63 | continue; |
michael@0 | 64 | } |
michael@0 | 65 | v.src = test.name; |
michael@0 | 66 | v._loadedData = false; |
michael@0 | 67 | v._loadStart = false; |
michael@0 | 68 | v._loadError = false; |
michael@0 | 69 | v.addEventListener("error", loadError, false); |
michael@0 | 70 | v.addEventListener("loadstart", loadStart, false); |
michael@0 | 71 | v.addEventListener("loadeddata", loadedData, false); |
michael@0 | 72 | document.body.appendChild(v); // Will start load. |
michael@0 | 73 | videos.push(v); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | if (videos.length == 0) { |
michael@0 | 77 | todo(false, "No types supported"); |
michael@0 | 78 | } else { |
michael@0 | 79 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 80 | } |
michael@0 | 81 | </script> |
michael@0 | 82 | </pre> |
michael@0 | 83 | </body> |
michael@0 | 84 | </html> |