| OLD | NEW |
| 1 <!DOCTYPE html> | |
| 2 <html> | 1 <html> |
| 3 <head> | 2 <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. --> | |
| 10 <link rel="stylesheet" | 3 <link rel="stylesheet" |
| 11 href="resources/redir.php?url=http://localhost:8000/security/resources/xor
igincss1.html"></link> | 4 href="resources/redir.php?url=http://localhost:8000/security/resources/xor
igincss1.html"></link> |
| 12 <link rel="stylesheet" | 5 <link rel="stylesheet" |
| 13 type="text/css" | 6 type="text/css" |
| 14 href="resources/redir.php?url=http://localhost:8000/security/resources/xor
igincss2.html"></link> | 7 href="resources/redir.php?url=http://localhost:8000/security/resources/xor
igincss2.html"></link> |
| 15 <link rel="stylesheet" | 8 <link rel="stylesheet" |
| 16 href="resources/redir.php?url=http://localhost:8000/security/resources/xor
igincss1.css"></link> | 9 href="resources/redir.php?url=http://localhost:8000/security/resources/xor
igincss1.css"></link> |
| 17 <link rel="stylesheet" | 10 <link rel="stylesheet" |
| 18 href="resources/xorigincss3.html"></link> | 11 href="resources/xorigincss3.html"></link> |
| 12 <script> |
| 13 if (window.testRunner) { |
| 14 testRunner.waitUntilDone(); |
| 15 testRunner.dumpAsText(); |
| 16 } |
| 19 | 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 |
| 34 if (window.testRunner) |
| 35 testRunner.notifyDone(); |
| 36 } |
| 37 </script> |
| 20 <style> | 38 <style> |
| 21 /* Deliberately reuse the same file / class / id on this first one */ | 39 /* Deliberately reuse the same file / class / id on this first one */ |
| 22 @import "resources/redir.php?url=http://localhost:8000/security/resources/xorigi
ncss2.html"; | 40 @import "resources/redir.php?url=http://localhost:8000/security/resources/xorigi
ncss2.html"; |
| 23 @import "resources/redir.php?url=http://localhost:8000/security/resources/xorigi
ncss4.html"; | 41 @import "resources/redir.php?url=http://localhost:8000/security/resources/xorigi
ncss4.html"; |
| 24 @import "resources/redir.php?url=http://localhost:8000/security/resources/xorigi
ncss2.css"; | 42 @import "resources/redir.php?url=http://localhost:8000/security/resources/xorigi
ncss2.css"; |
| 25 @import "resources/xorigincss5.html"; | 43 @import "resources/xorigincss5.html"; |
| 26 | 44 |
| 27 /* Check that data: is still allowed for non-CORS cross-origin image fetches. */ | 45 /* Check that data: is still allowed for non-CORS cross-origin image fetches. */ |
| 28 #data-background-url { | 46 #data-background-url { |
| 29 content: "PASS (image loaded)"; | 47 content: "PASS (image loaded)"; |
| 30 background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/
svg' width='0px' height='0px'></svg>"); | 48 background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/
svg' width='0px' height='0px'></svg>"); |
| 31 } | 49 } |
| 32 </style> | 50 </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> | |
| 72 </head> | 51 </head> |
| 73 <body> | 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> |
| 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> | |
| 83 </html> | 53 </html> |
| OLD | NEW |