Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<meta charset=utf-8>
<title>The output element</title>
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<output id=output></output>
<output id="defaultValueOutput">abc</output>
<script>
var output = document.getElementById("output");
var defaultValueOutput = document.getElementById("defaultValueOutput");
test(function(){
assert_equals(output.type, "output", "type must return the string 'output'");
assert_equals(output.textContent, "", "textContent is empty");
assert_equals(output.value, "", "value should be empty");
assert_equals(output.defaultValue, "", "defaultValue should be empty");
output.textContent="5";
assert_equals(output.value, "5", "textContent is set to 5: value is updated");
assert_equals(output.textContent, "5", "textContent is set to 5");
assert_equals(output.defaultValue, "5", "textContent is set to 5: defaultValue is updated");
output.defaultValue="10"; // value mode flag is in "default" mode. Setting defaultValue should set textContent as well
assert_equals(output.value, "10", "defaultValue is set to 10: value is updated");
assert_equals(output.textContent, "10", "defaultValue is set to 10: textContent is updated");
assert_equals(output.defaultValue, "10", "defaultValue is set to 10");
output.value="20"; // set the value mode flag to "value": default value remains unchanged
assert_equals(output.value, "20", "value is set to 20");
assert_equals(output.textContent, "20", "value is set to 20: textContent is updated");
assert_equals(output.defaultValue, "10", "value is set to 20: defaultValue remains unchanged");
output.defaultValue="15"; // value mode flag is in "value" mode. textContent remains unchanged when setting defaultValue
assert_equals(output.value, "20", "defaultValue is set to 15: value remains unchanged");
assert_equals(output.textContent, "20", "defaultValue is set to 15: textContent remains unchanged");
assert_equals(output.defaultValue, "15", "defaultValue is set to 15");
assert_equals(defaultValueOutput.type, "output", "type must return the string 'output'");
assert_equals(defaultValueOutput.textContent, "abc", "textContent should be 'abc'");
assert_equals(defaultValueOutput.value, "abc", "value should be 'abc'");
assert_equals(defaultValueOutput.defaultValue, "abc", "defaultValue should be 'abc'");
}, "output value and defaultValue");
</script>