<!DOCTYPE html>
<html>
<head>
    <script src="/js-test-resources/js-test-pre.js"></script>
    <script>
        description('Check that an X-Frame-Options header added by a 304 response does not override one from the original request.');
        debug('Two console messages should be generated, each followed by an alert.');
        window.jsTestIsAsync = true;

        var frame1, frame2;
        function frameLoaded() {
            frame1 = document.querySelector('iframe');

            frame2 = document.createElement('iframe');
            document.body.appendChild(frame2);
            frame2.onload = checkState;

            frame2.src = frame1.src;
        }

        function checkState() {
            debug('Both frames should point to the expected URL, and not to about:blank.');
            shouldBeEqualToString('frame1.src', 'http://127.0.0.1:8000/security/XFrameOptions/resources/nph-cached-xfo.pl');
            shouldBeEqualToString('frame2.src', 'http://127.0.0.1:8000/security/XFrameOptions/resources/nph-cached-xfo.pl');
            finishJSTest();
        }
    </script>
    <script src="/js-test-resources/js-test-post.js"></script>
</head>
<body>
    <iframe src="http://127.0.0.1:8000/security/XFrameOptions/resources/nph-cached-xfo.pl" onload="frameLoaded()"></iframe>
</body>
</html>
