<!DOCTYPE html>
<html>
<body>
<script src="../../../resources/gc.js"></script>
<script src="../../../resources/js-test.js"></script>
<script>
window.jsTestIsAsync = true;
var callbackWasTriggered = false;
var nodeIterator, callbackObservation, nodeFilterObservation,
nodeIteratorObservation;
(async () => {
// Do initialization work in an inner function to avoid references to
// objects remaining live on this function's stack frame.
// (http://crbug.com/595672/).
(function() {
var callback = function(node) {
callbackWasTriggered = true;
return NodeFilter.FILTER_ACCEPT;
};
nodeIterator = document.createNodeIterator(document,
NodeFilter.SHOW_ELEMENT, callback, false);
callbackObservation = internals.observeGC(callback);
nodeFilterObservation = internals.observeGC(nodeIterator.filter);
nodeIteratorObservation = internals.observeGC(nodeIterator);
})()
await asyncGC();
shouldBeFalse('nodeFilterObservation.wasCollected');
shouldBeFalse('callbackObservation.wasCollected');
(function() {
nodeIterator.nextNode();
nodeIterator = null;
})();
shouldBeTrue('callbackWasTriggered');
await asyncGC();
shouldBeTrue('nodeIteratorObservation.wasCollected');
shouldBeTrue('nodeFilterObservation.wasCollected');
shouldBeTrue('callbackObservation.wasCollected');
finishJSTest();
})();
</script>
</body>
</html>