<!DOCTYPE html>
<script src="../../resources/js-test-pre.js"></script>
<div id=container>
  <span id=el>
  </span>
</div>
<script>
description('Test that DOMSubtreeModified listeners cannot cause DocumentOrderedMap to be incorrect');

var counter = 0;
var container = document.getElementById('container');
var el = document.getElementById('el');
function broken() {
   if (++counter > 2) {
       document.removeEventListener('DOMSubtreeModified', broken, true);
       return;
   } else if (counter == 1)
       container.innerText = '';
   else
       container.appendChild(el);
}

document.addEventListener("DOMSubtreeModified", broken, true);
broken();
shouldBeTrue("document.contains(el)");
el.parentNode.removeChild(el);
el = null;
gc();
shouldBeNull("document.getElementById('el')");
</script>
<script src="../../resources/js-test-post.js"></script>
