Skip to content

Commit 0885bb6

Browse files
authored
Merge pull request #250 from ezzak/fix_framed_logged_out
Fix edge case with nested logged out frame on logged in document
2 parents 8b6c3ac + 4e866e1 commit 0885bb6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/js/background/tab_state_tracker/TabStateMachine.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ export default class TabStateMachine extends StateMachine {
6161
}
6262

6363
updateStateIfValid(newState: State) {
64-
// Only update the tab's state to VALID if all of it's frames are VALID
64+
// Only update the tab's state to VALID if all of it's frames are VALID or just starting
6565
if (
6666
newState === STATES.VALID &&
6767
!Object.values(this._frameStates).every(
68-
fsm => fsm.getState() === STATES.VALID,
68+
fsm =>
69+
fsm.getState() === STATES.VALID || fsm.getState() === STATES.START,
6970
)
7071
) {
7172
return;

src/js/contentUtils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ export const processFoundJS = async (version: string): Promise<void> => {
422422
window.setTimeout(() => processFoundJS(version), 3000);
423423
};
424424

425+
let isUserLoggedIn = false;
425426
export function startFor(
426427
origin: Origin,
427428
excludedPathnames: Array<RegExp> = [],
@@ -441,7 +442,6 @@ export function startFor(
441442
updateCurrentState(STATES.IGNORE);
442443
return;
443444
}
444-
let isUserLoggedIn = false;
445445
if (isFbMsgrOrIgOrigin(origin)) {
446446
// ds_user_id / c_user contains the user id of the user logged in
447447
const cookieName =
@@ -454,7 +454,7 @@ export function startFor(
454454
}
455455
});
456456
} else {
457-
// only doing this check for FB and MSGR
457+
// only doing this check for FB, MSGR, and IG
458458
isUserLoggedIn = true;
459459
}
460460
if (isUserLoggedIn) {
@@ -480,7 +480,7 @@ chrome.runtime.onMessage.addListener(request => {
480480
`Detected uncached script ${request.uncachedUrl}`,
481481
);
482482
} else if (request.greeting === 'checkIfScriptWasProcessed') {
483-
if (!ALL_FOUND_SCRIPT_TAGS.has(request.response.url)) {
483+
if (isUserLoggedIn && !ALL_FOUND_SCRIPT_TAGS.has(request.response.url)) {
484484
if (
485485
'serviceWorker' in navigator &&
486486
navigator.serviceWorker.controller?.scriptURL === request.response.url

0 commit comments

Comments
 (0)