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

Sometimes err.url is undefined. so It must has protect code. #893

Merged
merged 3 commits into from
Nov 4, 2016

Conversation

mixed
Copy link
Contributor

@mixed mixed commented Nov 2, 2016

When I ran lighthouse-cli from https://www.inflearn.com/. I found error. Sometimes err.url is undefined. so It must has protect code.

node lighthouse-cli --config-path=lighthouse-core/config/dobetterweb.json  https://www.inflearn.com/

@ebidel
Copy link
Contributor

ebidel commented Nov 2, 2016

@@ -57,7 +57,7 @@ class NoDateNowAudit extends Audit {
const pageHost = url.parse(artifacts.URL.finalUrl).host;
// Filter usage from other hosts.
const results = artifacts.DateNowUse.usage.filter(err => {
return url.parse(err.url).host === pageHost;
return url.parse(err.url || '').host === pageHost;
Copy link
Contributor

@ebidel ebidel Nov 2, 2016

Choose a reason for hiding this comment

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

For stacktraces that are missing .url, what do you think about over communicating and reporting those cases as if they were same-domain violations (since we don't know the url)? In other words:

return err.url ? url.parse(err.url).host === pageHost : true;

Copy link
Contributor Author

@mixed mixed Nov 2, 2016

Choose a reason for hiding this comment

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

@ebidel
The displayed that url was undefined like below image. What do you think about display? I think that - is more good than undefined. either (empty) is good.

image
->
image
,
image

Copy link
Contributor

@ebidel ebidel Nov 2, 2016

Choose a reason for hiding this comment

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

Agreed. Line/col number without an URL makes them less useful, so let's keep what you have then (err.url || ''). It looks like it finds all the violations on www.inflearn.com just fine :)

screen shot 2016-11-02 at 10 51 54 am

@@ -48,4 +48,14 @@ describe('Page does not use mutation events', () => {
assert.equal(auditResult.rawValue, false);
assert.equal(auditResult.extendedInfo.value.length, 3);
});

it('fails when listener hasn`t url', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

fails when listener is missing a url property

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DONE!

@@ -69,4 +69,14 @@ describe('Page uses passive events listeners where applicable', () => {
assert.equal(auditResult.rawValue, true);
assert.equal(auditResult.extendedInfo.value.length, 0);
});

it('fails when listener hasn`t url', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

fails when listener is missing a url property

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DONE!

@@ -66,4 +66,21 @@ describe('Page does not use Date.now()', () => {
assert.equal(auditResult.rawValue, false);
assert.equal(auditResult.extendedInfo.value.length, 2);
});

it('fails when usage hasn`t url', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe "only passes when has url property"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DONE!


assert.equal(auditResult.rawValue, false);
assert.ok(auditResult.extendedInfo.value[0].url === '');
assert.equal(auditResult.extendedInfo.value.length, 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check that extendedInfo.value has a url and is what you expect? From the first assert, it looks like extendedInfo.value will be the first to values in DateNowUse.usage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ebidel
Thank you. I have misunderstood spec. 😭

@ebidel ebidel merged commit ddcbe3a into GoogleChrome:master Nov 4, 2016
andrewrota pushed a commit to andrewrota/lighthouse that referenced this pull request Jan 13, 2017
…hrome#893)

* Sometimes err.url is undefined. so It must has protect code.

* apply reviews

* apply review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants