4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
10 description('Test for .text for OPTION element');
12 // See http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#space-character
14 String
.fromCharCode(0x20),
15 String
.fromCharCode(0x09),
16 String
.fromCharCode(0x0A),
17 String
.fromCharCode(0x0C),
18 String
.fromCharCode(0x0D)
21 // Unicode white spaces which are not handled as white space
22 // when removing spaces on option element.
23 // These are taken from Unicode PropList.txt
25 String
.fromCharCode(0x0B),
26 String
.fromCharCode(0x85),
27 String
.fromCharCode(0xA0),
28 String
.fromCharCode(0x1680),
29 String
.fromCharCode(0x180E),
30 String
.fromCharCode(0x2000),
31 String
.fromCharCode(0x2001),
32 String
.fromCharCode(0x2002),
33 String
.fromCharCode(0x2003),
34 String
.fromCharCode(0x2004),
35 String
.fromCharCode(0x2005),
36 String
.fromCharCode(0x2006),
37 String
.fromCharCode(0x2007),
38 String
.fromCharCode(0x2008),
39 String
.fromCharCode(0x2009),
40 String
.fromCharCode(0x200A),
41 String
.fromCharCode(0x2028),
42 String
.fromCharCode(0x2029),
43 String
.fromCharCode(0x202F),
44 String
.fromCharCode(0x205F),
45 String
.fromCharCode(0x3000)
48 var parent
= document
.createElement('div');
49 document
.body
.appendChild(parent
);
50 parent
.innerHTML
= '<select><option id=option></option></select>';
52 var option
= document
.getElementById('option');
56 debug('Insert one HTMLspace before/after/between the text');
57 for (var i
= 0; i
< HTMLSpaces
.length
; ++i
) {
58 option
.text
= HTMLSpaces
[i
] + 'text' + HTMLSpaces
[i
] + 'text' + HTMLSpaces
[i
];
59 expected
= 'text text';
60 shouldBe('option.text', 'expected');
64 debug('Insert multiple HTMLspaces before/after/between the text');
65 for (var i
= 0; i
< HTMLSpaces
.length
; ++i
) {
66 for (var j
= 0; j
< HTMLSpaces
.length
; ++j
) {
67 option
.text
= HTMLSpaces
[i
] + HTMLSpaces
[j
] + 'text' + HTMLSpaces
[i
] + HTMLSpaces
[j
] + 'text' + HTMLSpaces
[i
] + HTMLSpaces
[j
];
68 expected
= 'text text';
69 shouldBe('option.text', 'expected');
76 debug('Insert one nonHTMLspace before/after/between the text');
77 for (var i
= 0; i
< nonHTMLSpaces
.length
; ++i
) {
78 option
.text
= nonHTMLSpaces
[i
] + 'text' + nonHTMLSpaces
[i
] + 'text' + nonHTMLSpaces
[i
];
79 expected
= nonHTMLSpaces
[i
] + 'text' + nonHTMLSpaces
[i
] + 'text' + nonHTMLSpaces
[i
];
80 shouldBe('option.text', 'expected');
84 debug('Insert multiple nonHTMLspaces before/after/between the text');
85 for (var i
= 0; i
< nonHTMLSpaces
.length
; ++i
) {
86 for (var j
= 0; j
< nonHTMLSpaces
.length
; ++j
) {
87 option
.text
= nonHTMLSpaces
[i
] + nonHTMLSpaces
[j
] + 'text' + nonHTMLSpaces
[i
] + nonHTMLSpaces
[j
] + 'text' + nonHTMLSpaces
[i
] + nonHTMLSpaces
[j
];
88 expected
= nonHTMLSpaces
[i
] + nonHTMLSpaces
[j
] + 'text' + nonHTMLSpaces
[i
] + nonHTMLSpaces
[j
] + 'text' + nonHTMLSpaces
[i
] + nonHTMLSpaces
[j
];
89 shouldBe('option.text', 'expected');