diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index 5a16bc2..031cf18 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -939,9 +939,14 @@ browser.runtime.onMessage.addListener(async function(req, sender) { kpxcFill.fillAttributeToActiveElementWith(req.args); } else if (req.action === 'frame_message') { if (req.args?.[0] === 'frame_request_to_frames' && window.self !== window.top) { + // Handle message from top window in iframe kpxcCustomLoginFieldsBanner.handleParentWindowMessage(req.args); } else if (req.args?.[0] === 'frame_request_to_parent' && window.self === window.top) { + // Handle message from iframe in top window kpxcCustomLoginFieldsBanner.handleTopWindowMessage(req.args); + } else if (req.args?.[0] === 'notification_from_frame' && window.self === window.top) { + // Handle notification from iframe in top window + kpxcUI.createNotification(req?.args[1], req?.args[2]); } } else if (req.action === 'ignore_site') { kpxc.ignoreSite(req.args); diff --git a/keepassxc-browser/content/ui.js b/keepassxc-browser/content/ui.js index 1a77d3c..be2d43c 100644 --- a/keepassxc-browser/content/ui.js +++ b/keepassxc-browser/content/ui.js @@ -330,11 +330,17 @@ kpxcUI.updateFromIntersectionObserver = function(iconClass, entries) { * @param {string} type Notification type: (success, info, warning, error) * @param {string} message The message shown */ -kpxcUI.createNotification = function(type, message) { +kpxcUI.createNotification = async function(type, message) { if (!kpxc.settings.showNotifications || !type || !message) { return; } + // Send the notification to top window from iframe + if (window.self !== window.top) { + await sendMessage('frame_message', [ 'notification_from_frame', type, message ]); + return; + } + // Removes notification from the body element const removeNotification = function() { // Catch cross-domain exception