<!DOCTYPE html>
<title>GC while playing</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
async_test(function(t)
{
var a = document.createElement("audio");
a.foo = "bar";
a.src = "content/test.oga";
a.onsuspend = t.step_func(function()
{
assert_equals(a.networkState, a.NETWORK_IDLE);
a.play();
// Continue after a timeout since the current event target is the media
// element, which means that it cannot be garbage collected now.
setTimeout(t.step_func(gcAndAwaitTimeupdate), 0);
});
function gcAndAwaitTimeupdate()
{
a.ontimeupdate = t.step_func(function(e)
{
assert_greater_than(e.target.currentTime, 0);
assert_equals(e.target.foo, "bar");
t.done();
});
a = null;
gc();
}
});
</script>