4 https://bugzilla.mozilla.org/show_bug.cgi?id=300691
7 <title>Test for Bug
300691</title>
8 <script type=
"text/javascript" src=
"/MochiKit/MochiKit.js"></script>
9 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <script type=
"text/javascript" src=
"/tests/SimpleTest/EventUtils.js"></script>
11 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
14 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=300691">Mozilla Bug
300691</a>
16 <textarea id=
"target"></textarea>
18 <div id=
"content" style=
"display: none">
22 <script class=
"testbody" type=
"text/javascript">
26 /** Test for Bug
300691 **/
27 function valueIs(arg, reason) {
28 is(t.value, arg, reason);
31 function defValueIs(arg, reason) {
32 is(t.defaultValue, arg, reason);
35 valueIs(
"",
"Nothing in the textarea");
36 defValueIs(
"",
"Nothing in the textarea 2");
38 t.appendChild(document.createTextNode(
"ab"));
39 valueIs(
"ab",
"Appended textnode");
40 defValueIs(
"ab",
"Appended textnode 2");
42 t.firstChild.data =
"abcd";
43 valueIs(
"abcd",
"Modified textnode text");
44 defValueIs(
"abcd",
"Modified textnode text 2");
46 t.appendChild(document.createTextNode(
"efgh"));
47 valueIs(
"abcdefgh",
"Appended another textnode");
48 defValueIs(
"abcdefgh",
"Appended another textnode 2");
50 t.removeChild(t.lastChild);
51 valueIs(
"abcd",
"Removed textnode");
52 defValueIs(
"abcd",
"Removed textnode 2");
54 t.appendChild(document.createTextNode(
"efgh"));
55 valueIs(
"abcdefgh",
"Appended yet another textnode");
56 defValueIs(
"abcdefgh",
"Appended yet another textnode 2");
59 valueIs(
"abcdefgh",
"Normalization changes nothing for the value");
60 defValueIs(
"abcdefgh",
"Normalization changes nothing for the value 2");
62 t.defaultValue =
"abc";
63 valueIs(
"abc",
"Just set the default value on non-edited textarea");
64 defValueIs(
"abc",
"Just set the default value on non-edited textarea 2");
66 t.appendChild(document.createTextNode(
"defgh"));
67 valueIs(
"abcdefgh",
"Appended another textnode again");
68 defValueIs(
"abcdefgh",
"Appended another textnode again 2");
70 t.focus(); // This puts the caret at the end of the textarea, and doing
71 // something like
"home" in a cross-platform way is kinda hard.
77 valueIs(
"abcdeTestfgh",
"Typed 'Test' after three left-arrows starting from end");
78 defValueIs(
"abcdefgh",
"Typing 'Test' shouldn't affect default value");
82 sendKey(
"back_space");
83 sendKey(
"back_space");
86 "Backspaced twice after two right-arrows starting from end of typing");
87 defValueIs(
"abcdefgh",
"Deleting shouldn't affect default value");
89 t.appendChild(document.createTextNode(
"ijk"));
91 "Appending textnode shouldn't affect value in edited textarea");
92 defValueIs(
"abcdefghijk",
"Appended textnode 3");
94 t.lastChild.data =
"lmno";
96 "Modifying textnode text shouldn't affect value in edited textarea");
97 defValueIs(
"abcdefghlmno",
"Modified textnode text 3");
99 t.removeChild(t.firstChild);
100 valueIs(
"abcdeTesth",
101 "Removing child textnode shouldn't affect value in edited textarea");
102 defValueIs(
"defghlmno",
"Removed textnode 3");
104 t.insertBefore(document.createTextNode(
"abc"), t.firstChild);
105 valueIs(
"abcdeTesth",
106 "Inserting child textnode shouldn't affect value in edited textarea");
107 defValueIs(
"abcdefghlmno",
"Inserted a text node");
110 valueIs(
"abcdeTesth",
"Normalization changes nothing for the value 3");
111 defValueIs(
"abcdefghlmno",
"Normalization changes nothing for the value 4");
113 t.defaultValue =
"abc";
114 valueIs(
"abcdeTesth",
"Setting default value shouldn't affect edited textarea");
115 defValueIs(
"abc",
"Just set the default value textarea");