(eventName, count)
| 104 | // Function that returns a promise for when the given event fired at |
| 105 | // least count times. |
| 106 | const awaitEvent = (eventName, count) => { |
| 107 | if (!(eventName in events)) { |
| 108 | throw new Error('Unknown custom event ' + eventName); |
| 109 | } |
| 110 | return new Promise(function (resolve) { |
| 111 | if (events[eventName] >= count) { |
| 112 | resolve(); |
| 113 | } else { |
| 114 | win.addEventListener(eventName, () => { |
| 115 | if (events[eventName] == count) { |
| 116 | resolve(); |
| 117 | } |
| 118 | }); |
| 119 | } |
| 120 | }); |
| 121 | }; |
| 122 | // Record firing of custom events. |
| 123 | for (const name in events) { |
| 124 | win.addEventListener(name, () => { |
nothing calls this directly
no test coverage detected