Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude artifacts from result handed to extension/devtools. #1400

Merged
merged 2 commits into from
Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lighthouse-core/report/report-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

const Formatter = require('../formatters/formatter');
const Handlebars = require('handlebars');
const stringify = require('json-stringify-safe');
const fs = require('fs');
const path = require('path');
const marked = require('marked');
Expand Down Expand Up @@ -251,7 +252,7 @@ class ReportGenerator {
errMessage: err.message,
errStack: err.stack,
css: this.getReportCSS(),
results: JSON.stringify(results, null, 2)
results: stringify(results, null, 2)
});
}

Expand Down
21 changes: 21 additions & 0 deletions lighthouse-extension/app/src/lighthouse-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const _flatten = arr => [].concat(...arr);

let lighthouseIsRunning = false;
let latestStatusLog = [];
let latestArtifacts = undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the lifecycle for this like for devtools and the extension? Is memory eventually cleared? The artifacts can be really big

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unknown. :)
I'll nuke it until we have an immediate need for it.


/**
* Filter out any unrequested aggregations from the config. If any audits are
Expand Down Expand Up @@ -95,6 +96,17 @@ function updateBadgeUI(optUrl) {
}
}

/**
* Removes artifacts from the result object for portability
* @param {!Object} results Lighthouse results object
*/
function filterOutArtifacts(result) {
// save artifacts in case the viewer will want them later.
latestArtifacts = result.artifacts;
// strip them out, as the networkRecords artifact has circular structures
result.artifacts = undefined;
}

/**
* @param {!Connection} connection
* @param {string} url
Expand All @@ -120,6 +132,7 @@ window.runLighthouseForConnection = function(connection, url, options, requested
.then(result => {
lighthouseIsRunning = false;
updateBadgeUI();
filterOutArtifacts(result);
return result;
})
.catch(err => {
Expand Down Expand Up @@ -172,6 +185,7 @@ window.createReportPageAsBlob = function(results, reportContext) {
let html;
try {
html = reportGenerator.generateHTML(results, reportContext);
throw new Error('sdlfjksdf');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm...

} catch (err) {
html = reportGenerator.renderException(err, results);
}
Expand All @@ -183,6 +197,13 @@ window.createReportPageAsBlob = function(results, reportContext) {
return blobURL;
};

/**
* Returns full artifacts object from latest run
*/
window.getLatestArtifacts = function() {
return latestArtifacts;
};

/**
* Returns list of aggregation categories (each with a list of its constituent
* audits) from the default config.
Expand Down