fune/dom/base/test/file_webaudio_startstop.html
Paul Adenot b9e645073e Bug 1375119 - Consider a page active if it has running AudioContexts. r=ehsan
MozReview-Commit-ID: IOQ2DY9LoTw

--HG--
extra : rebase_source : f47568d3db129ff8d9a484d5b5554f1154d53133
2017-07-24 11:17:14 +02:00

36 lines
630 B
HTML

<!DOCTYPE html>
<script>
var ac = new AudioContext();
var runningPromise = new Promise(resolve => {
ac.onstatechange = event => {
if (ac.state == "running") {
resolve();
}
};
});
var osc = ac.createOscillator();
osc.connect(ac.destination);
osc.start(0);
osc.stop(osc.context.currentTime + 2.0);
var suspendPromise;
function suspendAC() {
runningPromise.then(() => {
suspendPromise = ac.suspend();
});
}
var resumePromise;
function resumeAC() {
suspendPromise.then(() => {
resumePromise = ac.resume();
});
}
function closeAC() {
resumePromise.then(() => {
ac.close();
});
}
</script>