<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function log(msg)
{
    document.getElementById("logger").innerHTML += msg + "<br>";
}

function testHistoryObject(historyToTest)
{
    try {
        historyToTest.replaceState(null, "Phishy Title", location.protocol + "//www.webkit.org" + "@" + location.host);
        log("replaceState with username worked, shouldn't have.");
    } catch(e) {
        log(e);
    }

    try {
        historyToTest.replaceState(null, "Phishy Title", location.protocol + "//:www.webkit.org" + "@" + location.host);
        log("replaceState with password worked, shouldn't have.");
    } catch(e) {
        log(e);
    }

    try {
        historyToTest.replaceState(null, "Phishy Title", location.protocol + "//www.webkit:org" + "@" + location.host);
        log("replaceState with username and password worked, shouldn't have.");
    } catch(e) {
        log(e);
    }

    try {
        historyToTest.replaceState(null, "Phishy Title", "blob:" + location.protocol + "//www.webkit:org" + "@" + location.host);
        log("replaceState with username and password worked, shouldn't have.");
    } catch(e) {
        log(e);
    }

    try {
        historyToTest.pushState(null, "Phishy Title", location.protocol + "//www.webkit.org" + "@" + location.host);
        log("pushState with username worked, shouldn't have.");
    } catch(e) {
        log(e);
    }

    try {
        historyToTest.pushState(null, "Phishy Title", location.protocol + "//:www.webkit.org" + "@" + location.host);
        log("pushState with password worked, shouldn't have.");
    } catch(e) {
        log(e);
    }

    try {
        historyToTest.pushState(null, "Phishy Title", location.protocol + "//www.webkit:org" + "@" + location.host);
        log("pushState with username and password worked, shouldn't have.");
    } catch(e) {
        log(e);
    }

    try {
        historyToTest.pushState(null, "Phishy Title", "blob:" + location.protocol + "//www.webkit:org" + "@" + location.host);
        log("pushState with username and password worked, shouldn't have.");
    } catch(e) {
        log(e);
    }
}

function clicked()
{
    newWindow = window.open('','newWindow');
    testHistoryObject(newWindow.history);
    if (window.testRunner)
        testRunner.notifyDone();
}

function loaded()
{
    testHistoryObject(window.history);

    if (window.eventSender) {
        var button = document.getElementById("theButton");
        eventSender.mouseMoveTo(button.offsetLeft + 5, button.offsetTop + 5);
        eventSender.mouseDown();
        eventSender.mouseUp();
    }
}

</script>
<body onload="loaded();">
<button id="theButton" onclick="clicked();">Click to test in new window</button>
<div id="logger"></div>
</body>
