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(playwright): skip unloaded iframes #1060

Merged
merged 2 commits into from
May 13, 2024
Merged

fix(playwright): skip unloaded iframes #1060

merged 2 commits into from
May 13, 2024

Conversation

straker
Copy link
Contributor

@straker straker commented May 13, 2024

Pulled out of #1048. Starting in Playwright 1.41.0 (using Chrome version 121.0.6167.57) Playwright is no longer loading the lazy loaded iframe that is out of view. Updated the version of Playwright and updated the tests to now account for this.

QA notes: Test a lazy loaded iframe with Playwright > 1.41.0 and ensure Playwright will complete an analyze of the page

@straker straker requested a review from a team as a code owner May 13, 2024 15:12
@@ -185,7 +185,14 @@ export default class AxeBuilder {

private async inject(frames: Frame[]): Promise<void> {
for (const iframe of frames) {
await iframe.evaluate(await this.script());
const race = new Promise((_, reject) => {
Copy link
Contributor Author

@straker straker May 13, 2024

Choose a reason for hiding this comment

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

The newer versions of Playwright with the update to Chrome, combined with our changes to the lazy loaded frame test now make it so Playwright is not loading the lazy loaded iframe when it is outside the viewport.

Playwright does not have a pageload timeout like all the other drivers, and neither does the evaluate function have a timeout option. So this was the only other choice to have the lazy loaded iframe not hang indefinitely.

Copy link
Contributor

@Zidious Zidious left a comment

Choose a reason for hiding this comment

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

One comment inline -

packages/playwright/src/index.ts Show resolved Hide resolved
@straker straker merged commit d30dae4 into develop May 13, 2024
30 checks passed
@straker straker deleted the playwright-lazy branch May 13, 2024 17:46
@github-actions github-actions bot mentioned this pull request May 15, 2024
dequejenn added a commit that referenced this pull request May 16, 2024
##
[4.9.1](v4.9.0...v4.9.1)
(2024-05-15)


### Bug Fixes

* **playwright:** skip unloaded iframes
([#1060](#1060))
([d30dae4](d30dae4))
* Update axe-core to v4.9.1
([#1055](#1055))
([8644fbd](8644fbd))

No qa needed
@padmavemulapati
Copy link

padmavemulapati commented May 17, 2024

Verified with the latest canary-build (4.7.4-62fd241.0)
Lazy-loaded iframes are scanning properly now, not hanging,

1. Here is iframes snippets:

lazyloadedIframe.html

<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en" id="lazy-loading-iframe-root">
  <head>
    <title>Lazy Loading Iframe Root</title>
  </head>
  <body>
    <main>
      <h1>iframe context test</h1>
      <div style="margin-top: 3000vh">
        <iframe src="iframes/lazy.html" id="ifr-lazy" loading="lazy"></iframe>
      </div>
    </main>
  </body>
</html>
2. for this iframes - directory has a lazy.html file too

./iframes.lazy.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Lazy</title>
  </head>
  <body>
    <h1>Lazy</h1>
    <div style="margin-top: 3000vh">
      <iframe id="lazy-iframe" src="https://www.youtube.com/embed/REDRiwmNunA" title="MONTHLY SPOTLIGHT" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" loading="lazy"></iframe>
      <iframe src="baz.html" id="lazy-baz"></iframe>
    </div>
  </body>
</html>
3. for Playwright 1.44.0 Version and v1.42.1 :

TestScript:

const { AxeBuilder } = require('@axe-core/playwright')
const playwright = require('playwright')
const fs = require('fs')
const axe = require('axe-core')

;(async () => {
  const browser = await playwright.chromium.launch({ headless: true })
  const context = await browser.newContext()
  const page = await context.newPage()
  await page.goto('http://localhost:8081/iframesfixture.html')

  try {
   const results = await new AxeBuilder({page}).analyze();
    fs.writeFileSync('./lazyloadedIframes144.json', JSON.stringify(results, null, 4))
  } catch (e) {
    console.error(e)
  }

  await browser.close()
})()

Result for 1.44.0:

image

Result for 1.42.1:

image

4. For Puppeteer v22.9.0 and v22.6.3.

test-script:

const { AxePuppeteer } = require('@axe-core/puppeteer');
const puppeteer = require('puppeteer');
const fs = require('fs');

(async () => {
  const browser = await puppeteer.launch({ headless: false });
  const page = await browser.newPage();
  await page.setBypassCSP(true);
  await page.goto('http://localhost:8081/iframesfixture.html');
  const results = await new AxePuppeteer(page).analyze();
    fs.writeFile("./lazyframes_frametested.json", JSON.stringify(results, null,4),(err)=>
    {if(err){
        console.error(err);
        return;
        };
        console.log("File has been created");
    })

  await page.close();
  await browser.close();
})();

Results:
For 22.9.0

image

For 22.6.3

image

5.for webdriverjs - selenium-webdriver v4.21.0 & v4.19.0:

Test-script:

const { AxeBuilder } = require('@axe-core/webdriverjs');
const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const fs = require('fs');

(async () => {
  const driver = new Builder()
    .forBrowser('chrome')
    .setChromeOptions(new chrome.Options().headless())
    .build();
  await driver.get('http://localhost:8081/iframesfixture.html');
  try {
    const results = await new AxeBuilder(driver).analyze();
    fs.writeFile("./lazyiframestest.json", JSON.stringify(results, null,4),(err)=>
    {if(err){
        console.error(err);
        return;
        };
        console.log("File has been created");
    })
  } catch (e) {
    // do something with the error
  }

  await driver.quit();
})();
  

Result:
For 4.21.0

image

For 4.19.0

image

5. for CLI (selenium-webdriver v4.21.0 & 4.19.0)-

command is axe http://localhost:8081/iframesfixture.html --save ./iframesresult1

for selenium webdriver v4.21.0

image

for selenenium webdriver v4.19.0

image

6. for webdriverio:

TestScript:

const AxeBuilder = require('@axe-core/webdriverio').default;
const { remote } = require('webdriverio');
const fs = require('fs');

(async () => {
  const client = await remote({
    logLevel: 'error',
    capabilities: {
      browserName: 'chrome'
    }
  });

  await client.url('http://localhost:8081/iframesfixture.html');

  const builder = new AxeBuilder({ client });
  const results = await builder.analyze();
    fs.writeFile("./lazyiframestest.json", JSON.stringify(results, null,4),(err)=>
    {if(err){
        console.error(err);
        return;
        };
        console.log(results);
    })
   client.deleteSession();
})();


Result:

for 8.36.1

image

for 8.35.1

image

Environment:

Label Value
Product axe-core-npm
Version 4.9.2-a2f07c5.0
Playwright 1.44.0 & 1.42.1
Puppeteer 22.9.0 & 22.6.3
WebdriverIO _8.36.1 & 8.35.1 _
Selenium-webdriver(WebdriverJS & CLI) _ v4.21.0 & 4.19.0 _
OS-Details _MAC- M1-14.4 & Windows11 _
BrowserDetails Chrome Version 124.0.1 (Official Build) (64-bit) & Firefox 125.0.3

@dequejenn dequejenn mentioned this pull request May 20, 2024
github-merge-queue bot pushed a commit to camunda/camunda that referenced this pull request May 20, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@axe-core/playwright](https://togithub.com/dequelabs/axe-core-npm) |
[`4.9.0` ->
`4.9.1`](https://renovatebot.com/diffs/npm/@axe-core%2fplaywright/4.9.0/4.9.1)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@axe-core%2fplaywright/4.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@axe-core%2fplaywright/4.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@axe-core%2fplaywright/4.9.0/4.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@axe-core%2fplaywright/4.9.0/4.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>dequelabs/axe-core-npm (@&#8203;axe-core/playwright)</summary>

###
[`v4.9.1`](https://togithub.com/dequelabs/axe-core-npm/releases/tag/v4.9.1):
Release 4.9.1

[Compare
Source](https://togithub.com/dequelabs/axe-core-npm/compare/v4.9.0...v4.9.1)

#### What's Changed

- chore: bump ip from 1.1.8 to 1.1.9 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[dequelabs/axe-core-npm#1023
- test(cli): add test to cover selenium-webdriver <4.17.0 by
[@&#8203;michael-siek](https://togithub.com/michael-siek) in
[dequelabs/axe-core-npm#1038
- chore: merge master into develop by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[dequelabs/axe-core-npm#1041
- chore: bump undici from 5.28.3 to 5.28.4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[dequelabs/axe-core-npm#1042
- chore: update test-fixtures to fix lazy load iframe by
[@&#8203;straker](https://togithub.com/straker) in
[dequelabs/axe-core-npm#1053
- docs(react): Update React support information. Offer axe Developer Hub
by [@&#8203;ballendq](https://togithub.com/ballendq) in
[dequelabs/axe-core-npm#1047
- fix: Update axe-core to v4.9.1 by
[@&#8203;straker](https://togithub.com/straker) in
[dequelabs/axe-core-npm#1055
- chore: RC v4.9.1 by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[dequelabs/axe-core-npm#1057
- chore: Update axe-core to v4.9.1 by
[@&#8203;attest-team-ci](https://togithub.com/attest-team-ci) in
[dequelabs/axe-core-npm#1056
- fix(playwright): skip unloaded iframes by
[@&#8203;straker](https://togithub.com/straker) in
[dequelabs/axe-core-npm#1060
- chore: bump the npm-low-risk group across 1 directory with 28 updates
by [@&#8203;dependabot](https://togithub.com/dependabot) in
[dequelabs/axe-core-npm#1061
- chore: bump ejs from 3.1.9 to 3.1.10 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[dequelabs/axe-core-npm#1049
- ci: update sync to master to include team-reviewers by
[@&#8203;michael-siek](https://togithub.com/michael-siek) in
[dequelabs/axe-core-npm#1062
- chore: RC v4.9.1 by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[dequelabs/axe-core-npm#1065
- Release v4.9.1 by [@&#8203;dequejenn](https://togithub.com/dequejenn)
in
[dequelabs/axe-core-npm#1068

**Full Changelog**:
dequelabs/axe-core-npm@v4.9.0...v4.9.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/camunda/zeebe).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNjMuNSIsInVwZGF0ZWRJblZlciI6IjM3LjM2My41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWVyZ2UiXX0=-->
github-merge-queue bot pushed a commit to camunda/camunda that referenced this pull request May 20, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@axe-core/playwright](https://togithub.com/dequelabs/axe-core-npm) |
[`4.9.0` ->
`4.9.1`](https://renovatebot.com/diffs/npm/@axe-core%2fplaywright/4.9.0/4.9.1)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@axe-core%2fplaywright/4.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@axe-core%2fplaywright/4.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@axe-core%2fplaywright/4.9.0/4.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@axe-core%2fplaywright/4.9.0/4.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>dequelabs/axe-core-npm (@&#8203;axe-core/playwright)</summary>

###
[`v4.9.1`](https://togithub.com/dequelabs/axe-core-npm/releases/tag/v4.9.1):
Release 4.9.1

[Compare
Source](https://togithub.com/dequelabs/axe-core-npm/compare/v4.9.0...v4.9.1)

#### What's Changed

- chore: bump ip from 1.1.8 to 1.1.9 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[dequelabs/axe-core-npm#1023
- test(cli): add test to cover selenium-webdriver <4.17.0 by
[@&#8203;michael-siek](https://togithub.com/michael-siek) in
[dequelabs/axe-core-npm#1038
- chore: merge master into develop by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[dequelabs/axe-core-npm#1041
- chore: bump undici from 5.28.3 to 5.28.4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[dequelabs/axe-core-npm#1042
- chore: update test-fixtures to fix lazy load iframe by
[@&#8203;straker](https://togithub.com/straker) in
[dequelabs/axe-core-npm#1053
- docs(react): Update React support information. Offer axe Developer Hub
by [@&#8203;ballendq](https://togithub.com/ballendq) in
[dequelabs/axe-core-npm#1047
- fix: Update axe-core to v4.9.1 by
[@&#8203;straker](https://togithub.com/straker) in
[dequelabs/axe-core-npm#1055
- chore: RC v4.9.1 by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[dequelabs/axe-core-npm#1057
- chore: Update axe-core to v4.9.1 by
[@&#8203;attest-team-ci](https://togithub.com/attest-team-ci) in
[dequelabs/axe-core-npm#1056
- fix(playwright): skip unloaded iframes by
[@&#8203;straker](https://togithub.com/straker) in
[dequelabs/axe-core-npm#1060
- chore: bump the npm-low-risk group across 1 directory with 28 updates
by [@&#8203;dependabot](https://togithub.com/dependabot) in
[dequelabs/axe-core-npm#1061
- chore: bump ejs from 3.1.9 to 3.1.10 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[dequelabs/axe-core-npm#1049
- ci: update sync to master to include team-reviewers by
[@&#8203;michael-siek](https://togithub.com/michael-siek) in
[dequelabs/axe-core-npm#1062
- chore: RC v4.9.1 by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[dequelabs/axe-core-npm#1065
- Release v4.9.1 by [@&#8203;dequejenn](https://togithub.com/dequejenn)
in
[dequelabs/axe-core-npm#1068

**Full Changelog**:
dequelabs/axe-core-npm@v4.9.0...v4.9.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/camunda/zeebe).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNjMuNSIsInVwZGF0ZWRJblZlciI6IjM3LjM2My41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWVyZ2UiXX0=-->
github-merge-queue bot pushed a commit to camunda/camunda that referenced this pull request May 21, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@axe-core/playwright](https://togithub.com/dequelabs/axe-core-npm) |
[`4.9.0` ->
`4.9.1`](https://renovatebot.com/diffs/npm/@axe-core%2fplaywright/4.9.0/4.9.1)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@axe-core%2fplaywright/4.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@axe-core%2fplaywright/4.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@axe-core%2fplaywright/4.9.0/4.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@axe-core%2fplaywright/4.9.0/4.9.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>dequelabs/axe-core-npm (@&#8203;axe-core/playwright)</summary>

###
[`v4.9.1`](https://togithub.com/dequelabs/axe-core-npm/releases/tag/v4.9.1):
Release 4.9.1

[Compare
Source](https://togithub.com/dequelabs/axe-core-npm/compare/v4.9.0...v4.9.1)

#### What's Changed

- chore: bump ip from 1.1.8 to 1.1.9 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[dequelabs/axe-core-npm#1023
- test(cli): add test to cover selenium-webdriver <4.17.0 by
[@&#8203;michael-siek](https://togithub.com/michael-siek) in
[dequelabs/axe-core-npm#1038
- chore: merge master into develop by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[dequelabs/axe-core-npm#1041
- chore: bump undici from 5.28.3 to 5.28.4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[dequelabs/axe-core-npm#1042
- chore: update test-fixtures to fix lazy load iframe by
[@&#8203;straker](https://togithub.com/straker) in
[dequelabs/axe-core-npm#1053
- docs(react): Update React support information. Offer axe Developer Hub
by [@&#8203;ballendq](https://togithub.com/ballendq) in
[dequelabs/axe-core-npm#1047
- fix: Update axe-core to v4.9.1 by
[@&#8203;straker](https://togithub.com/straker) in
[dequelabs/axe-core-npm#1055
- chore: RC v4.9.1 by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[dequelabs/axe-core-npm#1057
- chore: Update axe-core to v4.9.1 by
[@&#8203;attest-team-ci](https://togithub.com/attest-team-ci) in
[dequelabs/axe-core-npm#1056
- fix(playwright): skip unloaded iframes by
[@&#8203;straker](https://togithub.com/straker) in
[dequelabs/axe-core-npm#1060
- chore: bump the npm-low-risk group across 1 directory with 28 updates
by [@&#8203;dependabot](https://togithub.com/dependabot) in
[dequelabs/axe-core-npm#1061
- chore: bump ejs from 3.1.9 to 3.1.10 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[dequelabs/axe-core-npm#1049
- ci: update sync to master to include team-reviewers by
[@&#8203;michael-siek](https://togithub.com/michael-siek) in
[dequelabs/axe-core-npm#1062
- chore: RC v4.9.1 by
[@&#8203;github-actions](https://togithub.com/github-actions) in
[dequelabs/axe-core-npm#1065
- Release v4.9.1 by [@&#8203;dequejenn](https://togithub.com/dequejenn)
in
[dequelabs/axe-core-npm#1068

**Full Changelog**:
dequelabs/axe-core-npm@v4.9.0...v4.9.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/camunda/zeebe).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNjMuNSIsInVwZGF0ZWRJblZlciI6IjM3LjM2My41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWVyZ2UiXX0=-->
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.

None yet

3 participants