fix(host-control-mode): remove redundant CONTENT_EVENT guard, persist desync in storage, block stale tab HCM_DESYNC_STATE

Original code at L1957 already validates sender.tab tabId against
currentTabId before calling processEvent() — added guard was
duplicate. HCM_DESYNC_STATE had no such guard; added with same
sender.tab && currentTabId pattern (popup-safe via undefined
short-circuit).

hcmDesynced now persisted in session storage:
- Restored in ensureState()
- Set on HCM_DESYNC_STATE change
- Reset to false in all 3 teardown storage.sets
Survives SW restarts; cleared on leave/switch/idle-room
This commit is contained in:
KoalaDev
2026-06-26 13:23:24 +02:00
parent 1eca3fa5bb
commit 5863991bfb
-7
View File
@@ -1857,13 +1857,6 @@ async function handleAsyncMessage(message, sender, sendResponse) {
}
});
} else if (message.type === 'CONTENT_EVENT') {
// Only process media events from the currently selected tab — ignore
// stale content scripts in previously-selected tabs. Popup-originated
// events (no sender.tab) always pass through.
if (sender.tab && currentTabId && currentTabId !== sender.tab.id) {
sendResponse({ status: 'ignored_unselected_tab' });
return;
}
const processEvent = () => {
// Host Control Mode (sender-side): a guest in host-only mode must not
// drive the room. Don't broadcast; hand the action back to content.js so