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

misc(proto): make NO_ERROR default in proto #6358

Merged
merged 5 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
5 changes: 5 additions & 0 deletions lighthouse-core/lib/proto-preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ function processForProto(result) {
}
}

// Remove runtimeError if it is NO_ERROR
if (reportJson.runtimeError && reportJson.runtimeError.code === 'NO_ERROR') {
delete reportJson.runtimeError;
}

// Clean up actions that require 'audits' to exist
if (reportJson.audits) {
Object.keys(reportJson.audits).forEach(auditName => {
Expand Down
24 changes: 24 additions & 0 deletions lighthouse-core/test/lib/proto-preprocessor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ describe('processing for proto', () => {
expect(JSON.parse(output)).toMatchObject(expectation);
});

it('cleans up default runtimeErrors', () => {
const input = {
'runtimeError': {
'code': 'NO_ERROR',
},
};

const output = processForProto(JSON.stringify(input));

expect({}).toMatchObject(JSON.parse(output));
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
});

it('ignores non-default runtimeErrors', () => {
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
const input = {
'runtimeError': {
'code': 'ERROR_NO_DOCUMENT_REQUEST',
},
};

const output = processForProto(JSON.stringify(input));

expect(JSON.parse(output)).toMatchObject(input);
});

it('cleans up audits', () => {
const input = {
'audits': {
Expand Down
33 changes: 16 additions & 17 deletions proto/lighthouse-result.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,41 @@ import "google/protobuf/wrappers.proto";

// Canonical list of errors created by Lighthouse.
enum LighthouseError {
UNDEFINED = 0;
// No error in Lighthouse; the results are reliable.
NO_ERROR = 1;
NO_ERROR = 0;
exterkamp marked this conversation as resolved.
Show resolved Hide resolved
// An uncategorized error occurred, likely a JavaScript exception.
UNKNOWN_ERROR = 2;
UNKNOWN_ERROR = 1;
// The trace did not contain any screenshot events.
NO_SPEEDLINE_FRAMES = 3;
NO_SPEEDLINE_FRAMES = 2;
// No visual change between the beginning and end of load.
SPEEDINDEX_OF_ZERO = 4;
SPEEDINDEX_OF_ZERO = 3;
// The trace did not contain any screenshot events.
NO_SCREENSHOTS = 5;
NO_SCREENSHOTS = 4;
// The computed speedindex results are non-finite.
INVALID_SPEEDLINE = 6;
INVALID_SPEEDLINE = 5;
// The trace did not contain a TracingStartedInPage event.
NO_TRACING_STARTED = 7;
NO_TRACING_STARTED = 6;
// The trace did not contain a navigationStart event.
NO_NAVSTART = 8;
NO_NAVSTART = 7;
// The trace did not contain a firstContentfulPaint event.
NO_FCP = 9;
NO_FCP = 8;
// The trace did not contain a domContentLoaded event.
NO_DCL = 10;
NO_DCL = 9;
// No network request could be identified as the primary HTML document.
NO_DOCUMENT_REQUEST = 11;
NO_DOCUMENT_REQUEST = 10;
// The HTML document's network request failed due to Chrome-internal reasons
// (canceled, blocked, etc).
FAILED_DOCUMENT_REQUEST = 12;
FAILED_DOCUMENT_REQUEST = 11;
// The HTML document's network request completed, but returned an HTTP status
// code of 4xx or 5xx.
ERRORED_DOCUMENT_REQUEST = 13;
ERRORED_DOCUMENT_REQUEST = 12;
// Chromium's tracing controller did not manage to begin tracing across
// processes. Typically fixed by restarting Chromium.
TRACING_ALREADY_STARTED = 14;
TRACING_ALREADY_STARTED = 13;
// The trace data wasn't parsed correctly.
PARSING_PROBLEM = 15;
PARSING_PROBLEM = 14;
// The trace data failed to stream over the protocol.
READ_FAILED = 16;
READ_FAILED = 15;
}

// The overarching Lighthouse Response object (LHR)
Expand Down
3 changes: 0 additions & 3 deletions proto/sample_v2_round_trip.json
Original file line number Diff line number Diff line change
Expand Up @@ -3291,8 +3291,5 @@
"lighthouseVersion": "3.2.0",
"requestedUrl": "http://localhost:10200/dobetterweb/dbw_tester.html",
"runWarnings": [],
"runtimeError": {
"code": "NO_ERROR"
},
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3358.0 Safari/537.36"
}