Audits page source against aXe: https://github.com/dequelabs/axe-core

@param {Object} context The plugin context object
@return {q.Promise} A promise which resolves when the audit is finished
@private
185437
function runAxe(context) {

  var deferred = q.defer();

  AxeBuilder(browser.driver).options(context.config.axe)
    .analyze(function(results) {
      deferred.resolve(results);
    });

  return deferred.promise.then(function(results) {
    return processAxeResults(results);
  });

  function processAxeResults(results) {

    var testHeader = 'aXe - '

    var numResults = results.violations.length;

    if (numResults === 0) {
      return context.addSuccess();
    }

    results.passes.forEach(function(result) {
      context.addSuccess({specName: testHeader + result.help});
    });

    return results.violations.forEach(function(result) {
      var label = result.nodes.length === 1 ? ' element ' : ' elements ';
      var msg = result.nodes.reduce(function(msg, node) {
        return msg + '\t\t' + node.html + '\n';
      }, '\n');
      msg = '\n\t\t' + result.nodes.length + label + 'failed:' + msg + '\n\n\t\t' + result.helpUrl
      context.addFailure(msg, {specName: testHeader + result.help});
    });

  }

}
594304
function ( fn, context ) {

		// Initialize variables
		this.state = Promise.STATE.INITIALIZED;
		this.handlers = [];
		this.value = fn;

		// Rebind control functions to be run always on this promise
		this.resolve = this.resolve.bind( this );
		this.fulfill = this.fulfill.bind( this );
		this.reject = this.reject.bind( this );

		// Set fn and context
		if ( fn ) {
			if ( typeof fn !== 'function' ) throw new TypeError("fn is not a function");

			this.fn = fn;
			this.context = context || this;

			this.run();

		}

		return this;
	}
336456
function Plugin() {

    this.name = "Audit-Plugin";
    this.resources = new Map();
    this.duplicateContents = new Map();
    this.inLinks = new Map();
    this.outLinks = new Map();
    this.externalLinks = new Map();
    this.unparsedLinks =  new Set();
    this.images = new Map();
    this.errors = new Set();
    this.redirects = new Map();


}
1163346
function create(context) {
    return {
        AssignmentExpression(node) {
            if (assignsToModuleExports(node) && ancestor(isCommonJsWrapper, node)) {
                context.report(node, message);
            }
        }
    };
}
721031
function checkAccess({ accessToken, id, model, method, options, ctx }) {

     return new Promise((resolve, reject) => {
         // ignore checking if does not enable auth
         if (model.app.isAuthEnabled) {
             if (!model.app.models.ACL) {
                 console.log('ACL has not been setup, skipping access check.')
                 resolve(true);
             } else {
                 model.checkAccess(accessToken, id, method, ctx,
                     ((err, allowed) => {
                         if (err)
                             reject(err);
                         else if (allowed)
                             resolve(allowed);
                         else
                             reject(`ACCESS_DENIED`);
                     }));
             }
         } else {
             resolve(true);
         }
     })

 }
685089
function Context(data, parent, path, env) {
	/** 
	 * Context will inherit of AsyncCollector to manage all internal or external asynchroneous calls.
	 * It allows us to know when a context and its descendants are stabilised(i.e.all data are up to date).
	 **/
	AsyncCollector.call(this);
	this.__yContext__ = true;
	this.data = (data !== undefined) ? data : {};
	this.map = {};
	this.binds = [];
	if (parent) {
		this.parent = parent;
		this.env = env ? new Context(env) : parent.env;
		if (path) {
			var self = this;
			this.path = path;
			this.data = this.data || parent.get(path);
			this.parent.subscribe(path, function(value, type, p, key) {
				// console.log('binded context update : ', type, path, p, key, value);
				if (!p.length)
					p.push('$this');
				switch (type) {
					case 'set':
						self.set(p, value, true);
						break;
					case 'push':
						self.push(p, value, true);
						break;
					case 'delete':
						self.del(p, true);
						break;
					case 'displaceItem':
						self.displaceItem(p, value, true);
						break;
					case 'insertItem':
						self.insertItem(p, value, true);
						break;
					case 'deleteItem':
						self.deleteItem(p, value, true);
						break;
				}
			}, true, this.binds);
		}
	} else
		this.env = env ? (env.__yContext__ ? env : new Env(env)) : Context.env;
}
661830
function create(context) {
    return {
        CallExpression(node) {
            if (isFunctionDefine(node)) {
                context.report(node, message);
            }
        }
    };
}
1232247
function OperativeContext(module, dependencies, getBaseURL, getSelfURL) {

		var _self = this;

		module.get = module.get || function(prop) {
			return this[prop];
		};

		module.set = module.set || function(prop, value) {
			return this[prop] = value;
		};

		this._curToken = 0;
		this._queue = [];

		this._getBaseURL = getBaseURL;
		this._getSelfURL = getSelfURL;

		this.isDestroyed = false;
		this.isContextReady = false;

		this.module = module;
		this.dependencies = dependencies || [];

		this.dataProperties = {};
		this.api = {};
		this.callbacks = {};
		this.deferreds = {};

		this._fixDependencyURLs();
		this._setup();

		for (var methodName in module) {
			if (hasOwn.call(module, methodName)) {
				this._createExposedMethod(methodName);
			}
		}

		this.api.__operative__ = this;

		// Provide the instance's destroy method on the exposed API:
		this.api.destroy = this.api.terminate = function() {
			return _self.destroy();
		};

	}
