From 79b4706746d1efaca544f6b7a54aa14aaed3bb95 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 6 Apr 2018 13:25:06 -0400 Subject: [PATCH] code review: avoid special WebRTC test for non-Chromium browsers (#533) --- platform/chromium/vapi-background.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index dd628ce12..1ba429c94 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -92,7 +92,19 @@ vAPI.browserSettings = (function() { } return { - webRTCSupported: undefined, + // Whether the WebRTC-related privacy API is crashy is an open question + // only for Chromium proper (because it can be compiled without the + // WebRTC feature): hence avoid overhead of the evaluation (which uses + // an iframe) for platforms where it's a non-issue. + webRTCSupported: (function() { + var flavor = vAPI.webextFlavor.soup; + if ( + flavor.has('chromium') === false || + flavor.has('google') || flavor.has('opera') + ) { + return true; + } + })(), // https://github.com/gorhill/uBlock/issues/875 // Must not leave `lastError` unchecked. @@ -112,6 +124,10 @@ vAPI.browserSettings = (function() { setWebrtcIPAddress: function(setting) { // We don't know yet whether this browser supports WebRTC: find out. if ( this.webRTCSupported === undefined ) { + // If asked to leave WebRTC setting alone at this point in the + // code, this means we never grabbed the setting in the first + // place. + if ( setting ) { return; } this.webRTCSupported = { setting: setting }; var iframe = document.createElement('iframe'); var me = this;