Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static async audit(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const metricData = {
devtoolsLog,
trace,
settings: context.settings,
};
const {timing} = await ComputedAdRenderTime.request(metricData, context);
if (!(timing > 0)) { // Handle NaN, etc.
context.LighthouseRunWarnings.push(runWarning.NoAdRendered);
return auditNotApplicable.NoAdRendered;
}
const scoreOptions =
context.options[global.isLightrider ? 'default' : 'lightrider'];
return {
static async audit(artifacts, context) {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const unfilteredNetworkRecords =
await NetworkRecords.request(devtoolsLog, context);
if (!unfilteredNetworkRecords.length) {
return auditNotApplicable.NoRecords;
}
const mainResource =
await MainResource.request({URL: artifacts.URL, devtoolsLog}, context);
// Filter out requests without responses, image responses, and responses
// taking less than 50ms.
const networkRecords = unfilteredNetworkRecords
.filter(isPossibleBid)
.filter((r) => r.frameId == mainResource.frameId);
// We filter for URLs that are related to header bidding.
static async audit(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const metricData = {trace, devtoolsLog, settings: context.settings};
const {timing} = await ComputedBidRequestTime.request(metricData, context);
if (!(timing > 0)) { // Handle NaN, etc.
return auditNotApplicable.NoBids;
}
return {
numericValue: timing * 1e-3,
score: Audit.computeLogNormalScore(
timing,
context.options.scorePODR,
context.options.scoreMedian
),
displayValue: str_(UIStrings.displayValue, {timeInMs: timing}),
static async audit(artifacts, context) {
// Artifacts requested in `requiredArtifacts` above are passed to your audit.
// See the "API -> Plugin Audits" section below for what artifacts are available.
try {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const requests = await NetworkRecords.request(devtoolsLog, context);
let domains = new Set()
requests.forEach(req => {
domains.add(new URL(req.url).host)
})
// the spread syntax turns our deduped set into an array, then makes sure they're long enough to check
const domainArray = [...domains].filter(domain => domain.length > 2)
const checkResults = await Greencheck.checkDomains(domainArray)
const greyDomainResults = checkResults.greenChecks.filter(res => res.green == false)
const tableDetails = GreenAudit.convertToTableDetails(checkResults.greenChecks)
return {
score: checkResults.score,
static async audit(artifacts, context) {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
const tag = networkRecords.find((req) => isAdTag(new URL(req.url)));
if (!tag) {
return auditNotApplicable.NoTag;
}
/** @type {Map} */
const timingsByRecord =
await getTimingsByRecord(trace, devtoolsLog, context);
// NOTE(warrengm): Ideally we would key be requestId here but LinkElements
// don't have request IDs.
/** @type {Set} */
const blockingElementUrls = new Set();
for (const link of artifacts.LinkElements) {
// TODO(warrengm): Check for media queries? Or is the network filter below
static async audit(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const metricData = {trace, devtoolsLog, settings: context.settings};
const {timing} = await ComputedBidRequestTime.request(metricData, context);
if (!(timing > 0)) { // Handle NaN, etc.
return auditNotApplicable.NoBids;
}
return {
numericValue: timing * 1e-3,
score: Audit.computeLogNormalScore(
timing,
context.options.scorePODR,
context.options.scoreMedian
),
displayValue: str_(UIStrings.displayValue, {timeInMs: timing}),
};
static async audit(artifacts, context) {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
const gptUrl = networkRecords.map((r) => new URL(r.url)).find(isGptTag);
if (!gptUrl) {
return auditNotApplicable.NoGpt;
}
const passed = (gptUrl.host === 'securepubads.g.doubleclick.net');
return {
score: Number(passed),
numericValue: Number(!passed),
};
}
}
static async audit(artifacts, context) {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
const mainResource =
await MainResource.request({URL: artifacts.URL, devtoolsLog}, context);
const tagReqs = networkRecords
.filter((req) => isAdTag(new URL(req.url)))
.filter((req) => req.frameId === mainResource.frameId);
if (!tagReqs.length) {
return auditNotApplicable.NoTag;
}
const numSync = array.count(tagReqs, isAsync) - tagReqs.length;
const passed = (numSync === 0);
return {
score: Number(passed),
numericValue: numSync,
static async audit(artifacts, context) {
const devtoolsLogs = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const networkRecords = await NetworkRecords.request(devtoolsLogs, context);
const viewport = artifacts.ViewportDimensions;
const vpWidth = viewport.innerWidth;
/** @type {Array} */
const adRequestUrls = networkRecords
.filter(isAdRequest)
.map((record) => new URL(record.url));
if (!adRequestUrls.length) {
return auditNotApplicable.NoAds;
}
const sizeArrs = adRequestUrls.map((url) =>
url.searchParams.get('prev_iu_szs') || url.searchParams.get('sz'));