From 8c1d74e734a73c38dd1e60210c2df7eb1f58704e Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Wed, 27 Jun 2018 09:18:44 -0700 Subject: [PATCH] core(without-javascript): allow noscript pages --- lighthouse-core/audits/without-javascript.js | 3 ++- .../gatherers/html-without-javascript.js | 11 +++++++--- .../test/audits/without-javascript-test.js | 20 ++++++++++++++++--- .../gatherers/html-without-javascript-test.js | 9 +++++---- typings/artifacts.d.ts | 2 +- 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/lighthouse-core/audits/without-javascript.js b/lighthouse-core/audits/without-javascript.js index bfa3a1df9124..92bd88b6b1a7 100644 --- a/lighthouse-core/audits/without-javascript.js +++ b/lighthouse-core/audits/without-javascript.js @@ -30,7 +30,8 @@ class WithoutJavaScript extends Audit { static audit(artifacts) { const artifact = artifacts.HTMLWithoutJavaScript; - if (artifact.value.trim() === '') { + // Fail pages that have empty text and are missing a noscript tag + if (artifact.bodyText.trim() === '' && !artifact.hasNoScript) { return { rawValue: false, explanation: 'The page body should render some content if its scripts are not available.', diff --git a/lighthouse-core/gather/gatherers/html-without-javascript.js b/lighthouse-core/gather/gatherers/html-without-javascript.js index d878f7068933..7cdf7fb27c3a 100644 --- a/lighthouse-core/gather/gatherers/html-without-javascript.js +++ b/lighthouse-core/gather/gatherers/html-without-javascript.js @@ -18,7 +18,10 @@ const Gatherer = require('./gatherer'); function getBodyText() { // note: we use innerText, not textContent, because textContent includes the content of