Skip to content

Truly independent web browser

LibWeb: Expose RTCPeerConnection as webkitRTCPeerConnection too

sideshowbarkerd1a53cfa4a80
diff --git a/Libraries/LibWeb/WebRTC/RTCPeerConnection.idl b/Libraries/LibWeb/WebRTC/RTCPeerConnection.idl
index 7f9b3b8fcaa..529c1ad989e 100644
--- a/Libraries/LibWeb/WebRTC/RTCPeerConnection.idl
+++ b/Libraries/LibWeb/WebRTC/RTCPeerConnection.idl
@@ -1,7 +1,9 @@
// https://w3c.github.io/webrtc-pc/#interface-definition
-[Exposed=Window]
+// AD-HOC: The spec defines no webkitRTCPeerConnection, but pages that detect a Chrome-like browser by its prefixed
+// names expect the alias, and otherwise take us for an old Safari (WebRTC adapter libraries, e.g.).
+[Exposed=Window, LegacyWindowAlias=webkitRTCPeerConnection]
interface RTCPeerConnection : EventTarget {
constructor(optional RTCConfiguration configuration = {});
diff --git a/Tests/LibWeb/Text/expected/WebRTC/webkitRTCPeerConnection-alias.txt b/Tests/LibWeb/Text/expected/WebRTC/webkitRTCPeerConnection-alias.txt
new file mode 100644
index 00000000000..af6e5066657
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/WebRTC/webkitRTCPeerConnection-alias.txt
@@ -0,0 +1,4 @@
+webkitRTCPeerConnection is RTCPeerConnection: true
+constructs an RTCPeerConnection: true
+name: RTCPeerConnection
+writable: true, enumerable: false, configurable: true
diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txt
index 6c86ff109ed..7e192feec10 100644
--- a/Tests/LibWeb/Text/expected/all-window-properties.txt
+++ b/Tests/LibWeb/Text/expected/all-window-properties.txt
@@ -681,6 +681,7 @@ timeout
uniqueID
uniqueLocalhostHostname
uniqueTestHostname
+webkitRTCPeerConnection
webkitURL
wheelTargetToString
withCollectedWrapper
diff --git a/Tests/LibWeb/Text/input/WebRTC/webkitRTCPeerConnection-alias.html b/Tests/LibWeb/Text/input/WebRTC/webkitRTCPeerConnection-alias.html
new file mode 100644
index 00000000000..81dccf4107c
--- /dev/null
+++ b/Tests/LibWeb/Text/input/WebRTC/webkitRTCPeerConnection-alias.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script>
+ test(() => {
+ println(`webkitRTCPeerConnection is RTCPeerConnection: ${window.webkitRTCPeerConnection === RTCPeerConnection}`);
+ println(`constructs an RTCPeerConnection: ${new webkitRTCPeerConnection() instanceof RTCPeerConnection}`);
+ println(`name: ${webkitRTCPeerConnection.name}`);
+ const descriptor = Object.getOwnPropertyDescriptor(window, "webkitRTCPeerConnection");
+ println(`writable: ${descriptor.writable}, enumerable: ${descriptor.enumerable}, configurable: ${descriptor.configurable}`);
+ });
+</script>