Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: dom/media/webaudio/test/mochitest.toml
<!DOCTYPE HTML>
<html>
<head>
<title>Web Audio memory reporting</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
var ac = new AudioContext();
var sp = ac.createScriptProcessor(4096, 1, 1);
sp.connect(ac.destination);
// Not started so as to test
var oac = new OfflineAudioContext(1, 1, 48000);
var nodeTypes = ["ScriptProcessorNode", "AudioDestinationNode"];
var objectTypes = ["dom-nodes", "engine-objects", "track-objects"];
var usages = { "explicit/webaudio/audiocontext": 0 };
for (var i = 0; i < nodeTypes.length; ++i) {
for (var j = 0; j < objectTypes.length; ++j) {
usages["explicit/webaudio/audio-node/" +
nodeTypes[i] + "/" + objectTypes[j]] = 0;
}
}
var handleReport = function(aProcess, aPath, aKind, aUnits, aAmount) {
if (aPath in usages) {
usages[aPath] += aAmount;
}
}
var finished = function () {
ok(true, "Yay didn't crash!");
for (var resource in usages) {
ok(usages[resource] > 0, "Non-zero usage for " + resource);
};
SimpleTest.finish();
}
SpecialPowers.Cc["@mozilla.org/memory-reporter-manager;1"].
getService(SpecialPowers.Ci.nsIMemoryReporterManager).
getReports(handleReport, null, finished, null, /* anonymized = */ false);
// the tasks from getReports() are expected to run.
ac.decodeAudioData(new ArrayBuffer(4), function(){}, function(){});
</script>
</html>