1100467
function (reqContext, name, args) {
    return BPromise.resolve()
        .bind(this)
        .then(function () {
            var method = this._methods[name];
            if (!method) {
                throw new MWError(404, "Method not found");
            }
            var context = R.merge(method.context, reqContext);
            return method.fn.apply(context, args);
        });
}
526673
function getAppContext(apps) {
  var funcs = [
    getAppContextFromArgv,
    getAppContextFromCwd,
    getAppContextFromCwdConfig
  ];
  return Promise.reduce(funcs, function(acc, func) {
    return acc || func(apps);
  }, null);
}
214055
function(context, pkg, isRoot, deps){
		var stealPkg = utils.filter(deps, function(dep){
			return dep && dep.name === "steal";
		})[0];

		if(stealPkg) {
			return crawl.fetchDep(context, pkg, stealPkg, isRoot)
				.then(function(childPkg){
					if(childPkg) {
						return crawl.deps(context, childPkg);
					}
				});
		} else {
			return Promise.resolve();
		}
	}
865557
function(context){
    Object.defineProperty(context, 'length', {
        get: function() {
            var count = 0;

            // count valid accounts in browser storage
            _.each(this.get(), function(account, accountIndex){
                if(_.isUndefined(account)
                  || !_.isObject(account)
                  || _.isString(account))
                    return;

                if(!_.has(account, 'encrypted')
                   || !_.has(account, 'private'))
                    return;

                count += 1;
            });

            return count;
        }
    });
}
286275
function(editorContext, ctxt) {
		var promise = new Deferred();
		var launchConf = this._setup.runBar.getSelectedLaunchConfiguration();
		if (launchConf) {
			this._projectClient.getProjectDeployService(launchConf.ServiceId, launchConf.Type).then(function(service){
				if (service && service.computeHoverInfo) {
					service.computeHoverInfo(launchConf, editorContext, ctxt).then(function(value) {
						promise.resolve(value);
					}, function() {
						promise.resolve(null);
					});
				} else {
					console.error('Failed to evaluate hover.');
					promise.resolve(null);
				}
			});
		} else {
			promise.resolve(null);
		}
		return promise;
	}
558354
@Trivial
    protected AuditThreadContext getAuditThreadContext() {
        ThreadLocal<AuditThreadContext> currentThreadLocal = getThreadLocal();
        AuditThreadContext auditThreadContext = currentThreadLocal.get();
        if (auditThreadContext == null) {
            auditThreadContext = new AuditThreadContext();
            currentThreadLocal.set(auditThreadContext);
        }
        return auditThreadContext;
    }
150862
function Promise(cb, ctx) {
  this.context = ctx;
  this.thenChain = [];
  this.errCb = null;
  this.noErrorCb = null;
  process.nextTick(function() {
    cb();
  });
}
297911
function teardown() {

  var audits = [];

  if (this.config.axe) {
    audits.push(runAxe(this));
  }

  if (this.config.chromeA11YDevTools) {
    audits.push(runChromeDevTools(this));
  }
  // check for Tenon config and an actual API key, not the placeholder
  if (this.config.tenonIO && /[A-Za-z][0-9]/.test(
      this.config.tenonIO.options.key)) {
    audits.push(runTenonIO(this));
  }
  return q.all(audits);
}
131999
function onActFinished(context, next) {
  const msg = context.response.payload

  // pass to act context
  if (msg) {
    context.request$ = msg.request || {}
    context.trace$ = msg.trace || {}
    context.meta$ = msg.meta || {}
  }

  // calculate request duration
  const now = Util.nowHrTime()
  const diff = now - context.trace$.timestamp
  context.trace$.duration = diff

  if (context._config.traceLog) {
    context.log = context.log.child({
      tag: context._config.tag,
      requestId: context.request$.id,
      parentSpanId: context.trace$.parentSpanId,
      traceId: context.trace$.traceId,
      spanId: context.trace$.spanId
    })
    context.log.info(
      {
        pattern: context.trace$.method,
        responseTime: context.trace$.duration
      },
      'Request completed'
    )
  } else {
    context.log.info(
      {
        requestId: context.request$.id,
        pattern: context.trace$.method,
        responseTime: context.trace$.duration
      },
      'Request completed'
    )
  }

  next()
}