fix(aio): fix PWA testing in cases where `atob`/`btoa` is necessary

In some cases (unclear when), traceviewer-js, used by Lighthouse under the hood,
assumes `atob`/`btoa` are defined in the global scope. This is true for browser
environments, but not on node.

As a result, some aggregations that required access to model-tracing failed to
produce results, dropping the overall PWA score.

This affected #16665 (e.g. commit 0de6eec7a).
This commit is contained in:
Georgios Kalpakas 2017-05-15 15:36:48 +03:00 committed by Pete Bacon Darwin
parent baa3fbab46
commit b40aae54b7
1 changed files with 4 additions and 0 deletions

View File

@ -20,6 +20,10 @@ const config = require('lighthouse/lighthouse-core/config/default.json');
// Constants
const FLAGS = {output: 'json'};
// Work-around traceviewer-js bug.
global.atob = str => new Buffer(str, 'base64').toString('binary');
global.btoa = str => new Buffer(str, 'binary').toString('base64');
// Specify the path to Chrome on Travis
if (process.env.TRAVIS) {
process.env.LIGHTHOUSE_CHROMIUM_PATH = process.env.CHROME_BIN;