chromium/third_party/blink/web_tests/fast/dom/gc-custom-prototype.html

<p>Tests that custom prototypes on DOM objects persist after garbage collection.</p>
<pre id="console"></pre>

<p id="p"></p>
<script src="../../resources/gc.js"></script>
<script>
function $(id)
{
    return document.getElementById(id);
}

function log(s)
{
    $("console").appendChild(document.createTextNode(s + "\n"));
}

function shouldBe(aDescription, a, b)
{
    if (a != b) {
        log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
        return;
    }

    log("PASS: " + aDescription + " should be " + b + " and is.");
}

function shouldBeNull(aDescription, a)
{
    if (a == null) {
        log("PASS: " + aDescription + " should be null and is.");
        return;
    }
    
    log("FAIL: " + aDescription + " should be null but instead is " + a + ".");
}

function shouldBeNonNull(aDescription, a)
{
    if (a != null) {
        log("PASS: " + aDescription + " should be null and is.");
        return;
    }
    
    log("FAIL: " + aDescription + " should be null but instead is " + a + ".");
}

(function () {
    if (window.testRunner)
        testRunner.dumpAsText();

    shouldBeNonNull("$('p').__proto__", $('p').__proto__);
    $('p').__proto__ = null;
    shouldBeNull("$('p').__proto__", $('p').__proto__);

    gc();

    shouldBeNull("$('p').__proto__", $('p').__proto__);
})();
</script>