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 | <head> |
michael@0 | 4 | <meta charset="utf-8"> |
michael@0 | 5 | <title>Test returning metadata from media files with mozGetMetadata()</title> |
michael@0 | 6 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 7 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 8 | <script type="text/javascript" src="manifest.js"></script> |
michael@0 | 9 | </head> |
michael@0 | 10 | <body> |
michael@0 | 11 | <pre id="test"> |
michael@0 | 12 | <div id="output"></div> |
michael@0 | 13 | <script class="testbody" type="text/javascript"> |
michael@0 | 14 | |
michael@0 | 15 | var manager = new MediaTestManager; |
michael@0 | 16 | |
michael@0 | 17 | function startTest(test, token) { |
michael@0 | 18 | var a = document.createElement('audio'); |
michael@0 | 19 | a.preload = "auto"; |
michael@0 | 20 | a.token = token; |
michael@0 | 21 | manager.started(token); |
michael@0 | 22 | |
michael@0 | 23 | a.src = test.name; |
michael@0 | 24 | a.name = test.name; |
michael@0 | 25 | |
michael@0 | 26 | // Tags should not be available immediately. |
michael@0 | 27 | var exception_fired = false; |
michael@0 | 28 | try { |
michael@0 | 29 | var m = a.mozGetMetadata(); |
michael@0 | 30 | } catch (e) { |
michael@0 | 31 | is(e.name, 'InvalidStateError', |
michael@0 | 32 | "early mozGetMetadata() should throw InvalidStateError"); |
michael@0 | 33 | exception_fired = true; |
michael@0 | 34 | } |
michael@0 | 35 | ok(exception_fired, |
michael@0 | 36 | "mozGetMetadata() should throw an exception before HAVE_METADATA"); |
michael@0 | 37 | |
michael@0 | 38 | // Wait until metadata has loaded. |
michael@0 | 39 | a.addEventListener('loadedmetadata', function() { |
michael@0 | 40 | // read decoded tags |
michael@0 | 41 | tags = a.mozGetMetadata(); |
michael@0 | 42 | ok(tags, "mozGetMetadata() should return a truthy value"); |
michael@0 | 43 | // Dump them out. |
michael@0 | 44 | var d = document.getElementById('output'); |
michael@0 | 45 | var html = '<table>\n'; |
michael@0 | 46 | html += '<caption><p>Called getMozMetadata()' |
michael@0 | 47 | html += ' on '+test.name+'</p></caption>\n'; |
michael@0 | 48 | html += '<tr><th>tag</th>'; |
michael@0 | 49 | html += '<th>decoded value</th><th>expected value</th></tr>\n'; |
michael@0 | 50 | for (tag in tags) { |
michael@0 | 51 | html += '<tr><td>'+tag+'</td>'; |
michael@0 | 52 | html += '<td>'+tags[tag]+'</td>'; |
michael@0 | 53 | html += '<td>'+test.tags[tag]+'</td>'; |
michael@0 | 54 | html += '</tr>\n'; |
michael@0 | 55 | } |
michael@0 | 56 | if (!Object.keys(tags).length) { |
michael@0 | 57 | html += '<tr><td colspan=3 align=center><em>no tags</em></td></tr>\n'; |
michael@0 | 58 | } |
michael@0 | 59 | html += '</table>\n'; |
michael@0 | 60 | var div = document.createElement('div'); |
michael@0 | 61 | div.innerHTML = html; |
michael@0 | 62 | d.appendChild(div); |
michael@0 | 63 | // Verify decoded tag values. |
michael@0 | 64 | for (tag in tags) { |
michael@0 | 65 | is(tags[tag], test.tags[tag], "Tag '"+tag+"' should match"); |
michael@0 | 66 | } |
michael@0 | 67 | // Verify expected tag values |
michael@0 | 68 | for (tag in test.tags) { |
michael@0 | 69 | is(tags[tag], test.tags[tag], "Tag '"+tag+"' should match"); |
michael@0 | 70 | } |
michael@0 | 71 | manager.finished(token); |
michael@0 | 72 | }, false); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | manager.runTests(gMetadataTests, startTest); |
michael@0 | 76 | |
michael@0 | 77 | </script> |
michael@0 | 78 | </pre> |
michael@0 | 79 | </body> |
michael@0 | 80 | </html> |