Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / select-set-length-with-mutation-reparent.html
blob2b81d85adbc1d1ca3462afecfd88b6aca0fc8576
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
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);
31 sel.length = 200;
32 shouldBe('sel.length', '200');
33 shouldBe('otherSel.length', '0');
35 sel.length = 100;
36 shouldBe('sel.length', '100');
37 shouldBe('otherSel.length', '0');
39 sel.length = 180;
40 shouldBe('sel.length', '180');
41 shouldBe('otherSel.length', '0');
42 </script>
43 </body>
44 </html>