OLD | NEW |
| 1 <!DOCTYPE html> |
1 <html> | 2 <html> |
2 <head> | 3 <head> |
| 4 <title>Cross-origin CSS</title> |
| 5 |
| 6 <script src="../resources/testharness.js"></script> |
| 7 <script src="../resources/testharnessreport.js"></script> |
| 8 |
| 9 <!-- Bring in various same- and cross-origin stylesheets. --> |
3 <link rel="stylesheet" | 10 <link rel="stylesheet" |
4 href="resources/redir.php?url=http://localhost:8000/security/resources/xor
igincss1.html"></link> | 11 href="resources/redir.php?url=http://localhost:8000/security/resources/xor
igincss1.html"></link> |
5 <link rel="stylesheet" | 12 <link rel="stylesheet" |
6 type="text/css" | 13 type="text/css" |
7 href="resources/redir.php?url=http://localhost:8000/security/resources/xor
igincss2.html"></link> | 14 href="resources/redir.php?url=http://localhost:8000/security/resources/xor
igincss2.html"></link> |
8 <link rel="stylesheet" | 15 <link rel="stylesheet" |
9 href="resources/redir.php?url=http://localhost:8000/security/resources/xor
igincss1.css"></link> | 16 href="resources/redir.php?url=http://localhost:8000/security/resources/xor
igincss1.css"></link> |
10 <link rel="stylesheet" | 17 <link rel="stylesheet" |
11 href="resources/xorigincss3.html"></link> | 18 href="resources/xorigincss3.html"></link> |
12 <script> | |
13 if (window.testRunner) { | |
14 testRunner.waitUntilDone(); | |
15 testRunner.dumpAsText(); | |
16 } | |
17 | 19 |
18 window.onload = function() { | |
19 ele = document.getElementById("id1"); | |
20 ele.innerText = "LINK Cross-origin, HTML, valid: " + window.getComputedStyle(e
le, null).getPropertyValue('background-color'); | |
21 ele = document.getElementById("id2"); | |
22 ele.innerText = "LINK + IMPORT Cross-origin, HTML, invalid: " + window.getComp
utedStyle(ele, null).getPropertyValue('background-color'); | |
23 ele = document.getElementById("id3"); | |
24 ele.innerText = "LINK Cross-origin, CSS, invalid: " + window.getComputedStyle(
ele, null).getPropertyValue('background-color'); | |
25 ele = document.getElementById("id4"); | |
26 ele.innerText = "LINK Same-origin, HTML, invalid: " + window.getComputedStyle(
ele, null).getPropertyValue('background-color'); | |
27 ele = document.getElementById("id5"); | |
28 ele.innerText = "IMPORT Cross-origin, HTML, valid: " + window.getComputedStyle
(ele, null).getPropertyValue('background-color'); | |
29 ele = document.getElementById("id6"); | |
30 ele.innerText = "IMPORT Cross-origin, CSS, invalid: " + window.getComputedStyl
e(ele, null).getPropertyValue('background-color'); | |
31 ele = document.getElementById("id7"); | |
32 ele.innerText = "IMPORT Same-origin, HTML, invalid: " + window.getComputedStyl
e(ele, null).getPropertyValue('background-color'); | |
33 | |
34 if (window.testRunner) | |
35 testRunner.notifyDone(); | |
36 } | |
37 </script> | |
38 <style> | 20 <style> |
39 /* Deliberately reuse the same file / class / id on this first one */ | 21 /* Deliberately reuse the same file / class / id on this first one */ |
40 @import "resources/redir.php?url=http://localhost:8000/security/resources/xorigi
ncss2.html"; | 22 @import "resources/redir.php?url=http://localhost:8000/security/resources/xorigi
ncss2.html"; |
41 @import "resources/redir.php?url=http://localhost:8000/security/resources/xorigi
ncss4.html"; | 23 @import "resources/redir.php?url=http://localhost:8000/security/resources/xorigi
ncss4.html"; |
42 @import "resources/redir.php?url=http://localhost:8000/security/resources/xorigi
ncss2.css"; | 24 @import "resources/redir.php?url=http://localhost:8000/security/resources/xorigi
ncss2.css"; |
43 @import "resources/xorigincss5.html"; | 25 @import "resources/xorigincss5.html"; |
44 | 26 |
45 /* Check that data: is still allowed for non-CORS cross-origin image fetches. */ | 27 /* Check that data: is still allowed for non-CORS cross-origin image fetches. */ |
46 #data-background-url { | 28 #data-background-url { |
47 content: "PASS (image loaded)"; | 29 content: "PASS (image loaded)"; |
48 background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/
svg' width='0px' height='0px'></svg>"); | 30 background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/
svg' width='0px' height='0px'></svg>"); |
49 } | 31 } |
50 </style> | 32 </style> |
| 33 <script> |
| 34 function getBackgroundColorForId(id) { |
| 35 return window.getComputedStyle(document.getElementById(id), null).getPropert
yValue('background-color') |
| 36 } |
| 37 |
| 38 var onloadTest = async_test("Testing cross-origin and MIME behavior for CSS."); |
| 39 |
| 40 window.onload = function () { |
| 41 test(function () { |
| 42 assert_equals(getBackgroundColorForId('id1'), 'rgba(0, 0, 0, 0)'); |
| 43 }, 'xorigincss1.html should not be loaded via <link>.'); |
| 44 |
| 45 test(function () { |
| 46 assert_equals(getBackgroundColorForId('id2'), 'rgba(0, 0, 0, 0)'); |
| 47 }, 'xorigincss2.html should not be loaded either via <link> or @import.'); |
| 48 |
| 49 test(function () { |
| 50 assert_equals(getBackgroundColorForId('id3'), 'rgb(255, 255, 0)'); |
| 51 }, 'xorigincss1.css should be loaded via <link>'); |
| 52 |
| 53 test(function () { |
| 54 assert_equals(getBackgroundColorForId('id4'), 'rgba(0, 0, 0, 0)'); |
| 55 }, 'xorigincss3.html should not be loaded, even though it is same-origin'); |
| 56 |
| 57 test(function () { |
| 58 assert_equals(getBackgroundColorForId('id5'), 'rgba(0, 0, 0, 0)'); |
| 59 }, 'xorigincss4.html should not be loaded via @import.'); |
| 60 |
| 61 test(function () { |
| 62 assert_equals(getBackgroundColorForId('id6'), 'rgb(255, 255, 0)'); |
| 63 }, 'xorigincss2.css should be loaded.'); |
| 64 |
| 65 test(function () { |
| 66 assert_equals(getBackgroundColorForId('id7'), 'rgba(0, 0, 0, 0)'); |
| 67 }, 'xorigincss5.html should not be loaded.'); |
| 68 |
| 69 onloadTest.done(); |
| 70 }; |
| 71 </script> |
51 </head> | 72 </head> |
52 <body><div id="id1" class="id1"></div><div id="id2" class="id2"></div><div id="i
d3" class="id3"></div><div id="id4" class="id4"></div><div id="id5" class="id5">
</div><div id="id6" class="id6"></div><div id="id7" class="id7"></div><div id="d
ata-background-url">PASS background image loaded</div></body> | 73 <body> |
| 74 <div id="id1" class="id1"></div> |
| 75 <div id="id2" class="id2"></div> |
| 76 <div id="id3" class="id3"></div> |
| 77 <div id="id4" class="id4"></div> |
| 78 <div id="id5" class="id5"></div> |
| 79 <div id="id6" class="id6"></div> |
| 80 <div id="id7" class="id7"></div> |
| 81 <div id="data-background-url">PASS background image loaded</div> |
| 82 </body> |
53 </html> | 83 </html> |
OLD | NEW |