1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
10 description('Tests that setting .length on an HTMLSelectElement works in the presence of mutation event listeners that reparent options');
12 var sel
= document
.createElement('select');
13 document
.body
.appendChild(sel
);
14 var otherSel
= document
.createElement('select');
15 document
.body
.appendChild(otherSel
);
17 function onRemove(e
) {
18 if (e
.target
.nextSibling
!= null) {
19 // remove listener temporarily to avoid lots of nesting
20 sel
.removeEventListener('DOMNodeRemoved', onRemove
, false);
21 var n
= e
.target
.nextSibling
;
22 n
.parentNode
.removeChild(n
);
23 otherSel
.appendChild(n
);
24 sel
.addEventListener('DOMNodeRemoved', onRemove
, false);
28 sel
.addEventListener('DOMNodeRemoved', onRemove
, false);
29 sel
.addEventListener('DOMNodeInserted', function() {}, false);
32 shouldBe('sel.length', '200');
33 shouldBe('otherSel.length', '0');
36 shouldBe('sel.length', '100');
37 shouldBe('otherSel.length', '0');
40 shouldBe('sel.length', '180');
41 shouldBe('otherSel.length', '0');