audio-upgrade.https.sub.html (1890B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Autoupgrade mixed content: Audio.</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_audio_loads(t), "Audio autoupgraded"); 13 14 function assert_audio_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.wav") 17 var i = document.createElement('audio'); 18 i.oncanplaythrough = test.step_func_done(_ => { 19 assert_equals(i.duration, 1, "Length"); 20 }); 21 i.onerror = test.unreached_func("Audio should load successfully from " + url); 22 i.src = url; 23 } 24 // Test the same just with another host 25 async_test(t => assert_other_host_audio_loads(t), "Audio of other host autoupgraded"); 26 27 function assert_other_host_audio_loads(test) { 28 // 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). 29 var otherHost = get_host_info().HTTP_NOTSAMESITE_ORIGIN.slice(0,-4); // cut of http port 30 var url = new URL( otherHost + "{{ports[https][0]}}/mixed-content/tentative/resources/test.wav") 31 var i = document.createElement('audio'); 32 i.oncanplaythrough = test.step_func_done(_ => { 33 assert_equals(i.duration, 1, "Length of other host audio is correct"); 34 }); 35 i.onerror = test.unreached_func("Audio of other host should load successfully from " + url); 36 i.src = url; 37 } 38 </script> 39 </body> 40 </html>