Skip to content

Commit 489f654

Browse files
Move to webCompat
1 parent 0589a17 commit 489f654

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

injected/src/features.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ export const platformSupport = {
4646
android: [...baseFeatures, 'webCompat', 'breakageReporting', 'duckPlayer', 'messageBridge'],
4747
'android-broker-protection': ['brokerProtection'],
4848
'android-autofill-password-import': ['autofillPasswordImport'],
49-
windows: ['cookie', ...baseFeatures, 'windowsPermissionUsage', 'duckPlayer', 'brokerProtection', 'breakageReporting', 'messageBridge'],
49+
windows: ['cookie', ...baseFeatures, 'windowsPermissionUsage', 'duckPlayer', 'brokerProtection', 'breakageReporting', 'messageBridge', 'webCompat'],
5050
firefox: ['cookie', ...baseFeatures, 'clickToLoad'],
5151
chrome: ['cookie', ...baseFeatures, 'clickToLoad'],
52-
'chrome-mv3': ['cookie', ...baseFeatures, 'clickToLoad'],
52+
'chrome-mv3': ['cookie', ...baseFeatures, 'clickToLoad', 'webCompat'],
5353
integration: [...baseFeatures, ...otherFeatures],
5454
};

injected/src/features/web-compat.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ContentFeature from '../content-feature.js';
22
// eslint-disable-next-line no-redeclare
33
import { URL } from '../captured-globals.js';
4-
4+
import { DDGProxy } from '../utils';
55
/**
66
* Fixes incorrect sizing value for outerHeight and outerWidth
77
*/
@@ -126,6 +126,9 @@ export class WebCompat extends ContentFeature {
126126
if (this.getFeatureSettingEnabled('modifyCookies')) {
127127
this.modifyCookies();
128128
}
129+
if (this.getFeatureSettingEnabled('disableDeviceEnumeration') || this.getFeatureSettingEnabled('disableDeviceEnumerationFrames')) {
130+
this.preventDeviceEnumeration();
131+
}
129132
}
130133

131134
/** Shim Web Share API in Android WebView */
@@ -753,6 +756,27 @@ export class WebCompat extends ContentFeature {
753756
this.forceViewportTag(viewportTag, newContent.join(', '));
754757
}
755758
}
759+
760+
preventDeviceEnumeration() {
761+
if (!window.MediaDevices) {
762+
return;
763+
}
764+
let disableDeviceEnumeration = false;
765+
const isFrame = window.self !== window.top;
766+
if (isFrame) {
767+
disableDeviceEnumeration = this.getFeatureSettingEnabled('disableDeviceEnumerationFrames');
768+
} else {
769+
disableDeviceEnumeration = this.getFeatureSettingEnabled('disableDeviceEnumeration');
770+
}
771+
if (disableDeviceEnumeration) {
772+
const enumerateDevicesProxy = new DDGProxy(this, MediaDevices.prototype, 'enumerateDevices', {
773+
apply() {
774+
return Promise.resolve([]);
775+
},
776+
});
777+
enumerateDevicesProxy.overload();
778+
}
779+
}
756780
}
757781

758782
/** @typedef {{title?: string, url?: string, text?: string}} ShareRequestData */

injected/src/features/windows-permission-usage.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -350,21 +350,6 @@ export default class WindowsPermissionUsage extends ContentFeature {
350350
},
351351
});
352352
getUserMediaProxy.overload();
353-
let disableDeviceEnumeration = false;
354-
const isFrame = window.self !== window.top;
355-
if (isFrame) {
356-
disableDeviceEnumeration = this.getFeatureSettingEnabled('disableDeviceEnumerationFrames');
357-
} else {
358-
disableDeviceEnumeration = this.getFeatureSettingEnabled('disableDeviceEnumeration');
359-
}
360-
if (disableDeviceEnumeration) {
361-
const enumerateDevicesProxy = new DDGProxy(this, MediaDevices.prototype, 'enumerateDevices', {
362-
apply() {
363-
return Promise.resolve([]);
364-
},
365-
});
366-
enumerateDevicesProxy.overload();
367-
}
368353
}
369354

370355
function performAction(action, permission) {

0 commit comments

Comments
 (0)