Bug 1442294 - Downgrade global streaming indicator when a higher priority device has been disabled. r=florian
MozReview-Commit-ID: 6GxXNsB6xYy
--- a/browser/base/content/test/webrtc/head.js
+++ b/browser/base/content/test/webrtc/head.js
@@ -470,16 +470,20 @@ async function checkSharingUI(aExpected,
let doc = aWin.document;
// First check the icon above the control center (i) icon.
let identityBox = doc.getElementById("identity-box");
ok(identityBox.hasAttribute("sharing"), "sharing attribute is set");
let sharing = identityBox.getAttribute("sharing");
if (aExpected.screen)
is(sharing, "screen", "showing screen icon in the identity block");
+ else if (aExpected.video == STATE_CAPTURE_ENABLED)
+ is(sharing, "camera", "showing camera icon in the identity block");
+ else if (aExpected.audio == STATE_CAPTURE_ENABLED)
+ is(sharing, "microphone", "showing mic icon in the identity block");
else if (aExpected.video)
is(sharing, "camera", "showing camera icon in the identity block");
else if (aExpected.audio)
is(sharing, "microphone", "showing mic icon in the identity block");
let allStreamsPaused = Object.values(aExpected).every(isPaused);
is(identityBox.hasAttribute("paused"), allStreamsPaused,
"sharing icon(s) should be in paused state when paused");
--- a/browser/modules/ContentWebRTC.jsm
+++ b/browser/modules/ContentWebRTC.jsm
@@ -379,30 +379,41 @@ function getTabStateForContentWindow(aCo
tabState.screen = "ScreenPaused";
else if (window.value == MediaManagerService.STATE_CAPTURE_DISABLED)
tabState.screen = "WindowPaused";
else if (app.value == MediaManagerService.STATE_CAPTURE_DISABLED)
tabState.screen = "ApplicationPaused";
else if (browser.value == MediaManagerService.STATE_CAPTURE_DISABLED)
tabState.screen = "BrowserPaused";
- if (tabState.screen) {
+ let screenEnabled = tabState.screen && !tabState.screen.includes("Paused");
+ let cameraEnabled = tabState.camera == MediaManagerService.STATE_CAPTURE_ENABLED;
+ let microphoneEnabled = tabState.microphone == MediaManagerService.STATE_CAPTURE_ENABLED;
+
+ // tabState.sharing controls which global indicator should be shown
+ // for the tab. It should always be set to the _enabled_ device which
+ // we consider most intrusive (screen > camera > microphone).
+ if (screenEnabled) {
+ tabState.sharing = "screen";
+ } else if (cameraEnabled) {
+ tabState.sharing = "camera";
+ } else if (microphoneEnabled) {
+ tabState.sharing = "microphone";
+ } else if (tabState.screen) {
tabState.sharing = "screen";
} else if (tabState.camera) {
tabState.sharing = "camera";
} else if (tabState.microphone) {
tabState.sharing = "microphone";
}
// The stream is considered paused when we're sharing something
// but all devices are off or set to disabled.
tabState.paused = tabState.sharing &&
- (!tabState.screen || tabState.screen.includes("Paused")) &&
- tabState.camera != MediaManagerService.STATE_CAPTURE_ENABLED &&
- tabState.microphone != MediaManagerService.STATE_CAPTURE_ENABLED;
+ !screenEnabled && !cameraEnabled && !microphoneEnabled;
tabState.windowId = getInnerWindowIDForWindow(aContentWindow);
tabState.documentURI = aContentWindow.document.documentURI;
return tabState;
}
function getInnerWindowIDForWindow(aContentWindow) {