chromium/third_party/blink/web_tests/http/tests/security/same-origin-css-in-quirks.html

<html>
<!-- 
    Note the lack of doctype above: That is intentional. This test
    MUST be in quirks mode to have any real testing power.
-->
<head>
<title>Same-origin CSS in quirks mode</title>

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<link rel="stylesheet"
      href="resources/redir.php?url=/security/resources/xorigincss1.html"></link>
<link rel="stylesheet"
      type="text/css"
      href="resources/redir.php?url=/security/resources/xorigincss2.html"></link>
<link rel="stylesheet"
      href="resources/redir.php?url=/security/resources/xorigincss1.css"></link>
<link rel="stylesheet"
      href="resources/xorigincss3.html"></link>
<style>
/* Deliberately reuse the same file / class / id on this first one */
@import "resources/redir.php?url=/security/resources/xorigincss2.html";
@import "resources/redir.php?url=/security/resources/xorigincss4.html";
@import "resources/redir.php?url=/security/resources/xorigincss7.html";
@import "resources/redir.php?url=/security/resources/xorigincss2.css";
@import "resources/xorigincss5.html";

/* Check that data: is still allowed for non-CORS cross-origin image fetches. */
#data-background-url {
    content: "PASS (image loaded)";
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='0px' height='0px'></svg>");
}
</style>
<script>
    function getBackgroundColorForId(id) {
        return window.getComputedStyle(document.getElementById(id), null).getPropertyValue('background-color')
    }
    var onloadTest = async_test("Testing same-origin and MIME behavior for CSS.");
    window.onload = function () {
        test(function () {
            assert_equals(getBackgroundColorForId('id1'), 'rgb(255, 255, 0)');
        }, 'xorigincss1.html should be loaded via <link>.');
        test(function () {
            assert_equals(getBackgroundColorForId('id2'), 'rgb(255, 255, 0)');
        }, 'xorigincss2.html should be loaded either via <link> or @import.');
        test(function () {
            assert_equals(getBackgroundColorForId('id3'), 'rgb(255, 255, 0)');
        }, 'xorigincss1.css should be loaded via <link>');
        test(function () {
            assert_equals(getBackgroundColorForId('id4'), 'rgb(255, 255, 0)');
        }, 'xorigincss3.html should be loaded');
        test(function () {
            assert_equals(getBackgroundColorForId('id5'), 'rgb(255, 255, 0)');
        }, 'xorigincss4.html should be loaded via @import.');
        test(function () {
            assert_equals(getBackgroundColorForId('id6'), 'rgb(255, 255, 0)');
        }, 'xorigincss2.css should be loaded.');
        test(function () {
            assert_equals(getBackgroundColorForId('id7'), 'rgb(255, 255, 0)');
        }, 'xorigincss5.html should be loaded.');
        test(function () {
            assert_equals(getBackgroundColorForId('id8'), 'rgb(255, 255, 0)');
        }, 'xorigincss7.html should be loaded.');
        onloadTest.done();
    };
</script>
</head>
<body>
    <div id="id1" class="id1"></div>
    <div id="id2" class="id2"></div>
    <div id="id3" 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="id8" class="id8"></div>
    <div id="data-background-url">PASS background image loaded</div>
</body>
</html>