4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description">Tests to check behaviors of dirty flag and defaultValue change.
</p>
8 <div id=
"console"></div>
10 <textarea name=textarea id=textarea
>
16 var form
= document
.getElementById('form');
17 var textarea
= document
.getElementById('textarea');
19 // Dirty by execCommand(), then setDefaultValue().
22 shouldBe('document.execCommand("InsertText", false, "user-updated"); textarea.value', '"user-updated"');
23 shouldBe('textarea.defaultValue = "default 2"; textarea.value', '"user-updated"');
24 shouldBe('form.reset(); textarea.value', '"default 2"');
25 shouldBe('textarea.defaultValue = "default 3"; textarea.value', '"default 3"');
27 // Dirty by setValue(), then setDefaultValue().
28 shouldBe('textarea.value = "script-updated"; textarea.value', '"script-updated"');
29 shouldBe('textarea.defaultValue = "default 4"; textarea.value', '"script-updated"');
30 shouldBe('form.reset(); textarea.value', '"default 4"');
32 // Dirty by setValue(), then update defaultValue by innerHTML.
33 shouldBe('textarea.value = "script-updated"; textarea.value', '"script-updated"');
34 shouldBe('textarea.innerHTML = "default 5"; textarea.value', '"script-updated"');
35 shouldBe('form.reset(); textarea.value', '"default 5"');
36 shouldBe('textarea.innerHTML = "default 6"; textarea.value', '"default 6"');
38 // Dirty by setValue(), then update defaultValue by DOM tree operations.
39 shouldBe('textarea.value = "script-updated"; textarea.value', '"script-updated"');
40 shouldBe('textarea.removeChild(textarea.firstChild); textarea.appendChild(document.createTextNode("default 5")); textarea.value', '"script-updated"');
41 shouldBe('form.reset(); textarea.value', '"default 5"');
42 shouldBe('textarea.removeChild(textarea.firstChild); textarea.appendChild(document.createTextNode("default 6")); textarea.value', '"default 6"');