<!DOCTYPE html>
<html>
<head>
<script src='resources/cookies-test-pre.js'></script>
<script src="/js-test-resources/ui-helper.js"></script>
</head>
<body>
<script>
description('Tests that document.cookie returns the right value after a showModalDialog() call');
jsTestIsAsync = true;

function validateCookiesDuringChildFrameParsing(_cookiesInFrame)
{
    cookiesInFrame = _cookiesInFrame;
    shouldBeEqualToString('normalizeCookie(cookiesInFrame)', 'foo=bar; testKey=testValue');
    shouldBeEqualToString('normalizeCookie(document.cookie)', 'foo=bar; testKey=testValue');
    finishJSTest();    
}

onload = () => {
    document.cookie = "testKey=testValue";
    shouldBeEqualToString('normalizeCookie(document.cookie)', 'testKey=testValue');

    // This is so the cookie gets removed at the end of the test.
    registerCookieForCleanup('foo=bar; path=/');

    let iframe = document.createElement("iframe");
    iframe.src = "resources/set-cookie-and-serve.py?cookie-name=foo&cookie-value=bar&destination=document-cookie-during-iframe-parsing-iframe.html";
    document.body.appendChild(iframe);
};
</script>
<script src='resources/cookies-test-post.js'></script>
</body>
</html>
