<html>
<head>
<script>
function log(message)
{
    var paragraph = document.createElement("p");
    paragraph.appendChild(document.createTextNode(message));
    document.getElementById("console").appendChild(paragraph);
}

function expect(expected, actual)
{
    var msg = "Expected " + expected + ", got " + actual + ": ";
    if (expected == actual)
        log(msg + "PASS");
    else
        log(msg + "FAIL");
}

function test()
{
    if (window.testRunner)
        window.testRunner.dumpAsText();

    expect(0, document.getElementsByTagName('title').length);
    document.title = 'Document title';
    expect(1, document.getElementsByTagName('title').length);
}
</script>
</head>
<body>
<p>Test that setting document.title creates a title element and appends it to the documents head if one does not already exist, as
   per <a href='http://whatwg.org/specs/web-apps/current-work/#the-title1'>http://whatwg.org/specs/web-apps/current-work/#the-title1</a>.</p>
<hr>
<div id='console'/>
<script>
    test();
</script>
</body>
</html>
