blob: 3d44bd08fa1d5afee19f5b0631d569125094d4fc [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description('Tests that setting .length on an HTMLSelectElement works in the presence of mutation listeners that remove option elements.');
function onRemove(e) {
if (e.target.nextSibling != null) {
// remove listener temporarily to avoid lots of nesting
sel.removeEventListener('DOMNodeRemoved', onRemove, false);
e.target.nextSibling.parentNode.removeChild(e.target.nextSibling);
sel.addEventListener('DOMNodeRemoved', onRemove, false);
}
GCController.collect(); // Use a single GC here to avoid test TIMEOUTs.
}
var sel = document.createElement('select');
document.body.appendChild(sel);
sel.addEventListener('DOMNodeRemoved', onRemove, false);
sel.addEventListener('DOMNodeInserted', function() {}, false);
sel.length = 200;
shouldBe('sel.length', '200');
sel.length = 100;
shouldBe('sel.length', '100');
sel.length = 180;
shouldBe('sel.length', '180');
</script>
</body>
</html>