mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
add bitwardenFrameId checks to all content scripts
This commit is contained in:
parent
1873df7f20
commit
3d26e8fdb7
@ -216,7 +216,7 @@ export class BrowserApi {
|
|||||||
// condition is only called if the popup wasn't already dismissed (future proofing).
|
// condition is only called if the popup wasn't already dismissed (future proofing).
|
||||||
// ref: https://bugzilla.mozilla.org/show_bug.cgi?id=1433604
|
// ref: https://bugzilla.mozilla.org/show_bug.cgi?id=1433604
|
||||||
browser.tabs.update({ active: true }).finally(win.close);
|
browser.tabs.update({ active: true }).finally(win.close);
|
||||||
} else if (BrowserApi.isWebExtensionsApi || BrowserApi.isChromeApi) {
|
} else if (BrowserApi.isWebExtensionsApi || BrowserApi.isChromeApi) {
|
||||||
win.close();
|
win.close();
|
||||||
} else if (BrowserApi.isSafariApi && safari.extension.popovers && safari.extension.popovers.length > 0) {
|
} else if (BrowserApi.isSafariApi && safari.extension.popovers && safari.extension.popovers.length > 0) {
|
||||||
safari.extension.popovers[0].hide();
|
safari.extension.popovers[0].hide();
|
||||||
|
@ -991,7 +991,7 @@
|
|||||||
}
|
}
|
||||||
safari.self.addEventListener('message', function (msgEvent) {
|
safari.self.addEventListener('message', function (msgEvent) {
|
||||||
var msg = msgEvent.message;
|
var msg = msgEvent.message;
|
||||||
if(msg.bitwardenFrameId != null && window.__bitwardenFrameId !== msg.bitwardenFrameId) {
|
if (msg.bitwardenFrameId != null && window.__bitwardenFrameId !== msg.bitwardenFrameId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,13 +7,20 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||||||
navigator.userAgent.indexOf('Chrome') === -1;
|
navigator.userAgent.indexOf('Chrome') === -1;
|
||||||
|
|
||||||
if (isSafari) {
|
if (isSafari) {
|
||||||
|
if ((window as any).__bitwardenFrameId == null) {
|
||||||
|
(window as any).__bitwardenFrameId = Math.floor(Math.random() * Math.floor(99999999));
|
||||||
|
}
|
||||||
const responseCommand = 'autofillerAutofillOnPageLoadEnabledResponse';
|
const responseCommand = 'autofillerAutofillOnPageLoadEnabledResponse';
|
||||||
safari.self.tab.dispatchMessage('bitwarden', {
|
safari.self.tab.dispatchMessage('bitwarden', {
|
||||||
command: 'bgGetDataForTab',
|
command: 'bgGetDataForTab',
|
||||||
responseCommand: responseCommand,
|
responseCommand: responseCommand,
|
||||||
|
bitwardenFrameId: (window as any).__bitwardenFrameId,
|
||||||
});
|
});
|
||||||
safari.self.addEventListener('message', (msgEvent: any) => {
|
safari.self.addEventListener('message', (msgEvent: any) => {
|
||||||
const msg = msgEvent.message;
|
const msg = msgEvent.message;
|
||||||
|
if (msg.bitwardenFrameId != null && (window as any).__bitwardenFrameId !== msg.bitwardenFrameId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (msg.command === responseCommand && msg.data.autofillEnabled === true) {
|
if (msg.command === responseCommand && msg.data.autofillEnabled === true) {
|
||||||
setInterval(() => doFillIfNeeded(), 500);
|
setInterval(() => doFillIfNeeded(), 500);
|
||||||
} else if (msg.command === 'fillForm' && pageHref === msg.url) {
|
} else if (msg.command === 'fillForm' && pageHref === msg.url) {
|
||||||
@ -52,12 +59,13 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pageHref = window.location.href;
|
pageHref = window.location.href;
|
||||||
const msg = {
|
const msg: any = {
|
||||||
command: 'bgCollectPageDetails',
|
command: 'bgCollectPageDetails',
|
||||||
sender: 'autofiller',
|
sender: 'autofiller',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isSafari) {
|
if (isSafari) {
|
||||||
|
msg.bitwardenFrameId = (window as any).__bitwardenFrameId;
|
||||||
safari.self.tab.dispatchMessage('bitwarden', msg);
|
safari.self.tab.dispatchMessage('bitwarden', msg);
|
||||||
} else {
|
} else {
|
||||||
chrome.runtime.sendMessage(msg);
|
chrome.runtime.sendMessage(msg);
|
||||||
|
@ -24,6 +24,9 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||||||
let disabledChangedPasswordNotification = false;
|
let disabledChangedPasswordNotification = false;
|
||||||
|
|
||||||
if (isSafari) {
|
if (isSafari) {
|
||||||
|
if ((window as any).__bitwardenFrameId == null) {
|
||||||
|
(window as any).__bitwardenFrameId = Math.floor(Math.random() * Math.floor(99999999));
|
||||||
|
}
|
||||||
if (inIframe) {
|
if (inIframe) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -32,9 +35,13 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||||||
safari.self.tab.dispatchMessage('bitwarden', {
|
safari.self.tab.dispatchMessage('bitwarden', {
|
||||||
command: 'bgGetDataForTab',
|
command: 'bgGetDataForTab',
|
||||||
responseCommand: responseCommand,
|
responseCommand: responseCommand,
|
||||||
|
bitwardenFrameId: (window as any).__bitwardenFrameId,
|
||||||
});
|
});
|
||||||
safari.self.addEventListener('message', (msgEvent: any) => {
|
safari.self.addEventListener('message', (msgEvent: any) => {
|
||||||
const msg = msgEvent.message;
|
const msg = msgEvent.message;
|
||||||
|
if (msg.bitwardenFrameId != null && (window as any).__bitwardenFrameId !== msg.bitwardenFrameId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (msg.command === responseCommand && msg.data) {
|
if (msg.command === responseCommand && msg.data) {
|
||||||
notificationBarData = msg.data;
|
notificationBarData = msg.data;
|
||||||
if (notificationBarData.neverDomains &&
|
if (notificationBarData.neverDomains &&
|
||||||
@ -562,6 +569,7 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||||||
|
|
||||||
function sendPlatformMessage(msg: any) {
|
function sendPlatformMessage(msg: any) {
|
||||||
if (isSafari) {
|
if (isSafari) {
|
||||||
|
msg.bitwardenFrameId = (window as any).__bitwardenFrameId;
|
||||||
safari.self.tab.dispatchMessage('bitwarden', msg);
|
safari.self.tab.dispatchMessage('bitwarden', msg);
|
||||||
} else {
|
} else {
|
||||||
chrome.runtime.sendMessage(msg);
|
chrome.runtime.sendMessage(msg);
|
||||||
|
@ -10,6 +10,10 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSafari && (window as any).__bitwardenFrameId == null) {
|
||||||
|
(window as any).__bitwardenFrameId = Math.floor(Math.random() * Math.floor(99999999));
|
||||||
|
}
|
||||||
|
|
||||||
Mousetrap.prototype.stopCallback = () => {
|
Mousetrap.prototype.stopCallback = () => {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@ -30,12 +34,13 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendMessage(shortcut: string) {
|
function sendMessage(shortcut: string) {
|
||||||
const msg = {
|
const msg: any = {
|
||||||
command: 'keyboardShortcutTriggered',
|
command: 'keyboardShortcutTriggered',
|
||||||
shortcut: shortcut,
|
shortcut: shortcut,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isSafari) {
|
if (isSafari) {
|
||||||
|
msg.bitwardenFrameId = (window as any).__bitwardenFrameId;
|
||||||
safari.self.tab.dispatchMessage('bitwarden', msg);
|
safari.self.tab.dispatchMessage('bitwarden', msg);
|
||||||
} else {
|
} else {
|
||||||
chrome.runtime.sendMessage(msg);
|
chrome.runtime.sendMessage(msg);
|
||||||
|
Loading…
Reference in New Issue
Block a user