Add a mechanism to dispatch and listen to an action
[WebKit-https.git] / Websites / perf.webkit.org / browser-tests / close-button-tests.js
1
2 describe('CloseButton', () => {
3     const scripts = ['instrumentation.js', 'components/base.js', 'components/button-base.js', 'components/close-button.js'];
4
5     it('must dispatch "activate" action when the anchor is clicked', () => {
6         const context = new BrowsingContext();
7         return context.importScripts(scripts, 'CloseButton').then((CloseButton) => {
8             const closeButton = new CloseButton;
9             context.document.body.appendChild(closeButton.element());
10
11             closeButton.content().querySelector('a').click();
12
13             let activateCount = 0;
14             closeButton.listenToAction('activate', () => {
15                 activateCount++;
16             });
17             expect(activateCount).toBe(0);
18             closeButton.content().querySelector('a').click();
19             expect(activateCount).toBe(1);
20             closeButton.content().querySelector('a').click();
21             expect(activateCount).toBe(2);
22         });
23     });
24
25 });