Bug 1775499 - check for null GetParentObject in Performance::Measure. r=sefeng

Root cause: the global object can be null but I wasn't checking for it so it
caused a crash. I don't remember under what conditions it can be null but I saw
I had checked for null when I wrote Performance::Mark and remember debugging it
so it makes sense to do so here as well.

Differential Revision: https://phabricator.services.mozilla.com/D151960
This commit is contained in:
Michael Comella 2022-07-27 18:17:17 +00:00
parent 1b282f99f4
commit bd58669a22

View File

@ -528,6 +528,11 @@ already_AddRefed<PerformanceMeasure> Performance::Measure(
JSContext* aCx, const nsAString& aName,
const StringOrPerformanceMeasureOptions& aStartOrMeasureOptions,
const Optional<nsAString>& aEndMark, ErrorResult& aRv) {
if (!GetParentObject()) {
aRv.ThrowInvalidStateError("Global object is unavailable");
return nullptr;
}
// When resisting fingerprinting, we don't add marks to the buffer. Since
// measure relies on relationships between marks in the buffer, this method
// will throw if we look for user-entered marks so we return a dummy measure