Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
fix: Improve error message when an iframe was removed (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdnoC authored Jul 9, 2019
1 parent cddebec commit d625312
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/axe-injector.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { StaleElementReferenceError } = require('selenium-webdriver').error;

class AxeInjector {
constructor({ driver, config, axeSource = null }) {
this.driver = driver;
Expand All @@ -9,15 +11,20 @@ class AxeInjector {
}

// Single-shot error handler. Ensures we don't log more than once.
errorHandler() {
errorHandler(err) {
// We've already "warned" the user. No need to do it again (mostly for backwards compatiability)
if (this.didLogError) {
return;
}

this.didLogError = true;
// eslint-disable-next-line no-console
console.error('Failed to inject axe-core into one of the iframes!');
if (err instanceof StaleElementReferenceError) {
// eslint-disable-next-line no-console
console.error('Tried to inject into a removed iframe. This will not affect the analysis of the rest of the page but you might want to ensure the page has finished updating before starting the analysis.')
} else {
// eslint-disable-next-line no-console
console.error('Failed to inject axe-core into one of the iframes!');
}
}

// Get axe-core source (and configuration)
Expand Down

0 comments on commit d625312

Please sign in to comment.