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