chromium/third_party/blink/web_tests/fast/media/media-query-listener-gc.html

<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>

<div id="sandbox"></div>

<script>
    description("Media query listeners should work even after gc.");
    var jsTestIsAsync = true;

    var sandbox = document.getElementById("sandbox");
    var iframe = document.createElement("iframe");
    sandbox.appendChild(iframe);

    var matchMedia = iframe.contentWindow.matchMedia;
    var mediaList1 = matchMedia("(max-width: 100px)");

    var listenersCalled = [];

    function makeListener(label) {
        return function() { listenersCalled.push(label); };
    }

    mediaList1.addListener(makeListener("mediaList1_1"));
    mediaList1.addListener(verifyResult);
    mediaList1 = null;
    gc();
    iframe.style.width = "80px";

    var expectedResult = ["mediaList1_1"];
    function verifyResult() {
        shouldBe("listenersCalled", "expectedResult");
        finishJSTest();
    }
</script>