OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <title>Upgrade Insecure Requests: Basics.</title> | |
3 <script src="/resources/testharness.js"></script> | |
4 <script src="/resources/testharnessreport.js"></script> | |
5 | |
6 <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> | |
7 | |
8 <script> | |
9 // This is a bit of a hack. UPGRADE doesn't upgrade the port number, so we | |
10 // specify this non-existent URL ('http' over port 8443). If UPGRADE doesn't | |
11 // work, it won't load. | |
12 var insecureImage = "http://127.0.0.1:8443/security/resources/abe.png"; | |
13 | |
14 (function() { | |
15 var t = async_test("Verify that images are upgraded."); | |
16 t.step(function () { | |
17 var i = document.createElement('img'); | |
18 i.onload = t.step_func(function () { | |
19 assert_equals(i.naturalHeight, 103, "Height."); | |
20 assert_equals(i.naturalWidth, 76, "Width."); | |
21 t.done(); | |
22 }); | |
23 i.onerror = t.step_func(function () { | |
24 assert_unreached("The image should load successfully."); | |
25 }); | |
26 | |
27 i.src = insecureImage; | |
28 }); | |
29 }()); | |
30 | |
31 (function() { | |
32 var t = async_test("Verify that images have correct cross-origin behavior.")
; | |
33 t.step(function () { | |
34 var i = document.createElement('img'); | |
35 i.onload = t.step_func(function () { | |
36 // Draw the image onto a canvas. | |
37 var canvas = document.createElement('canvas'); | |
38 var ctx = canvas.getContext('2d'); | |
39 ctx.drawImage(i, 0, 0); | |
40 | |
41 // Grab a pixel to verify that the image is same-origin: | |
42 try { | |
43 var pixel = ctx.getImageData(0, 0, 1, 1); | |
44 t.done(); | |
45 } catch (e) { | |
46 assert_unreached("The image should be same-origin with this docu
ment."); | |
47 } | |
48 }); | |
49 i.onerror = t.step_func(function () { | |
50 assert_unreached("The image should load successfully."); | |
51 }); | |
52 | |
53 i.src = insecureImage; | |
54 }); | |
55 }()); | |
56 </script> | |
OLD | NEW |