Skip to content

Commit 224eda4

Browse files
Make pass instanceof checks
1 parent 802b9ae commit 224eda4

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

injected/src/features/web-compat.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,12 +789,13 @@ export class WebCompat extends ContentFeature {
789789
}
790790

791791
/**
792-
* Creates a valid MediaDeviceInfo object with required toJSON method
792+
* Creates a valid MediaDeviceInfo object that passes instanceof checks
793793
* @param {'videoinput' | 'audioinput' | 'audiooutput'} kind - The device kind
794794
* @returns {MediaDeviceInfo}
795795
*/
796796
createMediaDeviceInfo(kind) {
797-
return {
797+
// Create a simple object that looks like MediaDeviceInfo
798+
const deviceInfo = {
798799
deviceId: 'default',
799800
kind: kind,
800801
label: '',
@@ -808,6 +809,19 @@ export class WebCompat extends ContentFeature {
808809
};
809810
}
810811
};
812+
813+
// Make properties read-only to match MediaDeviceInfo behavior
814+
Object.defineProperties(deviceInfo, {
815+
deviceId: { writable: false, configurable: false },
816+
kind: { writable: false, configurable: false },
817+
label: { writable: false, configurable: false },
818+
groupId: { writable: false, configurable: false }
819+
});
820+
821+
// Set the prototype to MediaDeviceInfo.prototype for instanceof checks
822+
Object.setPrototypeOf(deviceInfo, MediaDeviceInfo.prototype);
823+
824+
return deviceInfo;
811825
}
812826

813827
/**

0 commit comments

Comments
 (0)