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

Fix some cross-browser compatibility issues #1593

Merged
merged 3 commits into from
Feb 2, 2017

Conversation

weiwei-lin
Copy link
Contributor

In interactive mode, the report page will be opened in the default browser. However, the interactive mode report page only works in Chrome currently.
This PR adds support for Safari and Firefox.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@googlebot
Copy link

CLAs look good, thanks!

@@ -31,7 +31,8 @@ class ConfigPanel {
this._messageField = this._configPanel.querySelector('.js-message');
this._urlBlockingList = this._configPanel.querySelector('.js-url-blocking-patterns');
this._urlBlockingStatus = {};
this._reportId = new URL(window.location).searchParams.get('id');
const match = location.search.match(/[?&]id=([^&]*)/);
Copy link
Contributor

Choose a reason for hiding this comment

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

I use a polyfill in Viewer for URLSearchParams: https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-viewer/package.json#L33

Could you use that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for your advice. Shall I move the dependencies from viewer to core? Or just add some dependencies to cli?

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to keep the deps for the viewer since it's a separate app.

Since you've already done the work of moving over to the fallbacks, there's not a lot of benefit to adding polyfills for two small APIs. I'm fine with what you've got.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:)

Copy link
Member

Choose a reason for hiding this comment

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

can you add a comment here? // Compat: URL.searchParams isn't yet supported by _______
so later when that browser updates we'll know when we can remove it

@@ -83,15 +84,6 @@ class ConfigPanel {
}
});
});

// get and recover blocked URL patterns of current run
fetch(`/flags?id=${this._reportId}`).then(response => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

But Safari 10.1 also has fetch(). A polyfill might not be worth it.

Copy link
Member

Choose a reason for hiding this comment

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

lets not polyfill fetch()

.catch(err => this.log(`Lighthouse Runtime Error: ${err}`));
const xhr = new XMLHttpRequest();
xhr.open('POST', `/rerun?id=${this._reportId}`, true);
xhr.onreadystatechange = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

just use xhr.onload, then you don't need to both with readyState checking.

Copy link
Contributor

@ebidel ebidel left a comment

Choose a reason for hiding this comment

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

LGTM from me

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

lgtm % compat comment

@@ -31,7 +31,8 @@ class ConfigPanel {
this._messageField = this._configPanel.querySelector('.js-message');
this._urlBlockingList = this._configPanel.querySelector('.js-url-blocking-patterns');
this._urlBlockingStatus = {};
this._reportId = new URL(window.location).searchParams.get('id');
const match = location.search.match(/[?&]id=([^&]*)/);
Copy link
Member

Choose a reason for hiding this comment

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

can you add a comment here? // Compat: URL.searchParams isn't yet supported by _______
so later when that browser updates we'll know when we can remove it

@paulirish paulirish merged commit 4a63f3c into GoogleChrome:master Feb 2, 2017
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

4 participants