<html>
<head>
    <script>
        function test() {
            if (window.testRunner) {
                testRunner.dumpAsText();
                testRunner.waitUntilDone();
            }

            var localStyleSheetLocation = "file:///tmp/LayoutTests/http/tests/security/resources/cssStyle.css";
            if (window.testRunner)
                localStyleSheetLocation = testRunner.pathToLocalResource(localStyleSheetLocation);

            var localLinkElement = document.createElement("link");
            localLinkElement.setAttribute("type", "text/css");
            localLinkElement.setAttribute("rel", "stylesheet");
            localLinkElement.setAttribute("href", localStyleSheetLocation);

            document.documentElement.firstChild.appendChild(localLinkElement);

            // Unfortunately link tags do not have load events, so we cannot simply make a load handler.
            window.setTimeout(backgroundCheck, 1);
            window.setTimeout(function() {
                if (window.testRunner)
                    testRunner.notifyDone();
            }, 5000);
        }

        function backgroundCheck() {
            var result = document.getElementById("result");
            var myBody = document.getElementById("myBody");
            var style = document.defaultView.getComputedStyle(myBody, null);
            var bgColor = style.getPropertyValue("background-color");
            if (bgColor[4] == 2) {
                result.innerHTML = "Test Passed. Local CSS remotely loaded";
                if (window.testRunner)
                    testRunner.notifyDone();
            } else {
                result.innerHTML = "Test Failed: Local CSS not remotely loaded.";
                window.setTimeout(backgroundCheck, 1);
            }
        }

    </script>
</head>
<body id="myBody" onload="test()">
    <div id="div0">
        This test is to see if a local file can include a local CSS style.
        <br/>
        Currently this test cannot be run manually on Windows because we do not have
        a function like pathToLocalResource() outside of DRT.
        <br/>
        <br/>
        If the background is yellow then the CSS was loaded.
    </div>
    <br/>
    <div id="result">
        Test not run correctly.
    </div>
</body>
</html>