chromium/third_party/blink/web_tests/fast/dom/option-properties.html

<html>
<head>
<script>
function print(message, color) 
{
    var paragraph = document.createElement("div");
    paragraph.appendChild(document.createTextNode(message));
    paragraph.style.fontFamily = "monospace";
    if (color)
        paragraph.style.color = color;
    document.getElementById("console").appendChild(paragraph);
}

function shouldBe(a, b)
{
    var evalA = eval(a);
    if (evalA == b)
        print("PASS: " + a + " should be " + b + " and is.", "green");
    else
        print("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".", "red");
}

function test() 
{
    if (window.testRunner)
        testRunner.dumpAsText();
        
    document.getElementById('sel').options[1].selected = true;
    shouldBe("document.getElementById('sel').options.selectedIndex", 1);
    shouldBe("document.getElementById('sel').options[1].selected", true);

    document.getElementById('sel').options[1].text = "PASS";
    shouldBe("document.getElementById('sel').options[1].text", "PASS");
}
</script>
</head>

<body onload="test();">
<p>This page tests setting 'selected' and 'text' on an option element. See <a href="https://bugs.webkit.org/show_bug.cgi?id=9095">https://bugs.webkit.org/show_bug.cgi?id=9095</a>.</p>
<p>If the test passes, you'll see a series of 'PASS' messages below.</p>
<hr>
<div id='console'></div>

<form>
    <select id='sel'>
        <option value='bad'>FAIL</option>
        <option value='good'>FAIL</option>
    </select>
</form>

</body>
</html>