tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 44be98e9e69981519fac6f8fff4f0b2e5e43ad98
parent abd89d56a76e1ef5996c2a1d197e387e2ed9106c
Author: Andreas Pehrson <apehrson@mozilla.com>
Date:   Wed, 26 Nov 2025 23:06:59 +0000

Bug 2000906 - On Microsoft Teams, drop resizeMode: "none" in gDM. r=jib,twisniewski,webcompat-reviewers

Drop the resizeMode constraint from gDM when used counter-productively with any
other constraint that causes downscaling or framerate decimation.

Also drop it from applyConstraints if not already present since track creation,
i.e. when previously dropped per the condition mentioned above.

Differential Revision: https://phabricator.services.mozilla.com/D274070

Diffstat:
Mbrowser/extensions/webcompat/data/interventions.json | 18++++++++++++++++++
Abrowser/extensions/webcompat/injections/js/bug2000906-teams.microsoft.com-disable-resizeMode-in-gDM.js | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/browser/extensions/webcompat/data/interventions.json b/browser/extensions/webcompat/data/interventions.json @@ -6127,5 +6127,23 @@ "ua_string": ["Chrome_with_FxQuantum"] } ] + }, + "2000906": { + "label": "teams.microsoft.com", + "bugs": { + "2000906": { + "issue": "broken-meetings", + "matches": ["*://teams.microsoft.com/*", "*://teams.live.com/*"] + } + }, + "interventions": [ + { + "platforms": ["desktop"], + "content_scripts": { + "all_frames": true, + "js": ["bug2000906-teams.microsoft.com-disable-resizeMode-in-gDM.js"] + } + } + ] } } diff --git a/browser/extensions/webcompat/injections/js/bug2000906-teams.microsoft.com-disable-resizeMode-in-gDM.js b/browser/extensions/webcompat/injections/js/bug2000906-teams.microsoft.com-disable-resizeMode-in-gDM.js @@ -0,0 +1,57 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +/** + * Bug 2000906 - Microsoft Teams, for getDisplayMedia requests resizeMode: "none" but expects downscaling and frameRate decimation + * + * If a constraint for width, height or frameRate is present together with resizeMode: "none", we clear resizeMode. + * Chrome seems to incorrectly ignore the resizeMode constraint for getDisplayMedia. + */ + +/* globals exportFunction */ + +console.info( + 'getDisplayMedia has been modified to drop resizeMode: "none" for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=2000906 for details.' +); + +function maybeDeleteResizeMode(video) { + const { resizeMode, width, height, frameRate } = video; + if (resizeMode == "none" && (width || height || frameRate)) { + delete video.resizeMode; + } +} + +if (navigator.mediaDevices?.getDisplayMedia) { + { + const { prototype } = MediaDevices.wrappedJSObject; + const { getDisplayMedia: gDM } = prototype; + prototype.getDisplayMedia = exportFunction(function getDisplayMedia( + options + ) { + const { video } = options || {}; + if (video) { + maybeDeleteResizeMode(video); + } + return gDM.call(this, options); + }, window); + } + + { + const { prototype } = MediaStreamTrack.wrappedJSObject; + const { applyConstraints: aC } = prototype; + prototype.applyConstraints = exportFunction(function applyConstraints( + constraints + ) { + // Don't allow adding resizeMode if it wasn't there from the start. + // Ideally we'd check for a gDM-sourced track instead but there's no + // spec-compliant way to do that. + if (!this.getConstraints().resizeMode) { + maybeDeleteResizeMode(constraints || {}); + } + return aC.call(this, constraints); + }, window); + } +}