2021-12-10 02:37:01 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google LLC All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
2024-09-20 15:23:15 +00:00
|
|
|
* found in the LICENSE file at https://angular.dev/license
|
2021-12-10 02:37:01 +00:00
|
|
|
*/
|
|
|
|
|
|
2025-06-15 23:10:52 +00:00
|
|
|
/**
|
|
|
|
|
* Selects an Iframe and returns its body when it's done loading.
|
|
|
|
|
* @param {string} selector - The selector for the iframe.
|
|
|
|
|
* @returns {Function} A function that returns the wrapped body of the iframe.
|
|
|
|
|
*/
|
|
|
|
|
function enterIframe(selector) {
|
|
|
|
|
return cy.get(selector, {log: false}).then({timeout: 30000}, async (frame) => {
|
|
|
|
|
const contentWindow = frame.prop('contentWindow');
|
|
|
|
|
|
|
|
|
|
while (
|
|
|
|
|
contentWindow.location.toString() === 'about:blank' ||
|
|
|
|
|
contentWindow.document.readyState !== 'complete'
|
|
|
|
|
) {
|
|
|
|
|
await new Promise((resolve) => setTimeout(resolve));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// return the body of the iframe wrapped in cypress
|
|
|
|
|
return () => cy.wrap(contentWindow.document.body);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('enterIframe', enterIframe);
|