Skip to content

Commit

Permalink
Firefox: do not attempt to modify read-only property in ice candidate…
Browse files Browse the repository at this point in the history
… shim (#1123)

* Firefox: do not attempt to modify read-only property in ice candidate shim

fixes #1122
  • Loading branch information
fippo authored Mar 12, 2023
1 parent 2b804e8 commit 5137c44
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/js/common_shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,23 @@ export function shimRTCIceCandidate(window) {
// Augment the native candidate with the parsed fields.
const nativeCandidate = new NativeRTCIceCandidate(args);
const parsedCandidate = SDPUtils.parseCandidate(args.candidate);
const augmentedCandidate = Object.assign(nativeCandidate,
parsedCandidate);
for (const key in parsedCandidate) {
if (!(key in nativeCandidate)) {
Object.defineProperty(nativeCandidate, key,
{value: parsedCandidate[key]});
}
}

// Add a serializer that does not serialize the extra attributes.
augmentedCandidate.toJSON = function toJSON() {
// Override serializer to not serialize the extra attributes.
nativeCandidate.toJSON = function toJSON() {
return {
candidate: augmentedCandidate.candidate,
sdpMid: augmentedCandidate.sdpMid,
sdpMLineIndex: augmentedCandidate.sdpMLineIndex,
usernameFragment: augmentedCandidate.usernameFragment,
candidate: nativeCandidate.candidate,
sdpMid: nativeCandidate.sdpMid,
sdpMLineIndex: nativeCandidate.sdpMLineIndex,
usernameFragment: nativeCandidate.usernameFragment,
};
};
return augmentedCandidate;
return nativeCandidate;
}
return new NativeRTCIceCandidate(args);
};
Expand Down

0 comments on commit 5137c44

Please sign in to comment.