为什么 Safari 通过了我为 WebRTC 编写的这个 Modernizr 测试?

Why is Safari passing this Modernizr test I wrote for WebRTC?

我想要一个 Modernizr 测试来检查 setLocalDescription with description optional。这是我想出的:

window.Modernizr.addTest('paramlessrtclocaldescription', function () {
    try {
        return window.RTCPeerConnection.prototype.setLocalDescription.length === 0;
    } catch (err) {
        // This can only happen if the browser doesn't support RTCPeerConnection, and
        // we have a separate test for that, but we don't want this test to crash
        // the script.
        return false;
    }
});

当我 运行 在 Firefox 73 中进行此测试时(在 Windows,来自 PortableApps.com),它正确 returns false.

但是,当我运行在Safari 14.1中测试returnstrue,尽管CanIUse说Safari不支持这个功能

此外,当我打开 JS 控制台并键入 window.RTCPeerConnection.prototype.setLocalDescription.length 时,它 returns 3window.RTCPeerConnection.prototype.setLocalDescription.length === 0 returns false.

UPDATE: The above observation is incorrect because manually running the code in the console is being done after webrtc-adapter has loaded, and webrtc-adapter overrides this function.

为什么 Safari 在被列为不受支持的情况下仍能通过 Modernizr 测试?

原来Safari 14.1支持这个功能,看来是CanIUse/MDN错了.

已添加到 Webkit in September 2020