Bug 1724108 - switched browser_trigger_listeners to new vpn promo event, r=andreio

Differential Revision: https://phabricator.services.mozilla.com/D122064
This commit is contained in:
Dan Mosedale 2021-08-11 22:27:38 +00:00
Родитель 7a27adb89c
Коммит 2575056f16
2 изменённых файлов: 20 добавлений и 6 удалений

Просмотреть файл

@ -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"
);
}
},
},

Просмотреть файл

@ -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");
});