chromium/third_party/blink/web_tests/fast/dom/node-filter-gc.html

<html>
<head>
<script src="../../resources/js-test.js"></script>
<script>
if (window.testRunner)
    testRunner.dumpAsText();

var filter = { acceptNode: function(node) { return true; } };
var iterator = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT, null);
var walker = document.createTreeWalker(document, NodeFilter.SHOW_ELEMENT, null);

// test that garbage collecting a node iterator or a tree walker without a
// filter doesn't crash.
gc();

// test that iterator keeps its filter alive
iterator = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT, filter);
filter = null;
shouldBeUndefined("iterator.filter.foo");
iterator.filter.foo = 42;
shouldBeEqualToNumber("iterator.filter.foo", 42);
gc();
shouldBeEqualToNumber("iterator.filter.foo", 42);

// test that walker keeps its filter alive
filter = { acceptNode: function(node) { return true; } };
walker = document.createTreeWalker(document, NodeFilter.SHOW_ELEMENT, filter);
shouldBeUndefined("walker.filter.foo");
filter = null;
walker.filter.foo = 42;
shouldBeEqualToNumber("walker.filter.foo", 42);
gc();
shouldBeEqualToNumber("walker.filter.foo", 42);

</script>
</head>
<body>
</body>
</html>