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

remove tab targetId dependency from multiple tab check #852

Merged
merged 1 commit into from
Oct 31, 2016
Merged

Conversation

brendankenny
Copy link
Member

Followup to #639. Unfortunately we don't necessarily have a tab ID (particularly in the case of the raw connection where Lighthouse doesn't establish the debugger connection), so we can't use the id to check against controlledClients of any active service workers.

However, with the change to first navigate to about:blank in #850, we know the current tab can't be controlled by a service worker for the target URL, so we can simplify the multiple tab check to just find any service worker for the target URL with any controlled clients at all.

@@ -229,7 +229,7 @@ function handleError(err: LightHouseError) {
if (err.code === 'ECONNREFUSED') {
showConnectionError();
} else if (err.message.toLowerCase().includes('multiple tabs')) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

no need for these 2 lines anymore :) it will just go inside the else. (thanks for cleaning up)

Copy link
Member Author

@brendankenny brendankenny Oct 31, 2016

Choose a reason for hiding this comment

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

good call. Just needed the process.exit(_RUNTIME_ERROR_CODE) when it fails on that, didn't notice it was the same thing now.

But yeah, sorry I didn't realize that raw.js wouldn't work with what you were up to in #639. We could have made that PR go on even longer :) Does the simplified checkForMultipleTabsAttachedhere seem like it will still work now that we go to about:blank before starting? Testing it with multiple tabs in the CLI/extension seems OK.

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.

only nits. lgtm

swHasMoreThanOneClient = !!versions.find(ver => {
// Check if any of the service workers are the same (registration id)
versions.forEach(ver => {
// Ignore non-matching service worker version information.
Copy link
Member

Choose a reason for hiding this comment

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

"Ignore workers unaffiliated with this registration"

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -198,56 +190,44 @@ class Driver {

/**
* Rejects if any open tabs would share a service worker with the target URL.
* This includes the target tab, so navigation to something like about:blank
* should be done before calling.
* @param {!string} pageUrl
* @return {!Promise}
*/
checkForMultipleTabsAttached(pageUrl) {
Copy link
Member

Choose a reason for hiding this comment

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

name-wise this is not testing "multiple" anymore. wanna update?

Copy link
Member Author

Choose a reason for hiding this comment

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

assertNoSameOriginServiceWorkerClients()? :)

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

3 participants