diff --git a/lighthouse-plugin-publisher-ads/audits/ad-blocking-tasks.js b/lighthouse-plugin-publisher-ads/audits/ad-blocking-tasks.js index e5bacaac..96e94bb0 100644 --- a/lighthouse-plugin-publisher-ads/audits/ad-blocking-tasks.js +++ b/lighthouse-plugin-publisher-ads/audits/ad-blocking-tasks.js @@ -13,7 +13,7 @@ const LongTasks = require('../computed/long-tasks'); const {auditNotApplicable} = require('../messages/common-strings'); const {Audit} = require('lighthouse'); const {getAttributableUrl} = require('../utils/tasks'); -const {isGpt} = require('../utils/resource-classification'); +const {isAdScript} = require('../utils/resource-classification'); const {URL} = require('url'); const UIStrings = { @@ -124,7 +124,7 @@ class AdBlockingTasks extends Audit { continue; } const scriptUrl = getAttributableUrl(longTask); - if (scriptUrl && isGpt(new URL(scriptUrl))) { + if (scriptUrl && isAdScript(new URL(scriptUrl))) { continue; } diff --git a/lighthouse-plugin-publisher-ads/audits/ad-render-blocking-resources.js b/lighthouse-plugin-publisher-ads/audits/ad-render-blocking-resources.js index 1f7ffd32..0f4b55a2 100644 --- a/lighthouse-plugin-publisher-ads/audits/ad-render-blocking-resources.js +++ b/lighthouse-plugin-publisher-ads/audits/ad-render-blocking-resources.js @@ -19,7 +19,7 @@ const RenderBlockingResources = require('lighthouse/lighthouse-core/audits/byte- const {auditNotApplicable} = require('../messages/common-strings'); const {Audit} = require('lighthouse'); const {getPageStartTime} = require('../utils/network-timing'); -const {isGptTag} = require('../utils/resource-classification'); +const {isAdTag} = require('../utils/resource-classification'); const {URL} = require('url'); const UIStrings = { @@ -88,7 +88,7 @@ class AdRenderBlockingResources extends RenderBlockingResources { static async audit(artifacts, context) { const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS]; const networkRecords = await NetworkRecords.request(devtoolsLog, context); - const hasTag = !!networkRecords.find((req) => isGptTag(new URL(req.url))); + const hasTag = !!networkRecords.find((req) => isAdTag(new URL(req.url))); if (!hasTag) { return auditNotApplicable.NoTag; } diff --git a/lighthouse-plugin-publisher-ads/audits/ad-top-of-viewport.js b/lighthouse-plugin-publisher-ads/audits/ad-top-of-viewport.js index 040d4cff..0488b549 100644 --- a/lighthouse-plugin-publisher-ads/audits/ad-top-of-viewport.js +++ b/lighthouse-plugin-publisher-ads/audits/ad-top-of-viewport.js @@ -15,7 +15,7 @@ const i18n = require('lighthouse/lighthouse-core/lib/i18n/i18n'); const {auditNotApplicable} = require('../messages/common-strings'); const {Audit} = require('lighthouse'); -const {isGptIframe} = require('../utils/resource-classification'); +const {isAdIframe} = require('../utils/resource-classification'); const UIStrings = { title: 'No ad found at the very top of the viewport', @@ -67,7 +67,7 @@ class AdTopOfViewport extends Audit { */ static audit(artifacts) { const viewport = artifacts.ViewportDimensions; - const slots = artifacts.IFrameElements.filter(isGptIframe) + const slots = artifacts.IFrameElements.filter(isAdIframe) .filter((slot) => slot.isVisible && !slot.isFixed) .map((slot) => ({ midpoint: slot.clientRect.top + slot.clientRect.height / 2, diff --git a/lighthouse-plugin-publisher-ads/audits/ads-in-viewport.js b/lighthouse-plugin-publisher-ads/audits/ads-in-viewport.js index 35345ffe..6835cfad 100644 --- a/lighthouse-plugin-publisher-ads/audits/ads-in-viewport.js +++ b/lighthouse-plugin-publisher-ads/audits/ads-in-viewport.js @@ -16,8 +16,8 @@ const {auditNotApplicable} = require('../messages/common-strings'); const {Audit} = require('lighthouse'); const i18n = require('lighthouse/lighthouse-core/lib/i18n/i18n'); +const {isAdIframe} = require('../utils/resource-classification'); const {isBoxInViewport} = require('../utils/geometry'); -const {isGptIframe} = require('../utils/resource-classification'); const UIStrings = { title: 'Few or no ads loaded outside viewport', @@ -67,7 +67,7 @@ class AdsInViewport extends Audit { static audit(artifacts) { const viewport = artifacts.ViewportDimensions; const slots = artifacts.IFrameElements - .filter((iframe) => isGptIframe(iframe) && iframe.isVisible); + .filter((iframe) => isAdIframe(iframe) && iframe.isVisible); if (!slots.length) { return auditNotApplicable.NoVisibleSlots; diff --git a/lighthouse-plugin-publisher-ads/audits/async-ad-tags.js b/lighthouse-plugin-publisher-ads/audits/async-ad-tags.js index 79af52dd..bd9d3204 100644 --- a/lighthouse-plugin-publisher-ads/audits/async-ad-tags.js +++ b/lighthouse-plugin-publisher-ads/audits/async-ad-tags.js @@ -19,15 +19,15 @@ const MainResource = require('lighthouse/lighthouse-core/computed/main-resource' const NetworkRecords = require('lighthouse/lighthouse-core/computed/network-records'); const {auditNotApplicable} = require('../messages/common-strings'); const {Audit} = require('lighthouse'); -const {isGptTag, isStaticRequest} = require('../utils/resource-classification'); +const {isAdTag, isStaticRequest} = require('../utils/resource-classification'); const {URL} = require('url'); const UIStrings = { - title: 'GPT tag is loaded asynchronously', - failureTitle: 'Load GPT asynchronously', - description: 'Loading the GPT tag synchronously blocks content rendering ' + + title: 'Ad tag is loaded asynchronously', + failureTitle: 'Load ad tag asynchronously', + description: 'Loading the ad tag synchronously blocks content rendering ' + 'until the tag is fetched and loaded. Consider using the `async` attribute ' + - 'to load gpt.js asynchronously. [Learn more](' + + 'to load gpt.js and/or adsbygoogle.js asynchronously. [Learn more](' + 'https://developers.google.com/publisher-ads-audits/reference/audits/async-ad-tags' + ').', }; @@ -72,7 +72,7 @@ class AsyncAdTags extends Audit { const mainResource = await MainResource.request({URL: artifacts.URL, devtoolsLog}, context); const tagReqs = networkRecords - .filter((req) => isGptTag(new URL(req.url))) + .filter((req) => isAdTag(new URL(req.url))) .filter((req) => req.frameId === mainResource.frameId); if (!tagReqs.length) { diff --git a/lighthouse-plugin-publisher-ads/audits/first-ad-paint.js b/lighthouse-plugin-publisher-ads/audits/first-ad-paint.js index f44dcb78..c19e1d1b 100644 --- a/lighthouse-plugin-publisher-ads/audits/first-ad-paint.js +++ b/lighthouse-plugin-publisher-ads/audits/first-ad-paint.js @@ -16,6 +16,7 @@ const AdPaintTime = require('../computed/ad-paint-time'); const i18n = require('lighthouse/lighthouse-core/lib/i18n/i18n'); const {auditNotApplicable, runWarning} = require('../messages/common-strings'); const {Audit} = require('lighthouse'); +const {isAdIframe, isGptIframe} = require('../utils/resource-classification'); const UIStrings = { title: 'Latency of first ad render', @@ -71,7 +72,12 @@ class FirstAdPaint extends Audit { const {timing} = await AdPaintTime.request(metricData, context); if (!(timing > 0)) { // Handle NaN, etc. - context.LighthouseRunWarnings.push(runWarning.NoAdRendered); + // Currently only GPT ads are supported by this audit. + const nonGptAdSlots = artifacts.IFrameElements.filter( + (iframe) => isAdIframe(iframe) && !isGptIframe(iframe)); + if (nonGptAdSlots.length === 0) { + context.LighthouseRunWarnings.push(runWarning.NoAdRendered); + } return auditNotApplicable.NoAdRendered; } diff --git a/lighthouse-plugin-publisher-ads/audits/full-width-slots.js b/lighthouse-plugin-publisher-ads/audits/full-width-slots.js index 5eaff5d1..99da91c0 100644 --- a/lighthouse-plugin-publisher-ads/audits/full-width-slots.js +++ b/lighthouse-plugin-publisher-ads/audits/full-width-slots.js @@ -16,7 +16,7 @@ const i18n = require('lighthouse/lighthouse-core/lib/i18n/i18n'); const NetworkRecords = require('lighthouse/lighthouse-core/computed/network-records'); const {auditNotApplicable} = require('../messages/common-strings'); const {Audit} = require('lighthouse'); -const {isGptAdRequest} = require('../utils/resource-classification'); +const {isAdRequest} = require('../utils/resource-classification'); const {URL} = require('url'); const UIStrings = { @@ -61,7 +61,7 @@ class FullWidthSlots extends Audit { /** @type {Array} */ const adRequestUrls = networkRecords - .filter(isGptAdRequest) + .filter(isAdRequest) .map((record) => new URL(record.url)); if (!adRequestUrls.length) { diff --git a/lighthouse-plugin-publisher-ads/audits/gpt-bids-parallel.js b/lighthouse-plugin-publisher-ads/audits/gpt-bids-parallel.js index 0b2777ad..f7b87797 100644 --- a/lighthouse-plugin-publisher-ads/audits/gpt-bids-parallel.js +++ b/lighthouse-plugin-publisher-ads/audits/gpt-bids-parallel.js @@ -18,7 +18,7 @@ const {auditNotApplicable} = require('../messages/common-strings'); const {Audit} = require('lighthouse'); const {getCriticalGraph} = require('../utils/graph'); const {getTimingsByRecord} = require('../utils/network-timing'); -const {isImplTag, isBidRequest, getAbbreviatedUrl, getHeaderBidder} = require('../utils/resource-classification'); +const {isGptImplTag, isBidRequest, getAbbreviatedUrl, getHeaderBidder} = require('../utils/resource-classification'); /** @typedef {LH.Artifacts.NetworkRequest} NetworkRequest */ /** @typedef {LH.Gatherer.Simulation.NodeTiming} NodeTiming */ @@ -73,9 +73,9 @@ class GptBidsInParallel extends Audit { const trace = artifacts.traces[Audit.DEFAULT_PASS]; const network = await NetworkRecords.request(devtoolsLog, context); - const pubadsImpl = network.find((r) => isImplTag(r.url)); + const pubadsImpl = network.find((r) => isGptImplTag(r.url)); if (!pubadsImpl) { - return auditNotApplicable.NoTag; + return auditNotApplicable.NoGpt; } const bids = network.filter(isBidRequest) @@ -118,3 +118,4 @@ class GptBidsInParallel extends Audit { } module.exports = GptBidsInParallel; +module.exports.UIStrings = UIStrings; diff --git a/lighthouse-plugin-publisher-ads/audits/loads-gpt-over-https.js b/lighthouse-plugin-publisher-ads/audits/loads-ad-tag-over-https.js similarity index 60% rename from lighthouse-plugin-publisher-ads/audits/loads-gpt-over-https.js rename to lighthouse-plugin-publisher-ads/audits/loads-ad-tag-over-https.js index 74408cae..ad3005e7 100644 --- a/lighthouse-plugin-publisher-ads/audits/loads-gpt-over-https.js +++ b/lighthouse-plugin-publisher-ads/audits/loads-ad-tag-over-https.js @@ -17,37 +17,40 @@ const NetworkRecords = require('lighthouse/lighthouse-core/computed/network-reco const util = require('util'); const {auditNotApplicable} = require('../messages/common-strings'); const {Audit} = require('lighthouse'); -const {isGptTag} = require('../utils/resource-classification'); +const {isAdTag} = require('../utils/resource-classification'); const {URL} = require('url'); const UIStrings = { - title: 'GPT tag is loaded over HTTPS', - failureTitle: 'Load GPT over HTTPS', - description: 'For privacy and security, always load GPT over HTTPS. ' + - 'Insecure pages should explicitly request the GPT script securely. Example:' + - '`