Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cann't load iframe which is created with setTimout #29291

Closed
10229428 opened this issue Apr 9, 2024 · 2 comments
Closed

Cann't load iframe which is created with setTimout #29291

10229428 opened this issue Apr 9, 2024 · 2 comments
Labels
stage: needs investigating Someone from Cypress needs to look at this stale no activity on this issue for a long period topic: iframes

Comments

@10229428
Copy link

10229428 commented Apr 9, 2024

Current behavior

I have three pages: portal.html, child.html, app.html.
In page portal.html, there is an iframe for loading page child.html, with display: none
When page child.html is loaded, it creates a new iframe in top window(portal.html) for loading page app.html, and delete the pre iframe.

Then I visit portal.html by cypress, and get the iframe element, I got this result:
image

The deleted old iframe(for load page child.html) can be found, but the new iframe which is created dynamically cann't be found.

Desired behavior

This is the result, visited by chrome:
image

Test code to reproduce

portal.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>portal</title>
</head>
<body>
<div>
    <div style="width: 100%; height: 100%; min-width: 1200px; display: flex; flex-direction: column;">
        <div style="height: 48px; line-height: 48px; display: flex; justify-content: center; font-size: 24px; background-color: #98C5FC; "></div>
        <iframe id="child-iframe" src="/copilot/child.html" style="display:none"></iframe>
    </div>
</div>
</body>
</html>

child.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>child</title>
    <script>
        function load() {
            var topWindow = top.window;
            if (topWindow === window) {
                return;
            }
            var luiIframe = top.document.getElementById('app-iframe');
            if (luiIframe) {
                return;
            }

            luiIframe = top.document.createElement('iframe');
            luiIframe.setAttribute('id', 'app-iframe');
            luiIframe.setAttribute('src', "/copilot/app.html");
            top.document.body.appendChild(luiIframe);

            var child = topWindow.document.getElementById('child-iframe');
            if (child) {
                child.remove();
            }
        }

        load();
    </script>
</head>
<body>
<div>child</div>
</body>
</html>

app.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>app</title>
</head>
<body>
<div>app</div>
</body>

</html>

test code:

 cy.visit(urlPrefix + "portal.html", {
        retryOnStatusCodeFailure: true
    }).then((contentWindow) => {
        cy.wait(10000);

        cy.log("otcp-lui >>>> " + contentWindow.document.querySelector('iframe#otcp-lui'))
        cy.log("copilot-page >>>> " + contentWindow.document.querySelector('iframe#copilot-page'))
        cy.get('iframe#otcp-lui').should('exist');
        cy.get('iframe#copilot-page').should('exist');

        cy.wait(10000);
    })

Cypress Version

6.3.0

Node version

v10.24.1

Operating System

linux

Debug Logs

No response

Other

No response

@10229428 10229428 changed the title Cann't load iframe which is created dynamically Cann't load iframe which is created with setTimout Apr 10, 2024
@jennifer-shehane jennifer-shehane added stage: needs investigating Someone from Cypress needs to look at this topic: iframes labels Apr 16, 2024
@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Oct 14, 2024
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this stale no activity on this issue for a long period topic: iframes
Projects
None yet
Development

No branches or pull requests

3 participants