Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Fix cross frame communication not exposing sourceTabId properly #1379

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ext/bg/js/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ class Backend {
}
if (details.name !== 'background-cross-frame-communication-port') { return; }

const tabId = (port.sender && port.sender.tab ? port.sender.tab.id : null);
if (typeof tabId !== 'number') {
const senderTabId = (port.sender && port.sender.tab ? port.sender.tab.id : null);
if (typeof senderTabId !== 'number') {
throw new Error('Port does not have an associated tab ID');
}
const senderFrameId = port.sender.frameId;
Expand All @@ -330,11 +330,12 @@ class Backend {
}
let {targetTabId, targetFrameId} = details;
if (typeof targetTabId !== 'number') {
targetTabId = tabId;
targetTabId = senderTabId;
}

const details2 = {
name: 'cross-frame-communication-port',
sourceTabId: senderTabId,
sourceFrameId: senderFrameId
};
let forwardPort = chrome.tabs.connect(targetTabId, {frameId: targetFrameId, name: JSON.stringify(details2)});
Expand Down