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

Commit

Permalink
Fix cross frame communication not exposing sourceTabId properly (#1379)
Browse files Browse the repository at this point in the history
  • Loading branch information
toasted-nutbread authored Feb 13, 2021
1 parent edc22b9 commit 00066e4
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 00066e4

Please sign in to comment.