Open Bug 1829758 Opened 2 years ago Updated 1 year ago

Add an override for web.snapchat.com

Categories

(Web Compatibility :: Interventions, enhancement)

Firefox 114
enhancement

Tracking

(Not tracked)

People

(Reporter: ksenia, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

There are reports suggesting that web.snapchat.com works fine in Firefox with Chrome UA, so we can test and ship an override for desktop.

I've tried using the web version with spoofed UA and the chat feature seems to work, though there is this “click the camera to send snaps” on the main page that doesn’t work in Firefox.

I’m getting this error “Uncaught (in promise) TypeError: ‘camera’ (value of ‘name’ member of PermissionDescriptor) is not a valid value for enumeration PermissionName.“ which is bug1609427. We could probably try shimming this api, but that would require more time and likely won't happen in this release.

No longer blocks: 1805411
See Also: → 1609427

(In reply to Ksenia Berezina [:ksenia] from comment #1)

I've tried using the web version with spoofed UA and the chat feature seems to work, though there is this “click the camera to send snaps” on the main page that doesn’t work in Firefox.

I’m getting this error “Uncaught (in promise) TypeError: ‘camera’ (value of ‘name’ member of PermissionDescriptor) is not a valid value for enumeration PermissionName.“ which is bug1609427. We could probably try shimming this api, but that would require more time and likely won't happen in this release.

You can make this part of the site work with this javascript code

if ('permissions' in navigator && typeof navigator.permissions.query === 'function') {
	const originalQuery = navigator.permissions.query;
	navigator.permissions.query = function(query) {
		if (query.name === 'camera' || query.name === 'microphone') {
			navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
			return new Promise(function(resolve, reject) {
				navigator.getUserMedia({ audio: true, video: true }, function() {
					resolve({ state: 'granted' });
				}, function() {
					resolve({ state: 'denied' });
				});
			});
		} else {
			return originalQuery.call(navigator.permissions, query);
		}
	};
}

present in https://addons.mozilla.org/fr/firefox/addon/snapchatweb/

You can make this part of the site work with this javascript code

Thanks for your comment, this is helpful! I've tried shimming navigator.permissions.query and the camera/snaps starts working.

I was testing other parts of the app, and noticed that calls to other users don't work. When trying to make a call, I receive it at the other end, but not able to connect and the call just ends. There are no obvious errors in the console, so I'm not sure what's causing this, perhaps the way they're establishing webrtc connection is not supported in Firefox. This needs additional investigation, I'll look into it when I have some spare cycles.

Just so this doesn't get lost, the following intervention makes camera and snaps working:

const win = window.wrappedJSObject;
const nav = navigator.wrappedJSObject;
const proto = window.Permissions.prototype.wrappedJSObject;

const queryDesc = Object.getOwnPropertyDescriptor(proto, "query");
const originalQuery = queryDesc.value;
const returnValue = { state: "granted" };

queryDesc.value = exportFunction(function (args) {
  if (args?.name === "camera" || args?.name === "microphone") {
    return win.Promise.resolve(
      cloneInto(returnValue, window, {
        cloneFunctions: true,
      })
    );
  }

  return originalQuery.call(nav.permissions, args);
}, window);

Object.defineProperty(proto, "query", queryDesc);
Depends on: 1396922, 1609427
See Also: 1609427
Depends on: 1876865
Blocks: snapchat
No longer depends on: 1876865
No longer depends on: 1396922, 1609427
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: