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