-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
core: add top-level runtimeError #6014
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d5e4755
core: add top-level runtimeError
brendankenny 683a77c
use error code; wrap thrown errors in LR
brendankenny 76689df
pseudoLHR
brendankenny 91c171b
goldenLHR
brendankenny 8e228bd
add tests
brendankenny 09e5c20
unknownsss
brendankenny accc297
fix extension window export
brendankenny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
33 changes: 33 additions & 0 deletions
33
lighthouse-extension/test/app/src/lighthouse-ext-background-test.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* @license Copyright 2018 Google Inc. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const lhBackground = require('../../../app/src/lighthouse-ext-background.js'); | ||
const LHError = require('../../../../lighthouse-core/lib/lh-error.js'); | ||
|
||
/* eslint-env mocha */ | ||
|
||
describe('lighthouse-ext-background', () => { | ||
it('returns a runtimeError LHR when lighthouse run throws a runtimeError', async () => { | ||
const connectionError = new LHError(LHError.errors.FAILED_DOCUMENT_REQUEST); | ||
assert.strictEqual(connectionError.lhrRuntimeError, true); | ||
const mockConnection = { | ||
async connect() { | ||
throw connectionError; | ||
}, | ||
async disconnect() {}, | ||
async sendCommand() {}, | ||
on() {}, | ||
}; | ||
const url = 'https://example.com'; | ||
|
||
const result = await lhBackground.runLighthouseInLR(mockConnection, url, {output: 'json'}, {}); | ||
const parsedResult = JSON.parse(result); | ||
assert.strictEqual(parsedResult.runtimeError.code, connectionError.code); | ||
assert.ok(parsedResult.runtimeError.message.includes(connectionError.friendlyMessage)); | ||
}); | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this situation I think we should not throw but instead return an "UNKNOWN_ERROR" i guess.
tbh i dont know what throwing does in this context. my guess is its not caught and triggers a timeout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well it would throw and be up to the caller to deal with, but we can do
UNKNOWN_ERROR
instead :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done