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

fix: supported switching to iframes that are places in a Shadow Root #7139

Merged
merged 8 commits into from Jul 20, 2022

Conversation

Aleksey28
Copy link
Collaborator

@Aleksey28 Aleksey28 commented Jul 11, 2022

[closes #3673]

Purpose

Support switching to Iframes that are places in a Shadow Root

Approach

  1. Add test for switching to iframes that are places in a Shadow Root
  2. Fix searching driverIframe in the DOM for instances ChildIframeDriverLink

References

#3673

Pre-Merge TODO

  • Write tests for your proposed changes
  • Make sure that existing tests do not fail

@Aleksey28 Aleksey28 temporarily deployed to CI July 11, 2022 15:55 Inactive
@Aleksey28 Aleksey28 temporarily deployed to CI July 12, 2022 09:12 Inactive
@Aleksey28 Aleksey28 temporarily deployed to CI July 12, 2022 13:15 Inactive
@Aleksey28 Aleksey28 temporarily deployed to CI July 12, 2022 13:46 Inactive
@Aleksey28 Aleksey28 temporarily deployed to CI July 12, 2022 13:50 Inactive
@Aleksey28 Aleksey28 temporarily deployed to CI July 12, 2022 14:04 Inactive
@Aleksey28 Aleksey28 temporarily deployed to CI July 12, 2022 14:24 Inactive
@Aleksey28 Aleksey28 temporarily deployed to CI July 12, 2022 14:37 Inactive
@Aleksey28 Aleksey28 temporarily deployed to CI July 12, 2022 15:01 Inactive
@Aleksey28 Aleksey28 temporarily deployed to CI July 12, 2022 15:17 Inactive
@Aleksey28 Aleksey28 temporarily deployed to CI July 12, 2022 15:30 Inactive
@Aleksey28 Aleksey28 temporarily deployed to CI July 12, 2022 18:30 Inactive
export function findIframeByWindow (iframeWindow) {
const iframes = [];

document.querySelectorAll('*').forEach(elem => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the native methods from the hammerhead.nativeMethods for querySelector, querySelectorAll functions.

Consider using the find method from hammerhead here.

if (elem.tagName === 'IFRAME')
iframes.push(elem);

if (elem.shadowRoot)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using the the forEach method here. It can be overridden and it's not cross-browser code (we are still supporting IE).

@@ -52,6 +52,21 @@ test('Click on element in a nested iframe', async t => {
expect(iframeBtnClickCount).eql(1);
});

test.page`http://localhost:3000/fixtures/api/es-next/iframe-switching/pages/shadow.html`
('Click on an element in a shadow iframe and return to the main window', async t => {
await t
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test for the case with nested shadow roots with iframes:

  • element
    • shadowRoot
      • iframe
        • element
          • shadowRoot
            • iframe

@Aleksey28 Aleksey28 temporarily deployed to CI July 13, 2022 09:37 Inactive
@Aleksey28 Aleksey28 temporarily deployed to CI July 13, 2022 09:44 Inactive
@AndreyBelym AndreyBelym merged commit bc8bac1 into DevExpress:master Jul 20, 2022
@github-actions
Copy link

Release v1.20.1-rc.1 addresses this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support switching to Iframes that are places in a Shadow Root
3 participants