tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / forms / script-tests / select-set-length-with-mutation-remove.js
1 description('Tests that setting .length on an HTMLSelectElement works in the presence of mutation listeners that remove option elements.');
2
3 function gc() {
4     if (window.GCController)
5         return GCController.collect();
6
7     for (var i=0; i<10000; ++i) {
8         var s = new String("abc");
9     }
10 }
11
12 function onRemove(e) {
13     if (e.target.nextSibling != null) {
14         // remove listener temporarily to avoid lots of nesting
15         sel.removeEventListener('DOMNodeRemoved', onRemove, false);
16         e.target.nextSibling.parentNode.removeChild(e.target.nextSibling);
17         sel.addEventListener('DOMNodeRemoved', onRemove, false);
18     }
19     gc();
20 }
21
22 var sel = document.createElement('select');
23 document.body.appendChild(sel);
24
25 sel.addEventListener('DOMNodeRemoved', onRemove, false);
26 sel.addEventListener('DOMNodeInserted', function() {}, false);
27
28 sel.length = 200;
29 shouldBe('sel.length', '200');
30
31 sel.length = 100;
32 shouldBe('sel.length', '100');
33
34 sel.length = 180;
35 shouldBe('sel.length', '180');