зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1692385 add some memory usage testing for setSinkId() r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D106251
This commit is contained in:
Родитель
113df4f3a2
Коммит
1fe1bca9b7
|
@ -892,6 +892,36 @@ function haveEventsButNoMore(target, name, count, cancel) {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Resolves the returned promise with an object with usage and reportCount
|
||||
* properties. `usage` is in the same units as reported by the reporter for
|
||||
* `path`.
|
||||
*/
|
||||
const collectMemoryUsage = async path => {
|
||||
const MemoryReporterManager = Cc[
|
||||
"@mozilla.org/memory-reporter-manager;1"
|
||||
].getService(Ci.nsIMemoryReporterManager);
|
||||
|
||||
let usage = 0;
|
||||
let reportCount = 0;
|
||||
await new Promise(resolve =>
|
||||
MemoryReporterManager.getReports(
|
||||
(aProcess, aPath, aKind, aUnits, aAmount, aDesc) => {
|
||||
if (aPath != path) {
|
||||
return;
|
||||
}
|
||||
++reportCount;
|
||||
usage += aAmount;
|
||||
},
|
||||
null,
|
||||
resolve,
|
||||
null,
|
||||
/* anonymized = */ false
|
||||
)
|
||||
);
|
||||
return { usage, reportCount };
|
||||
};
|
||||
|
||||
/**
|
||||
* This class executes a series of functions in a continuous sequence.
|
||||
* Promise-bearing functions are executed after the previous promise completes.
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
bug: "934425",
|
||||
});
|
||||
|
||||
const memoryReportPath = 'explicit/media/media-manager-aggregates';
|
||||
|
||||
/**
|
||||
* Run a test to verify set sink id in audio element.
|
||||
*/
|
||||
|
@ -48,6 +50,28 @@
|
|||
ok(true, `Set sink id expected to fail: ${error}`);
|
||||
is(error.name, "NotFoundError", "Verify correct error");
|
||||
}
|
||||
|
||||
const {usage: usage1} =
|
||||
await collectMemoryUsage(memoryReportPath); // Provided by head.js
|
||||
|
||||
ok(usage1 > 0, "MediaManager memory usage should be non-zero to store \
|
||||
device ids after enumerateDevices");
|
||||
|
||||
const p2 = audio.setSinkId("");
|
||||
is(audio.sinkId, audioDevices[0].deviceId,
|
||||
'sinkId after setSinkId("") return');
|
||||
is(await p2, undefined,
|
||||
"promise resolution value when sinkId parameter is empty");
|
||||
is(audio.sinkId, "", 'sinkId after setSinkId("") resolution');
|
||||
|
||||
await audio.setSinkId(audioDevices[0].deviceId);
|
||||
|
||||
const {usage: usage2, reportCount} =
|
||||
await collectMemoryUsage(memoryReportPath);
|
||||
is(reportCount, 1,
|
||||
'Expect only one MediaManager to report in content processes.');
|
||||
is(usage2, usage1, "MediaManager memory usage should return to previous \
|
||||
value after promise resolution");
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче