Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit fa7b42a

Browse files
committed
Bug 1608286 - Crash in [@ mozilla::dom::MediaKeySystemAccessManager::CheckDoesWindowSupportProtectedMedia] r=bryce,bzbarsky
This changes fixes a failfast in a call to Navigator.requestMediaKeySystemAccess for the case where there is no browser available from a window when e10s is on. This can happen when a document is disconnected from the DOM. The fix is to reject the promise in this case. Differential Revision: https://phabricator.services.mozilla.com/D60022 --HG-- extra : moz-landing-system : lando
1 parent 9847ab1 commit fa7b42a

3 files changed

Lines changed: 61 additions & 4 deletions

File tree

dom/media/eme/MediaKeySystemAccessManager.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,18 @@ void MediaKeySystemAccessManager::CheckDoesWindowSupportProtectedMedia(
134134
RefPtr<BrowserChild> browser(BrowserChild::GetFrom(mWindow));
135135
if (!browser) {
136136
if (!XRE_IsParentProcess() || XRE_IsE10sParentProcess()) {
137-
MOZ_CRASH("BrowserChild should only be unavailable with e10s off");
138-
}
137+
// In this case, there is no browser because the Navigator object has
138+
// been disconnected from its window. Thus, reject the promise.
139+
aRequest->mPromise->MaybeRejectWithTypeError(
140+
u"Browsing context is no longer available");
141+
} else {
142+
// In this case, there is no browser because e10s is off. Proceed with
143+
// the request with support since this scenario is always supported.
144+
MKSAM_LOG_DEBUG("Allowing protected media on Windows with e10s off.");
139145

140-
MKSAM_LOG_DEBUG("Allowing protected media on Windows with e10s off.");
146+
OnDoesWindowSupportProtectedMedia(true, std::move(aRequest));
147+
}
141148

142-
OnDoesWindowSupportProtectedMedia(true, std::move(aRequest));
143149
return;
144150
}
145151

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<html class="reftest-wait">
2+
<head>
3+
<script>
4+
function test() {
5+
function checkResolve(value) {
6+
// Let the test timeout and fail
7+
throw new Error("This promise should not resolve");
8+
}
9+
10+
function checkReject(reason) {
11+
if (reason.message !== "Browsing context is no longer available") {
12+
// Let the test timeout and fail
13+
throw new Error("Unexpected rejected promise reason");
14+
}
15+
// Otherwise, successfully rejected a request not attached to a
16+
// window without crashing
17+
}
18+
19+
var i = document.querySelector("iframe");
20+
var nav = i.contentWindow.navigator;
21+
i.remove();
22+
23+
// First, check with valid args
24+
nav.requestMediaKeySystemAccess(
25+
"com.widevine.alpha",
26+
[{
27+
initDataTypes: ["webm"],
28+
videoCapabilities: [{ contentType: 'video/webm; codecs="vp9"' }]
29+
}]
30+
).then(
31+
checkResolve,
32+
(reason) => {
33+
checkReject(reason);
34+
35+
// Then, check with invalid args
36+
nav.requestMediaKeySystemAccess("", []).then(
37+
checkResolve,
38+
(reason) => {
39+
checkReject(reason);
40+
document.documentElement.removeAttribute("class");
41+
}
42+
);
43+
});
44+
}
45+
</script>
46+
</head>
47+
<body onload="test()">
48+
<iframe></iframe>
49+
</body>
50+
</html>

dom/media/test/crashtests/crashtests.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,4 @@ load 1577184.html
135135
pref(media.autoplay.default,0) load 1587248.html
136136
load 1594466.html
137137
load 1604941.html
138+
load 1608286.html

0 commit comments

Comments
 (0)