tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

URL-createObjectURL-revoke.html (2341B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4  <meta charset='utf-8'>
      5  <title>Revoking a created URL with URL.revokeObjectURL(url)</title>
      6  <script src="/resources/testharness.js"></script>
      7  <script src="/resources/testharnessreport.js"></script>
      8 </head>
      9 <body>
     10 <div id="log"></div>
     11 <script>
     12 async_test(function(t) {
     13    var mediaSource = new MediaSource();
     14    var url = window.URL.createObjectURL(mediaSource);
     15    window.URL.revokeObjectURL(url);
     16    mediaSource.addEventListener('sourceopen',
     17                                 t.unreached_func("url should not reference MediaSource."));
     18    var video = document.createElement('video');
     19    video.src = url;
     20    video.addEventListener('error', t.step_func_done(function(e) {
     21        assert_equals(e.target.error.code,
     22                      MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED,
     23                      'Expected error code');
     24        assert_equals(mediaSource.readyState, 'closed');
     25    }));
     26 }, "Check revoking behavior of URL.revokeObjectURL(url).");
     27 async_test(function(t) {
     28    var mediaSource = new MediaSource();
     29    var url = window.URL.createObjectURL(mediaSource);
     30    var video = document.createElement('video');
     31    var unexpectedErrorHandler = t.unreached_func("Unexpected error.")
     32    video.addEventListener('error', unexpectedErrorHandler);
     33    video.src = url;
     34    window.URL.revokeObjectURL(url);
     35    mediaSource.addEventListener('sourceopen', t.step_func_done(function(e) {
     36        assert_equals(mediaSource.readyState, 'open');
     37        mediaSource.endOfStream();
     38        video.removeEventListener('error', unexpectedErrorHandler);
     39    }));
     40 }, "Check referenced MediaSource can open after URL.revokeObjectURL(url).");
     41 async_test(function(t) {
     42    var mediaSource = new MediaSource();
     43    var url = window.URL.createObjectURL(mediaSource);
     44    setTimeout(function() {
     45        mediaSource.addEventListener('sourceopen', t.step_func_done(function(e) {
     46          assert_equals(video.networkState, video.NETWORK_LOADING);
     47          assert_equals(video.readyState, video.HAVE_NOTHING);
     48        }));
     49        var video = document.createElement('video');
     50        video.src = url;
     51        video.addEventListener('error', t.unreached_func("no error events should be dispatched"));
     52    }, 0);
     53 }, "Check no auto-revoking behavior with URL.createObjectURL(MediaSource).");
     54 </script>
     55 </body>
     56 </html>