MCPcopy
hub / github.com/MetaMask/metamask-extension / waitForWindowToClose

Method waitForWindowToClose

test/e2e/webdriver/driver.js:1312–1328  ·  view source on GitHub ↗

* Waits for the specified window handle to close before returning. * * @param {string} handle - The handle of the window or tab we'll wait for. * @param {number} [timeout] - The amount of time in milliseconds to wait * before timing out. Defaults to `this.timeout`. * @throws {Error} t

(handle, timeout = this.timeout)

Source from the content-addressed store, hash-verified

1310 * the timeout.
1311 */
1312 async waitForWindowToClose(handle, timeout = this.timeout) {
1313 const start = Date.now();
1314 // eslint-disable-next-line no-constant-condition
1315 while (true) {
1316 const handles = await this.getAllWindowHandles();
1317 if (!handles.includes(handle)) {
1318 return;
1319 }
1320
1321 const timeElapsed = Date.now() - start;
1322 if (timeElapsed > timeout) {
1323 throw new Error(
1324 `waitForWindowToClose timed out waiting for window handle '${handle}' to close.`,
1325 );
1326 }
1327 }
1328 }
1329
1330 /**
1331 * Waits until the specified number of window handles are present.

Calls 1

getAllWindowHandlesMethod · 0.95

Tested by

no test coverage detected