WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
283763
Message sent from background using browser.tabs.sendMessage is sent incorrectly to target tab and to the tab opened with window.open by the target tab
https://bugs.webkit.org/show_bug.cgi?id=283763
Summary
Message sent from background using browser.tabs.sendMessage is sent incorrect...
alexandru.caba
Reported
2024-11-27 08:43:14 PST
Created
attachment 473382
[details]
Webpages to reproduce issue. A browser extension communicating with content webpages wrongly sends a message to a tab open with the Web API window.open("somepage"). Example: There are two web pages. The main page has a button that opens the second page. Click the button so that the secondary webpage is opened. With both webpages opened, from the extension background, find the Tab ID of the main page and send a message to it as described below. Observe that both tabs receive the message, and only one will successfully respond in the background. Expectation: When sendMessage is used with a valid tab ID, only the tab with the correct tab ID receives the message from the extension background. Problem: Both tabs receive the message. in window_open_main.html: <button onclick="myFunction()">Try it</button> <script> function myFunction() { window.open("window_open_child.html"); } </script> Have a Safari extension with a background page and a content page, where: background sends a message to a tab (resolve tabId with browser.tabs.query, frameId can be 0) tabs.sendMessage(tabId, { request: "some"}, frameId, , function(response) { console.log(response.value); }); and content listens for messages and sends a response: chrome.runtime.onMessage.addListener((msg, _sender, sendResponse) => { console.log("Hi from background"); sendResponse({ value: "Hi from content script" }); return false; // sync }); I've attached the manifest of our extension and the web pages I've used to reproduce the problem. The main page is slightly overcomplicated so the work we have to do on it takes enough time so the secondary tab sends the response first.
Attachments
Webpages to reproduce issue.
(3.20 KB, text/html)
2024-11-27 08:43 PST
,
alexandru.caba
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2024-11-27 08:43:22 PST
<
rdar://problem/140626378
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug