diff --git a/browser/components/newtab/lib/ASRouterTriggerListeners.jsm b/browser/components/newtab/lib/ASRouterTriggerListeners.jsm index ed6009397258..63ad4e0f8329 100644 --- a/browser/components/newtab/lib/ASRouterTriggerListeners.jsm +++ b/browser/components/newtab/lib/ASRouterTriggerListeners.jsm @@ -595,7 +595,10 @@ this.ASRouterTriggerListeners = new Map([ init(triggerHandler) { if (!this._initialized) { - Services.obs.addObserver(this, "captive-portal-login-success"); + Services.obs.addObserver( + this, + "captive-portal-login-success-after-button-pressed" + ); this._initialized = true; } this._triggerHandler = triggerHandler; @@ -603,7 +606,7 @@ this.ASRouterTriggerListeners = new Map([ observe(aSubject, aTopic, aData) { switch (aTopic) { - case "captive-portal-login-success": + case "captive-portal-login-success-after-button-pressed": const browser = Services.wm.getMostRecentBrowserWindow(); if (browser) { this._triggerHandler(browser.gBrowser.selectedBrowser, { @@ -618,7 +621,10 @@ this.ASRouterTriggerListeners = new Map([ if (this._initialized) { this._triggerHandler = null; this._initialized = false; - Services.obs.removeObserver(this, "captive-portal-login-success"); + Services.obs.removeObserver( + this, + "captive-portal-login-success-after-button-pressed" + ); } }, }, diff --git a/browser/components/newtab/test/browser/browser_trigger_listeners.js b/browser/components/newtab/test/browser/browser_trigger_listeners.js index af61c8c7a189..3cbb65f33769 100644 --- a/browser/components/newtab/test/browser/browser_trigger_listeners.js +++ b/browser/components/newtab/test/browser/browser_trigger_listeners.js @@ -72,13 +72,21 @@ add_task(async function test_captivePortalLogin() { captivePortalTrigger.init(stub); - Services.obs.notifyObservers(this, "captive-portal-login-success", {}); + Services.obs.notifyObservers( + this, + "captive-portal-login-success-after-button-pressed", + {} + ); - Assert.ok(stub.called, "Called after login event"); + Assert.ok(stub.called, "Called after button press and login"); captivePortalTrigger.uninit(); - Services.obs.notifyObservers(this, "captive-portal-login-success", {}); + Services.obs.notifyObservers( + this, + "captive-portal-login-success-after-button-pressed", + {} + ); Assert.equal(stub.callCount, 1, "Not called after uninit"); });