Skip to content

Commit 839c38e

Browse files
committed
Use the tab's URL to check if the Vimium is enabled
Previously we were accessing the top frame's URL, which fails due to cross-origin restrictions if the frames are from different origins.
1 parent 38278b8 commit 839c38e

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

background_scripts/main.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,9 @@ const sendRequestHandlers = {
560560
},
561561

562562
async initializeFrame(request, sender) {
563-
const tabId = sender.tab.id;
564-
const enabledState = Exclusions.isEnabledForUrl(request.topFrameUrl);
563+
// Check whether the extension is enabled for the top frame's URL, rather than the URL of the
564+
// specific frame that sent this request.
565+
const enabledState = Exclusions.isEnabledForUrl(sender.tab.url);
565566

566567
const isTopFrame = sender.frameId == 0;
567568
if (isTopFrame) {
@@ -588,7 +589,7 @@ const sendRequestHandlers = {
588589
"32": "../icons/action_disabled_32.png",
589590
},
590591
};
591-
chrome.action.setIcon({ path: iconSet[whichIcon], tabId: tabId });
592+
chrome.action.setIcon({ path: iconSet[whichIcon], tabId: sender.tab.id });
592593
}
593594

594595
const response = Object.assign({

content_scripts/vimium_frontend.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,7 @@ globalThis.lastFocusedInput = (function () {
409409

410410
// Checks if Vimium should be enabled or not based on the top frame's URL.
411411
const checkIfEnabledForUrl = async () => {
412-
const response = await chrome.runtime.sendMessage({
413-
handler: "initializeFrame",
414-
topFrameUrl: window.top.location.toString(),
415-
});
412+
const response = await chrome.runtime.sendMessage({ handler: "initializeFrame" });
416413

417414
isEnabledForUrl = response.isEnabledForUrl;
418415

0 commit comments

Comments
 (0)