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=584480 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 584480</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=584480">Mozilla Bug </a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content" style="display: none"> |
michael@0 | 16 | |
michael@0 | 17 | </div> |
michael@0 | 18 | <pre id="test"> |
michael@0 | 19 | <script type="application/javascript"> |
michael@0 | 20 | var media = []; |
michael@0 | 21 | |
michael@0 | 22 | function checkComplete() { |
michael@0 | 23 | for (var i=0; i<media.length; ++i) { |
michael@0 | 24 | if (!media[i]._complete) { |
michael@0 | 25 | return; |
michael@0 | 26 | } |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | SimpleTest.finish(); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function removeNode(v) { |
michael@0 | 33 | v.removeEventListener("error", loadError, false); |
michael@0 | 34 | v.removeEventListener("loadedmetadata", loadedMetadata, false); |
michael@0 | 35 | v.remove(); |
michael@0 | 36 | v.src = ""; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | function loadError(evt) { |
michael@0 | 40 | // If no referer is sent then the sjs returns an error |
michael@0 | 41 | ok(false, "check referer is sent with media request"); |
michael@0 | 42 | evt.target._complete = true; |
michael@0 | 43 | checkComplete(); |
michael@0 | 44 | removeNode(evt.target); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | function loadedMetadata(evt) { |
michael@0 | 48 | // If a referer is sent then the sjs returns a valid media |
michael@0 | 49 | ok(true, "check referer is sent with media request"); |
michael@0 | 50 | evt.target._complete = true; |
michael@0 | 51 | checkComplete(); |
michael@0 | 52 | removeNode(evt.target); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | // Create all media objects. |
michael@0 | 56 | for (var i=0; i<gSmallTests.length; ++i) { |
michael@0 | 57 | var test = gSmallTests[i]; |
michael@0 | 58 | var type; |
michael@0 | 59 | if (/^video/.test(test.type)) { |
michael@0 | 60 | type = "video" |
michael@0 | 61 | } else { |
michael@0 | 62 | type = "audio"; |
michael@0 | 63 | } |
michael@0 | 64 | var v = document.createElement(type); |
michael@0 | 65 | if (!v.canPlayType(test.type)) { |
michael@0 | 66 | continue; |
michael@0 | 67 | } |
michael@0 | 68 | // ensure metadata is loaded for default preload is none on b2g |
michael@0 | 69 | v.preload = "metadata"; |
michael@0 | 70 | v._complete = false; |
michael@0 | 71 | v.addEventListener("error", loadError, false); |
michael@0 | 72 | v.addEventListener("loadedmetadata", loadedMetadata, false); |
michael@0 | 73 | v.src = 'referer.sjs?name=' + test.name + '&type=' + test.type; |
michael@0 | 74 | document.body.appendChild(v); // Will start load. |
michael@0 | 75 | media.push(v); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | if (media.length == 0) { |
michael@0 | 79 | todo(false, "No types supported"); |
michael@0 | 80 | } else { |
michael@0 | 81 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 82 | } |
michael@0 | 83 | </script> |
michael@0 | 84 | </pre> |
michael@0 | 85 | |
michael@0 | 86 | </body> |
michael@0 | 87 | </html> |