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).
|
||||
// ref: https://bugzilla.mozilla.org/show_bug.cgi?id=1433604
|
||||
browser.tabs.update({ active: true }).finally(win.close);
|
||||
} else if (BrowserApi.isWebExtensionsApi || BrowserApi.isChromeApi) {
|
||||
} else if (BrowserApi.isWebExtensionsApi || BrowserApi.isChromeApi) {
|
||||
win.close();
|
||||
} else if (BrowserApi.isSafariApi && safari.extension.popovers && safari.extension.popovers.length > 0) {
|
||||
safari.extension.popovers[0].hide();
|
||||
|
@ -991,7 +991,7 @@
|
||||
}
|
||||
safari.self.addEventListener('message', function (msgEvent) {
|
||||
var msg = msgEvent.message;
|
||||
if(msg.bitwardenFrameId != null && window.__bitwardenFrameId !== msg.bitwardenFrameId) {
|
||||
if (msg.bitwardenFrameId != null && window.__bitwardenFrameId !== msg.bitwardenFrameId) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,20 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
navigator.userAgent.indexOf('Chrome') === -1;
|
||||
|
||||
if (isSafari) {
|
||||
if ((window as any).__bitwardenFrameId == null) {
|
||||
(window as any).__bitwardenFrameId = Math.floor(Math.random() * Math.floor(99999999));
|
||||
}
|
||||
const responseCommand = 'autofillerAutofillOnPageLoadEnabledResponse';
|
||||
safari.self.tab.dispatchMessage('bitwarden', {
|
||||
command: 'bgGetDataForTab',
|
||||
responseCommand: responseCommand,
|
||||
bitwardenFrameId: (window as any).__bitwardenFrameId,
|
||||
});
|
||||
safari.self.addEventListener('message', (msgEvent: any) => {
|
||||
const msg = msgEvent.message;
|
||||
if (msg.bitwardenFrameId != null && (window as any).__bitwardenFrameId !== msg.bitwardenFrameId) {
|
||||
return;
|
||||
}
|
||||
if (msg.command === responseCommand && msg.data.autofillEnabled === true) {
|
||||
setInterval(() => doFillIfNeeded(), 500);
|
||||
} else if (msg.command === 'fillForm' && pageHref === msg.url) {
|
||||
@ -52,12 +59,13 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
}
|
||||
|
||||
pageHref = window.location.href;
|
||||
const msg = {
|
||||
const msg: any = {
|
||||
command: 'bgCollectPageDetails',
|
||||
sender: 'autofiller',
|
||||
};
|
||||
|
||||
if (isSafari) {
|
||||
msg.bitwardenFrameId = (window as any).__bitwardenFrameId;
|
||||
safari.self.tab.dispatchMessage('bitwarden', msg);
|
||||
} else {
|
||||
chrome.runtime.sendMessage(msg);
|
||||
|
@ -24,6 +24,9 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
let disabledChangedPasswordNotification = false;
|
||||
|
||||
if (isSafari) {
|
||||
if ((window as any).__bitwardenFrameId == null) {
|
||||
(window as any).__bitwardenFrameId = Math.floor(Math.random() * Math.floor(99999999));
|
||||
}
|
||||
if (inIframe) {
|
||||
return;
|
||||
}
|
||||
@ -32,9 +35,13 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
safari.self.tab.dispatchMessage('bitwarden', {
|
||||
command: 'bgGetDataForTab',
|
||||
responseCommand: responseCommand,
|
||||
bitwardenFrameId: (window as any).__bitwardenFrameId,
|
||||
});
|
||||
safari.self.addEventListener('message', (msgEvent: any) => {
|
||||
const msg = msgEvent.message;
|
||||
if (msg.bitwardenFrameId != null && (window as any).__bitwardenFrameId !== msg.bitwardenFrameId) {
|
||||
return;
|
||||
}
|
||||
if (msg.command === responseCommand && msg.data) {
|
||||
notificationBarData = msg.data;
|
||||
if (notificationBarData.neverDomains &&
|
||||
@ -562,6 +569,7 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
|
||||
function sendPlatformMessage(msg: any) {
|
||||
if (isSafari) {
|
||||
msg.bitwardenFrameId = (window as any).__bitwardenFrameId;
|
||||
safari.self.tab.dispatchMessage('bitwarden', msg);
|
||||
} else {
|
||||
chrome.runtime.sendMessage(msg);
|
||||
|
@ -10,6 +10,10 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSafari && (window as any).__bitwardenFrameId == null) {
|
||||
(window as any).__bitwardenFrameId = Math.floor(Math.random() * Math.floor(99999999));
|
||||
}
|
||||
|
||||
Mousetrap.prototype.stopCallback = () => {
|
||||
return false;
|
||||
};
|
||||
@ -30,12 +34,13 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
}
|
||||
|
||||
function sendMessage(shortcut: string) {
|
||||
const msg = {
|
||||
const msg: any = {
|
||||
command: 'keyboardShortcutTriggered',
|
||||
shortcut: shortcut,
|
||||
};
|
||||
|
||||
if (isSafari) {
|
||||
msg.bitwardenFrameId = (window as any).__bitwardenFrameId;
|
||||
safari.self.tab.dispatchMessage('bitwarden', msg);
|
||||
} else {
|
||||
chrome.runtime.sendMessage(msg);
|
||||
|
Loading…
Reference in New Issue
Block a user