OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE html> |
| 2 <body> |
2 <script src="/js-test-resources/js-test.js"></script> | 3 <script src="/js-test-resources/js-test.js"></script> |
3 <script> | 4 <script> |
4 description("Tests that the order of setting the src of an image element and its
crossOrigin attribute doesn't matter"); | 5 description("Tests that the order of setting the src of an image element and
its crossOrigin attribute doesn't matter"); |
5 window.jsTestIsAsync = true; | 6 jsTestIsAsync = true; |
6 | 7 |
7 // Resource returns a 100x100 image if Origin: is present, a 200x200 one if not. | 8 var img = new Image(); |
8 var testImageURL = "http://127.0.0.1:8000/resources/origin.php"; | 9 img.src="http://127.0.0.1:8000/resources/origin.php?1"; |
9 var successWidth = 100; | 10 img.crossOrigin = "anonymous"; |
| 11 var img2 = new Image(); |
| 12 img2.crossOrigin = "anonymous"; |
| 13 img2.src="http://127.0.0.1:8000/resources/origin.php?2"; |
10 | 14 |
11 function checkIfDone() { | 15 var srcFirstHasOrigin = false; |
12 if ("loaded" in img1 && "loaded" in img2) | 16 var srcLastHasOrigin = false; |
| 17 document.body.onload = function() { |
| 18 srcFirstHasOrigin = (img.width == 100) |
| 19 // srcFirstHasOrigin should be true per spec - see http://crbug.com/3410
47 |
| 20 shouldBeFalse('srcFirstHasOrigin'); |
| 21 srcLastHasOrigin = (img2.width == 100) |
| 22 shouldBeTrue('srcLastHasOrigin'); |
13 finishJSTest(); | 23 finishJSTest(); |
14 } | 24 }; |
15 | 25 |
16 function createImage() { | |
17 var img = new Image(); | |
18 img.onload = function () { | |
19 (img.width == successWidth ? testPassed : testFailed)("Origin: present i
n request."); | |
20 img.loaded = true; | |
21 checkIfDone(); | |
22 } | |
23 return img; | |
24 } | |
25 | |
26 var img1 = createImage(); | |
27 img1.src = testImageURL + "?1"; | |
28 img1.crossOrigin = "anonymous"; | |
29 | |
30 var img2 = createImage(); | |
31 img2.crossOrigin = "anonymous"; | |
32 img2.src = testImageURL + "?2"; | |
33 </script> | 26 </script> |
| 27 </body> |
| 28 </html> |
OLD | NEW |