<html>
<script>
var frame;

if (!window.gc) {
    window.gc = function() {
        if (window.GCController)
            return GCController.collect();
        for (var i = 0; i < 10000; i++) {
            var s = new String("abc");
        }
    }
}

function done() {
    document.body.innerHTML = 'PASS: handler not supported or did not crash when removing Windows during ondeviceorientation event';
    if (window.testRunner)
        testRunner.notifyDone();
}

function remove() {
    frame = null;
    document.body.innerHTML = '';
    gc();
    setTimeout(done, 0);
}

function crash() {
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    frame = document.createElement('iframe');
    document.body.appendChild(frame);

    if (!frame.contentWindow.ondeviceorientation)
        done();
    else
        frame.contentWindow.ondeviceorientation = remove;
}
</script>
<body onload="crash()">
</body>
</html>
