Skip to content

Commit 859ba8f

Browse files
Use input interface also
1 parent d5aecbe commit 859ba8f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

injected/src/features/web-compat.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,9 @@ export class WebCompat extends ContentFeature {
789789
}
790790

791791
/**
792-
* Creates a valid MediaDeviceInfo object that passes instanceof checks
792+
* Creates a valid MediaDeviceInfo or InputDeviceInfo object that passes instanceof checks
793793
* @param {'videoinput' | 'audioinput' | 'audiooutput'} kind - The device kind
794-
* @returns {MediaDeviceInfo}
794+
* @returns {MediaDeviceInfo | InputDeviceInfo}
795795
*/
796796
createMediaDeviceInfo(kind) {
797797
// Create a simple object that looks like MediaDeviceInfo
@@ -818,8 +818,18 @@ export class WebCompat extends ContentFeature {
818818
groupId: { writable: false, configurable: false }
819819
});
820820

821-
// Set the prototype to MediaDeviceInfo.prototype for instanceof checks
822-
Object.setPrototypeOf(deviceInfo, MediaDeviceInfo.prototype);
821+
// Set the prototype based on device type
822+
if (kind === 'videoinput' || kind === 'audioinput') {
823+
// Input devices should inherit from InputDeviceInfo.prototype if available
824+
if (typeof InputDeviceInfo !== 'undefined' && InputDeviceInfo.prototype) {
825+
Object.setPrototypeOf(deviceInfo, InputDeviceInfo.prototype);
826+
} else {
827+
Object.setPrototypeOf(deviceInfo, MediaDeviceInfo.prototype);
828+
}
829+
} else {
830+
// Output devices inherit from MediaDeviceInfo.prototype
831+
Object.setPrototypeOf(deviceInfo, MediaDeviceInfo.prototype);
832+
}
823833

824834
return deviceInfo;
825835
}

0 commit comments

Comments
 (0)