<!DOCTYPE html>

<script src="../../../resources/js-test-pre.js"></script>

<script>
description('MutationObserver wrappers should survive GC for passing into the callback even if JS has lost references.');

jsTestIsAsync = true;

function addObserver(node, fn) {
    var observer = new MutationObserver(fn);
    observer.testProperty = true;
    observer.observe(node, {attributes:true});
}

onload = function() {
    addObserver(document.body, function(records, observer) {
        window.observer = observer;
        shouldBe('observer.testProperty', 'true');
        finishJSTest();
    });

    gc();

    document.body.setAttribute('touch', 'the node');
};
</script>

<script src="../../../resources/js-test-post.js"></script>
