Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit 727e00b

Browse files
authored
Merge pull request #349 from mozilla/move-contextual-banner
Move contextual banner to only be used by methods negating enumerateD…
2 parents b820ce8 + 67de6b3 commit 727e00b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/content-script.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ const ContentScript = {
6262

6363
overwriteProperties() {
6464
const overwrittenProperties = new Set([
65-
{ originalMethod: null, parentObject: window.navigator.mediaDevices, methodName: "getSupportedConstraints", type: "method" },
66-
{ originalMethod: null, parentObject: window.navigator.mediaDevices, methodName: "enumerateDevices", type: "method" },
67-
{ originalMethod: null, parentObject: window.navigator.mediaDevices, methodName: "getUserMedia", type: "method" },
68-
{ originalMethod: null, parentObject: window.navigator.mediaDevices, methodName: "getDisplayMedia", type: "method" },
65+
{ originalMethod: null, parentObject: window.navigator.mediaDevices, methodName: "getSupportedConstraints", type: "method", potentiallyShowContextBanner: true },
66+
{ originalMethod: null, parentObject: window.navigator.mediaDevices, methodName: "enumerateDevices", type: "method", potentiallyShowContextBanner: false },
67+
{ originalMethod: null, parentObject: window.navigator.mediaDevices, methodName: "getUserMedia", type: "method", potentiallyShowContextBanner: true },
68+
{ originalMethod: null, parentObject: window.navigator.mediaDevices, methodName: "getDisplayMedia", type: "method", potentiallyShowContextBanner: true },
6969
{ originalMethod: null, parentObject: window, methodName: "RTCPeerConnection", type: "object" },
7070
{ originalMethod: null, parentObject: window, methodName: "RTCIceCandidate", type: "object" },
7171
{ originalMethod: null, parentObject: window, methodName: "RTCPeerConnectionStatic", type: "object" },
@@ -81,9 +81,11 @@ const ContentScript = {
8181
Object.defineProperty(object, property, {
8282
get: exportFunction(() => {
8383
if (ContentScript.shouldOverload()) {
84-
ContentScript.potentiallyShowContextBanner();
8584
if (data.type === "method") {
8685
return exportFunction(() => {
86+
if (data.potentiallyShowContextBanner) {
87+
ContentScript.potentiallyShowContextBanner();
88+
}
8789
return window.wrappedJSObject.Promise.reject(new window.wrappedJSObject.Error("SecurityError"));
8890
}, window);
8991
}

0 commit comments

Comments
 (0)