Created
October 29, 2018 09:23
-
-
Save kahunacohen/a623d4597f2d60a7ce905d7cc506b93d to your computer and use it in GitHub Desktop.
NCBI-written gatherer for ncbi_app meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const Gatherer = require("lighthouse").Gatherer; | |
/** | |
* @fileoverview Extracts `window.myLoadMetrics` from the test page. | |
*/ | |
class NCBIAppMeta extends Gatherer { | |
async afterPass(options) { | |
const driver = options.driver; | |
const expression = `(function() { | |
var meta = document.querySelector("meta[name=ncbi_app]"); | |
ret = {name: false, content: false}; | |
var content; | |
if (meta) { | |
content = meta.getAttribute("content"); | |
ret.name = true; | |
ret.content = content && content.length > 3; | |
} | |
return ret; | |
})()`; | |
return await driver.evaluateAsync(expression); | |
} | |
} | |
module.exports = NCBIAppMeta; |
OK I kind of figured. Thanks for taking a look!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In general we try to write gatherers to just get the information and not pass the judgement yet, so for example this might return the content attribute value or
null
if it didn't exist and then the audit would check that it's length is> 3
. If you think it's unlikely the test will ever change, this works too.