tor-browser

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

video-upgrade.https.sub.html (1931B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>Autoupgrade mixed content: Video.</title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/common/get-host-info.sub.js"></script>
      8 
      9 </head>
     10 <body>
     11  <script>
     12    async_test(t => assert_video_loads(t), "Video autoupgraded");
     13 
     14    function assert_video_loads(test) {
     15        // Since autoupgrades don't upgrade custom ports, we use the https port with an HTTP scheme. A successful autoupgrade will result in the right URL loading (and no autoupgrade will result in failure).
     16        var url = new URL("http://{{host}}:{{ports[https][0]}}/mixed-content/tentative/resources/test.webm")
     17        var i = document.createElement('video');
     18        i.oncanplaythrough = test.step_func_done(_ => {
     19            assert_equals(Math.floor(i.duration), 1, "Length.");
     20        });
     21        i.onerror = test.unreached_func("Video should load successfully from " + url);
     22        i.src = url;
     23    }
     24 
     25    // Test the same just with another host
     26    async_test(t => assert_other_host_video_loads(t), "Video of other host autoupgraded");
     27 
     28    function assert_other_host_video_loads(test) {
     29        // Since autoupgrades don't upgrade custom ports, we use the https port with an HTTP scheme. A successful autoupgrade will result in the right URL loading (and no autoupgrade will result in failure).
     30        var otherHost = get_host_info().HTTP_NOTSAMESITE_ORIGIN.slice(0,-4); // cut of http port
     31        var url = new URL( otherHost + "{{ports[https][0]}}/mixed-content/tentative/resources/test.webm")
     32        var i = document.createElement('video');
     33        i.oncanplaythrough = test.step_func_done(_ => {
     34            assert_equals(Math.floor(i.duration), 1, "Length. Other host");
     35        });
     36        i.onerror = test.unreached_func("Video of other host should load successfully from " + url);
     37        i.src = url;
     38    }
     39 </script>
     40 </body>
     41 </html>