diff --git a/packages/webdriverjs/src/axe-injector.ts b/packages/webdriverjs/src/axe-injector.ts index 390521db..9c2d7b54 100644 --- a/packages/webdriverjs/src/axe-injector.ts +++ b/packages/webdriverjs/src/axe-injector.ts @@ -139,7 +139,9 @@ export default class AxeInjector { await this.driver.executeScript(this.script); - const frames = await this.driver.findElements({ tagName: 'iframe' }); + const ifs = await this.driver.findElements({ tagName: 'iframe' }); + const fs = await this.driver.findElements({ tagName: 'frame' }); + const frames = ifs.concat(fs); for (const childFrames of frames) { framePath.push(childFrames); @@ -171,8 +173,10 @@ export default class AxeInjector { // XXX: if this `executeScript` fails, we *want* to error, as we cannot run axe-core. await this.driver.executeScript(this.script); - // Get all of - + + + diff --git a/packages/webdriverjs/src/test/fixtures/frames/foo.html b/packages/webdriverjs/src/test/fixtures/frames/foo.html index 9ab66c76..d906571a 100644 --- a/packages/webdriverjs/src/test/fixtures/frames/foo.html +++ b/packages/webdriverjs/src/test/fixtures/frames/foo.html @@ -3,8 +3,7 @@ Foo - -

Foo

- - + + + diff --git a/packages/webdriverjs/src/test/fixtures/frames/recursive.html b/packages/webdriverjs/src/test/fixtures/frames/recursive.html deleted file mode 100644 index 3a3ce063..00000000 --- a/packages/webdriverjs/src/test/fixtures/frames/recursive.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - Recursive - - -

Recursive

- - - diff --git a/packages/webdriverjs/src/test/fixtures/iframes/bar.html b/packages/webdriverjs/src/test/fixtures/iframes/bar.html new file mode 100644 index 00000000..594c0dc2 --- /dev/null +++ b/packages/webdriverjs/src/test/fixtures/iframes/bar.html @@ -0,0 +1,10 @@ + + + + Bar + + +

Bar

+ + + diff --git a/packages/webdriverjs/src/test/fixtures/iframes/baz.html b/packages/webdriverjs/src/test/fixtures/iframes/baz.html new file mode 100644 index 00000000..b5f94320 --- /dev/null +++ b/packages/webdriverjs/src/test/fixtures/iframes/baz.html @@ -0,0 +1,9 @@ + + + + Baz + + +

Baz

+ + diff --git a/packages/webdriverjs/src/test/fixtures/iframes/foo.html b/packages/webdriverjs/src/test/fixtures/iframes/foo.html new file mode 100644 index 00000000..86fe0d49 --- /dev/null +++ b/packages/webdriverjs/src/test/fixtures/iframes/foo.html @@ -0,0 +1,10 @@ + + + + Foo + + +

Foo

+ + + diff --git a/packages/webdriverjs/src/test/fixtures/inner-configure-frame.html b/packages/webdriverjs/src/test/fixtures/inner-configure-frame.html new file mode 100644 index 00000000..c24cf9ab --- /dev/null +++ b/packages/webdriverjs/src/test/fixtures/inner-configure-frame.html @@ -0,0 +1,6 @@ + + + + Hello + + diff --git a/packages/webdriverjs/src/test/fixtures/multiple-frames.html b/packages/webdriverjs/src/test/fixtures/multiple-frames.html deleted file mode 100644 index 2547a902..00000000 --- a/packages/webdriverjs/src/test/fixtures/multiple-frames.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Multiple Frames - - - -

this page has 3 iframes (no recursion)

-


- - - - - - diff --git a/packages/webdriverjs/src/test/fixtures/nested-frames.html b/packages/webdriverjs/src/test/fixtures/nested-frames.html index 6f6f75b4..c9dd981b 100644 --- a/packages/webdriverjs/src/test/fixtures/nested-frames.html +++ b/packages/webdriverjs/src/test/fixtures/nested-frames.html @@ -3,9 +3,7 @@ Nested Frames - -

This page has nested frames!

-


- - + + + diff --git a/packages/webdriverjs/src/test/fixtures/nested-iframes.html b/packages/webdriverjs/src/test/fixtures/nested-iframes.html new file mode 100644 index 00000000..3a7a1433 --- /dev/null +++ b/packages/webdriverjs/src/test/fixtures/nested-iframes.html @@ -0,0 +1,11 @@ + + + + Nested Frames + + +

This page has nested frames!

+


+ + + diff --git a/packages/webdriverjs/src/test/fixtures/outer-configure-frame.html b/packages/webdriverjs/src/test/fixtures/outer-configure-frame.html index 6b5cb58c..f88d6b50 100644 --- a/packages/webdriverjs/src/test/fixtures/outer-configure-frame.html +++ b/packages/webdriverjs/src/test/fixtures/outer-configure-frame.html @@ -3,7 +3,7 @@ Configure Frame Test - - - + + + diff --git a/packages/webdriverjs/src/test/fixtures/outer-configure-iframe.html b/packages/webdriverjs/src/test/fixtures/outer-configure-iframe.html new file mode 100644 index 00000000..6b5cb58c --- /dev/null +++ b/packages/webdriverjs/src/test/fixtures/outer-configure-iframe.html @@ -0,0 +1,9 @@ + + + + Configure Frame Test + + + + + diff --git a/packages/webdriverjs/src/test/fixtures/recursive-frames.html b/packages/webdriverjs/src/test/fixtures/recursive-frames.html deleted file mode 100644 index 6725009f..00000000 --- a/packages/webdriverjs/src/test/fixtures/recursive-frames.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - Recursive Frames - - -

This page has a weird recursive frams!

-


- - - - diff --git a/packages/webdriverjs/src/test/test.ts b/packages/webdriverjs/src/test/test.ts index 865a6efa..04fea3fc 100644 --- a/packages/webdriverjs/src/test/test.ts +++ b/packages/webdriverjs/src/test/test.ts @@ -83,6 +83,26 @@ describe('@axe-core/webdriverjs', () => { }); describe('configure', () => { + it('should find configured violations in all iframes', async () => { + await driver.get(`${addr}/outer-configure-iframe.html`); + const results = await new AxeBuilder(driver) + .options({ + rules: { + 'landmark-one-main': { enabled: false }, + 'page-has-heading-one': { enabled: false }, + region: { enabled: false }, + 'html-lang-valid': { enabled: false }, + bypass: { enabled: false } + } + }) + .configure(json) + .analyze(); + + assert.equal(results.violations[0].id, 'dylang'); + // the second violation is in a iframe + assert.equal(results.violations[0].nodes.length, 2); + }); + it('should find configured violations in all frames', async () => { await driver.get(`${addr}/outer-configure-frame.html`); const results = await new AxeBuilder(driver) @@ -135,6 +155,22 @@ describe('@axe-core/webdriverjs', () => { }); describe('iframe tests', () => { + it('injects into nested iframes', async () => { + await driver.get(`${addr}/nested-iframes.html`); + const executeSpy = sinon.spy(driver, 'executeScript'); + await new AxeBuilder(driver).analyze(); + /** + * Ensure we called execute 4 times + * 1. nested-iframes.html + * 2. iframes/foo.html + * 3. iframes/bar.html + * 4. iframes/baz.html + */ + assert.strictEqual(executeSpy.callCount, 4); + }); + }); + + describe('frame tests', () => { it('injects into nested frames', async () => { await driver.get(`${addr}/nested-frames.html`); const executeSpy = sinon.spy(driver, 'executeScript'); @@ -142,9 +178,9 @@ describe('@axe-core/webdriverjs', () => { /** * Ensure we called execute 4 times * 1. nested-frames.html - * 2. foo.html - * 3. bar.html - * 4. baz.html + * 2. frames/foo.html + * 3. frames/bar.html + * 4. frames/baz.html */ assert.strictEqual(executeSpy.callCount, 4); });