blob: 337f74c4b1591b0a4c29fb14386feeae49259068 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
const { ASRouter } = ChromeUtils.import(
"resource://activity-stream/lib/ASRouter.jsm"
);
const { ASRouterTriggerListeners } = ChromeUtils.import(
"resource://activity-stream/lib/ASRouterTriggerListeners.jsm"
);
const { SpecialMessageActions } = ChromeUtils.importESModule(
"resource://messaging-system/lib/SpecialMessageActions.sys.mjs"
);
add_task(async function cfr_firefoxview_should_show() {
await SpecialPowers.pushPrefEnv({
set: [["browser.firefox-view.view-count", 0]],
});
let cfrSpy = sinon.spy(ASRouter, "routeCFRMessage");
let specialMessageActionsSpy = sinon.spy(
SpecialMessageActions,
"handleAction"
);
registerCleanupFunction(() => {
cfrSpy.restore();
specialMessageActionsSpy.restore();
ASRouter.resetMessageState();
ASRouter.unblockMessageById("CFR_FIREFOX_VIEW");
ASRouterTriggerListeners.get("nthTabClosed").uninit();
});
let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser);
let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser);
let tab3 = await BrowserTestUtils.openNewForegroundTab(gBrowser);
const showPanel = BrowserTestUtils.waitForEvent(
PopupNotifications.panel,
"popupshown",
target => {
return target;
}
);
BrowserTestUtils.removeTab(tab1);
BrowserTestUtils.removeTab(tab2);
BrowserTestUtils.removeTab(tab3);
await showPanel;
Assert.equal(cfrSpy.lastCall.args[0].id, "CFR_FIREFOX_VIEW");
const notification = document.querySelector(
"#contextual-feature-recommendation-notification"
);
Assert.ok(notification);
Assert.ok(document.querySelector(".popup-notification-primary-button"));
Assert.ok(document.querySelector(".popup-notification-secondary-button"));
await notification.button.click();
Assert.equal(
specialMessageActionsSpy.firstCall.args[0].type,
"OPEN_FIREFOX_VIEW"
);
await SpecialPowers.popPrefEnv();
closeFirefoxViewTab(window);
});
|