  <div class="buckets"
   ><p id="bucket1" class="z"></p
   ><p id="bucket2" class="z"></p
   ><p id="bucket3" class="z"></p
   ><p id="bucket4" class="z"></p
   ><p id="bucket5" class="z"></p
   ><p id="bucket6" class="z"></p>
  </div>
<p>There should be no assertion failures below, but the word DONE should show up.</p>
<script>
if (window.layoutTestController) {
    layoutTestController.dumpAsText();
}
</script>
<script>
  function fail(message) {
      document.write(message + "<br>");
  }
  function assert(condition, message) {
    if (!condition)
      fail(message);
  }
  function assertEquals(expression, value, message) {
    if (expression != value) {
      expression = (""+expression).replace(/[\r\n]+/g, "\\n");
      value = (""+value).replace(/\r?\n/g, "\\n");
      fail("expected: " + value + ", got: " + expression + " - " + message);
    }
  }


      var d;
      // e1 - an element that's in a document
      d = document.implementation.createDocument(null, null, null);
      var e1 = d.createElement('test1');
      d.appendChild(d.createElement('root'));
      d.documentElement.appendChild(e1);
      assert(e1.parentNode, "e1 - parent element doesn't exist");
      assert(e1.parentNode.ownerDocument, "e1 - document doesn't exist");
      // e2 - an element that's not in a document
      d = document.implementation.createDocument(null, null, null);
      var e2 = d.createElement('test2');
      d.createElement('root').appendChild(e2);
      assert(e2.parentNode, "e2 - parent element doesn't exist");
      assert(e2.parentNode.ownerDocument, "e2 - document doesn't exist");
      // now try to decouple them
      d = null;

      kungFuDeathGrip = [e1, e2];
      assert(e1.parentNode, "e1 - parent element doesn't exist after dropping reference to document");
      assert(e1.parentNode.ownerDocument, "e1 - document doesn't exist after dropping reference to document");
      assert(e2.parentNode, "e2 - parent element doesn't exist after dropping reference to document");
      assert(e2.parentNode.ownerDocument, "e2 - document doesn't exist after dropping reference to document");
      var loops = ((new Date().valueOf() - 1.1e12) / 32e9) * 0x500; // increases linearly over time
      for (var i = 0; i < loops; i += 1) {
        // we want to force a GC here, so we use up lots of memory
        // we take the opportunity to sneak in a perf test to make DOM and JS stuff faster...
        d = new Date();
        d = new (function (x) { return { toString: function () { return x.toString() } } })(d.valueOf());
        d = document.createTextNode("iteration " + i + " at " + d);
        document.createElement('a').appendChild(d);
        d = d.parentNode;
        document.body.insertBefore(d, document.getElementById('bucket1').parentNode);
        assert(document.getElementById('bucket2').nextSibling.parentNode.previousSibling.firstChild.data.match(/AT\W/i), "iteration " + i + " failed");
        d.setAttribute('class', d.textContent);
        document.body.removeChild(d);
      }

      assert(e1.parentNode, "e1 - parent element doesn't exist after looping");
      assert(e1.parentNode.ownerDocument, "e1 - document doesn't exist after looping");
      assertEquals(e1.parentNode.ownerDocument.nodeType, 9, "e1 - document node type has wrong node type");
      assert(e2.parentNode, "e2 - parent element doesn't exist after looping");
      assert(e2.parentNode.ownerDocument, "e2 - document doesn't exist after looping");
      assertEquals(e2.parentNode.ownerDocument.nodeType, 9, "e2 - document node type has wrong node type");

</script>
<p>DONE</p>
