<!DOCTYPE html>
<html>
<body>
<p>Test for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=45372">45372</a>: https://bugs.webkit.org/show_bug.cgi?id=45372</p>
<p>Test EventSource with an event-stream with a Content-Type with a charset is still recognized. You should see 5 PASSED below.</p>
<div id="result"></div>
<script>
function log(msg) {
    document.getElementById("result").innerHTML += msg + "<br>";
}

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function shouldGetMessage(es)
{
    if (es.sawOpen && es.sawMessage && !es.sawError)
        log("PASSED: " + es.contentType);
    else
        log("FAILED: " + es.contentType);
}

function shouldFail(es)
{
    if (es.sawError && !es.sawOpen && !es.sawMessages)
        log("PASSED: " + es.contentType);
    else
        log("FAILED: " + es.contentType);
}

var i = 0;
var contentTypes = [ 'text/event-stream; charset=UTF-8',
                     'text/event-stream; charset=windows-1251',
                     'text/event-stream; charset=utf-8',
                     'text/event-stream; charset="UTF-8"',
                     'text/event-stream-foobar;'
                   ];

var expectedResultCallback = [ shouldGetMessage,
                               shouldGetMessage,
                               shouldGetMessage,
                               shouldGetMessage,
                               shouldFail
                             ];

function openListener(evt) {
    evt.target.sawOpen = true;
};

function messageListener(evt) {
    evt.target.sawMessage = true;
    evt.target.successCallback(evt.target);
    evt.target.close();
    next();
};

function errorListener(evt) {
    evt.target.sawError = true;
    evt.target.successCallback(evt.target);
    evt.target.close();
    next();
};

function startRequest()
{
    es = new EventSource("resources/response-content-type-charset.py?contentType=" + escape(contentTypes[i]));
    es.onopen = openListener;
    es.onmessage = messageListener;
    es.onerror = errorListener;
    es.successCallback = expectedResultCallback[i];
    es.contentType = contentTypes[i];
    ++i;
}

function next() {
    if (i >= contentTypes.length) {
        end();
        return;
    }
    startRequest();
}

function end() {
    if (window.testRunner)
        testRunner.notifyDone();
}
startRequest();
</script>
</body>
</html>
