image-upgrade.https.sub.html (2015B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Autoupgrade mixed content: Optionally Blockable.</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_image_loads(t), "Image autoupgraded"); 13 14 function assert_image_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/pass.png") 17 var i = document.createElement('img'); 18 i.onload = test.step_func_done(_ => { 19 assert_equals(i.naturalHeight, 64, "Height."); 20 assert_equals(i.naturalWidth, 168, "Width."); 21 }); 22 i.onerror = test.unreached_func("Image should load successfully from " + url); 23 i.src = url; 24 } 25 26 // Test the same just with another host 27 async_test(t => assert_other_host_image_loads(t), "Image of other host autoupgraded"); 28 29 function assert_other_host_image_loads(test) { 30 // 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). 31 var otherHost = get_host_info().HTTP_NOTSAMESITE_ORIGIN.slice(0,-4); // cut of http port 32 var url = new URL( otherHost + "{{ports[https][0]}}/mixed-content/tentative/resources/pass.png") 33 var i = document.createElement('img'); 34 i.onload = test.step_func_done(_ => { 35 assert_equals(i.naturalHeight, 64, "Height."); 36 assert_equals(i.naturalWidth, 168, "Width."); 37 }); 38 i.onerror = test.unreached_func("image of other host should load successfully from " + url); 39 i.src = url; 40 } 41 </script> 42 </body> 43 </html>