chromium/third_party/blink/web_tests/fast/xpath/xpath-snapshot-result-should-mark-its-nodeset.html

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

        var types = [ XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
                      XPathResult.ORDERED_NODE_SNAPSHOT_TYPE ];

        function test(type)
        {
            var result;
            function initialize() {
                result = document.evaluate("//div", document.documentElement, null, type, null);
                result.snapshotItem(0).foo = "PASS";
                document.body.removeChild(result.snapshotItem(0));
            }

            // Do initialization work in an inner function to avoid references
            // to objects remaining live on this function's stack frame
            // (http://crbug.com/595672/).
            initialize();
            gc();
            var console = document.getElementById("console");
            console.appendChild(document.createTextNode(result.snapshotItem(0).foo));
            console.appendChild(document.createElement("br"));
        }

        function tests()
        {
            while (types.length) {
                test(types.pop());
            }
        }
    </script>
</head>
<body onload="tests()">
<div></div>
<div></div>
<div> Test for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=34231">34231</a>: Nodes in XPath result snapshots should keep JS wrappers alive.</div>
<div> For this test to PASS you should see 2 PASS below.</div><br>
<div id="console"></div>
</body></html>