rdNavigationTelemetry("view-all", event.originalTarget); }); viewsDeck.addEventListener("view-changed", onViewsDeckViewChange); // set the initial state onHashChange(); onViewsDeckViewChange(); await updateSearchTextboxSize(); await updateSearchKeyboardShortcut(); updateSyncVisibility(); if (Cu.isInAutomation) { Services.obs.notifyObservers(null, "firefoxview-entered"); } }); document.addEventListener("visibilitychange", () => { if (document.visibilityState === "visible") { recordEnteredTelemetry(); if (Cu.isInAutomation) { // allow all the component visibilitychange handlers to execute before notifying requestAnimationFrame(() => { Services.obs.notifyObservers(null, "firefoxview-entered"); }); } } }); function recordEnteredTelemetry() { Glean.firefoxviewNext.enteredFirefoxview.record({ page: document.location?.hash?.substring(1) || "recentbrowsing", }); } document.addEventListener("keydown", e => { if (e.getModifierState("Accel") && e.key === searchKeyboardShortcut) { activeComponent.searchTextbox?.focus(); } }); window.addEventListener( "unload", () => { // Clear out the document so the disconnectedCallback will trigger // properly and all of the custom elements can cleanup. document.body.textContent = ""; topChromeWindow.removeEventListener("command", onCommand); Services.obs.removeObserver(onLocalesChanged, "intl:app-locales-changed"); Services.prefs.removeObserver( "identity.fxaccounts.enabled", updateSyncVisibility ); }, { once: true } ); topChromeWindow.addEventListener("command", onCommand); Services.obs.addObserver(onLocalesChanged, "intl:app-locales-changed"); Services.prefs.addObserver("identity.fxaccounts.enabled", updateSyncVisibility); function onCommand(e) { if (document.hidden || !e.target.closest("#contentAreaContextMenu")) { return; } const item = e.target.closest("#context-openlinkinusercontext-menu") || e.target; Glean.firefoxviewNext.browserContextMenuTabs.record({ menu_action: item.id, page: location.hash?.substring(1) || "recentbrowsing", }); } function onLocalesChanged() { requestIdleCallback(() => { updateSearchTextboxSize(); updateSearchKeyboardShortcut(); }); } PK