{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments/83768190","pull_request_review_id":4587838,"id":83768190,"diff_hunk":"@@ -213,6 +221,75 @@ class Driver {\n     });\n   }\n \n+  getServiceWorkerRegistrations() {\n+    return new Promise(resolve => {\n+      this.once('ServiceWorker.workerRegistrationUpdated', data => {\n+        this.sendCommand('ServiceWorker.disable');\n+        resolve(data);\n+      });\n+\n+      this.sendCommand('ServiceWorker.enable');\n+    });\n+  }\n+\n+  /**\n+   * Checks all service workers and see if any duplications are running\n+   * @param {!string} pageUrl\n+   * @return {!Promise}\n+   */\n+  checkForMultipleTabsAttached(pageUrl) {\n+    // Get necessary information of serviceWorkers\n+    const getRegistrations = this.getServiceWorkerRegistrations();\n+    const getVersions = this.getServiceWorkerVersions();\n+    const getActiveTabId = this.getCurrentTabId();\n+\n+    return Promise.all([getRegistrations, getVersions, getActiveTabId]).then(res => {\n+      const registrations = res[0].registrations;\n+      const versions = res[1].versions;\n+      const activeTabId = res[2];\n+      const parsedURL = parseURL(pageUrl);\n+      const origin = `${parsedURL.protocol}//${parsedURL.hostname}` +\n+      (parsedURL.port ? `:${parsedURL.port}` : '');\n+\n+      let swHasMoreThanOneClient = false;\n+      registrations\n+        .filter(reg => {\n+          const parsedURL = parseURL(reg.scopeURL);\n+          const swOrigin = `${parsedURL.protocol}//${parsedURL.hostname}` +\n+            (parsedURL.port ? `:${parsedURL.port}` : '');\n+\n+          return origin === swOrigin;\n+        })\n+        .forEach(reg => {\n+          // Check if any of the service workers are the same (registration id)\n+          // Check if the controlledClients are bigger than 1 and it's not the active tab\n+          swHasMoreThanOneClient = !!versions.find(ver => {\n+            if (ver.registrationId !== reg.registrationId) {\n+              return false;\n+            }\n+\n+            if (!ver.controlledClients || ver.controlledClients.length === 0) {\n+              return false;\n+            }\n+\n+            const multipleTabsAttached = ver.controlledClients.length > 1;\n+            const oneInactiveTabIsAttached = ver.controlledClients.length === 1 &&\n+              !ver.controlledClients.find(client => client === activeTabId);","path":"lighthouse-core/gather/drivers/driver.js","position":72,"original_position":72,"commit_id":"acc3c4f089e4e03b0c4d5c1a167fc7788d7be3bf","original_commit_id":"acc3c4f089e4e03b0c4d5c1a167fc7788d7be3bf","user":{"login":"brendankenny","id":316891,"avatar_url":"https://avatars.githubusercontent.com/u/316891?v=3","gravatar_id":"","url":"https://api.github.com/users/brendankenny","html_url":"https://github.com/brendankenny","followers_url":"https://api.github.com/users/brendankenny/followers","following_url":"https://api.github.com/users/brendankenny/following{/other_user}","gists_url":"https://api.github.com/users/brendankenny/gists{/gist_id}","starred_url":"https://api.github.com/users/brendankenny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendankenny/subscriptions","organizations_url":"https://api.github.com/users/brendankenny/orgs","repos_url":"https://api.github.com/users/brendankenny/repos","events_url":"https://api.github.com/users/brendankenny/events{/privacy}","received_events_url":"https://api.github.com/users/brendankenny/received_events","type":"User","site_admin":false},"body":"nit: since you know it's length 1, clearer to just write this line as `ver.controlledClients[0] !== activeTabId;`?","created_at":"2016-10-18T01:34:47Z","updated_at":"2016-10-18T01:39:07Z","html_url":"https://github.com/GoogleChrome/lighthouse/pull/639#discussion_r83768190","pull_request_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/639","_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments/83768190"},"html":{"href":"https://github.com/GoogleChrome/lighthouse/pull/639#discussion_r83768190"},"pull_request":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/639"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/639","id":84538408,"html_url":"https://github.com/GoogleChrome/lighthouse/pull/639","diff_url":"https://github.com/GoogleChrome/lighthouse/pull/639.diff","patch_url":"https://github.com/GoogleChrome/lighthouse/pull/639.patch","issue_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/639","number":639,"state":"open","locked":false,"title":"Stop the trace when multiple tabs are found.","user":{"login":"wardpeet","id":1120926,"avatar_url":"https://avatars.githubusercontent.com/u/1120926?v=3","gravatar_id":"","url":"https://api.github.com/users/wardpeet","html_url":"https://github.com/wardpeet","followers_url":"https://api.github.com/users/wardpeet/followers","following_url":"https://api.github.com/users/wardpeet/following{/other_user}","gists_url":"https://api.github.com/users/wardpeet/gists{/gist_id}","starred_url":"https://api.github.com/users/wardpeet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wardpeet/subscriptions","organizations_url":"https://api.github.com/users/wardpeet/orgs","repos_url":"https://api.github.com/users/wardpeet/repos","events_url":"https://api.github.com/users/wardpeet/events{/privacy}","received_events_url":"https://api.github.com/users/wardpeet/received_events","type":"User","site_admin":false},"body":"Fixes #601 \r\nI check if multiple service workers got found and it throws an error. I check in the cli and the extension on this error and show the a good message.","created_at":"2016-09-08T19:26:34Z","updated_at":"2016-10-18T01:39:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2f3993b3c8a6466f703e3d1875f22597461b1a7f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/639/commits","review_comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/639/comments","review_comment_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/639/comments","statuses_url":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/acc3c4f089e4e03b0c4d5c1a167fc7788d7be3bf","head":{"label":"wardpeet:sw/warn-tabs","ref":"sw/warn-tabs","sha":"acc3c4f089e4e03b0c4d5c1a167fc7788d7be3bf","user":{"login":"wardpeet","id":1120926,"avatar_url":"https://avatars.githubusercontent.com/u/1120926?v=3","gravatar_id":"","url":"https://api.github.com/users/wardpeet","html_url":"https://github.com/wardpeet","followers_url":"https://api.github.com/users/wardpeet/followers","following_url":"https://api.github.com/users/wardpeet/following{/other_user}","gists_url":"https://api.github.com/users/wardpeet/gists{/gist_id}","starred_url":"https://api.github.com/users/wardpeet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wardpeet/subscriptions","organizations_url":"https://api.github.com/users/wardpeet/orgs","repos_url":"https://api.github.com/users/wardpeet/repos","events_url":"https://api.github.com/users/wardpeet/events{/privacy}","received_events_url":"https://api.github.com/users/wardpeet/received_events","type":"User","site_admin":false},"repo":{"id":59512656,"name":"lighthouse","full_name":"wardpeet/lighthouse","owner":{"login":"wardpeet","id":1120926,"avatar_url":"https://avatars.githubusercontent.com/u/1120926?v=3","gravatar_id":"","url":"https://api.github.com/users/wardpeet","html_url":"https://github.com/wardpeet","followers_url":"https://api.github.com/users/wardpeet/followers","following_url":"https://api.github.com/users/wardpeet/following{/other_user}","gists_url":"https://api.github.com/users/wardpeet/gists{/gist_id}","starred_url":"https://api.github.com/users/wardpeet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wardpeet/subscriptions","organizations_url":"https://api.github.com/users/wardpeet/orgs","repos_url":"https://api.github.com/users/wardpeet/repos","events_url":"https://api.github.com/users/wardpeet/events{/privacy}","received_events_url":"https://api.github.com/users/wardpeet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wardpeet/lighthouse","description":"auditing and performance metrics for Progressive Web Apps","fork":true,"url":"https://api.github.com/repos/wardpeet/lighthouse","forks_url":"https://api.github.com/repos/wardpeet/lighthouse/forks","keys_url":"https://api.github.com/repos/wardpeet/lighthouse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wardpeet/lighthouse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wardpeet/lighthouse/teams","hooks_url":"https://api.github.com/repos/wardpeet/lighthouse/hooks","issue_events_url":"https://api.github.com/repos/wardpeet/lighthouse/issues/events{/number}","events_url":"https://api.github.com/repos/wardpeet/lighthouse/events","assignees_url":"https://api.github.com/repos/wardpeet/lighthouse/assignees{/user}","branches_url":"https://api.github.com/repos/wardpeet/lighthouse/branches{/branch}","tags_url":"https://api.github.com/repos/wardpeet/lighthouse/tags","blobs_url":"https://api.github.com/repos/wardpeet/lighthouse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wardpeet/lighthouse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wardpeet/lighthouse/git/refs{/sha}","trees_url":"https://api.github.com/repos/wardpeet/lighthouse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wardpeet/lighthouse/statuses/{sha}","languages_url":"https://api.github.com/repos/wardpeet/lighthouse/languages","stargazers_url":"https://api.github.com/repos/wardpeet/lighthouse/stargazers","contributors_url":"https://api.github.com/repos/wardpeet/lighthouse/contributors","subscribers_url":"https://api.github.com/repos/wardpeet/lighthouse/subscribers","subscription_url":"https://api.github.com/repos/wardpeet/lighthouse/subscription","commits_url":"https://api.github.com/repos/wardpeet/lighthouse/commits{/sha}","git_commits_url":"https://api.github.com/repos/wardpeet/lighthouse/git/commits{/sha}","comments_url":"https://api.github.com/repos/wardpeet/lighthouse/comments{/number}","issue_comment_url":"https://api.github.com/repos/wardpeet/lighthouse/issues/comments{/number}","contents_url":"https://api.github.com/repos/wardpeet/lighthouse/contents/{+path}","compare_url":"https://api.github.com/repos/wardpeet/lighthouse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wardpeet/lighthouse/merges","archive_url":"https://api.github.com/repos/wardpeet/lighthouse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wardpeet/lighthouse/downloads","issues_url":"https://api.github.com/repos/wardpeet/lighthouse/issues{/number}","pulls_url":"https://api.github.com/repos/wardpeet/lighthouse/pulls{/number}","milestones_url":"https://api.github.com/repos/wardpeet/lighthouse/milestones{/number}","notifications_url":"https://api.github.com/repos/wardpeet/lighthouse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wardpeet/lighthouse/labels{/name}","releases_url":"https://api.github.com/repos/wardpeet/lighthouse/releases{/id}","deployments_url":"https://api.github.com/repos/wardpeet/lighthouse/deployments","created_at":"2016-05-23T19:33:12Z","updated_at":"2016-05-23T19:33:13Z","pushed_at":"2016-10-16T13:01:44Z","git_url":"git://github.com/wardpeet/lighthouse.git","ssh_url":"git@github.com:wardpeet/lighthouse.git","clone_url":"https://github.com/wardpeet/lighthouse.git","svn_url":"https://github.com/wardpeet/lighthouse","homepage":"","size":8054,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleChrome:master","ref":"master","sha":"48331db2e6ec1a22719cd98a304e12f8d96174ad","user":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"repo":{"id":53370988,"name":"lighthouse","full_name":"GoogleChrome/lighthouse","owner":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars.githubusercontent.com/u/1778935?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleChrome/lighthouse","description":"auditing and performance metrics for Progressive Web Apps","fork":false,"url":"https://api.github.com/repos/GoogleChrome/lighthouse","forks_url":"https://api.github.com/repos/GoogleChrome/lighthouse/forks","keys_url":"https://api.github.com/repos/GoogleChrome/lighthouse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleChrome/lighthouse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleChrome/lighthouse/teams","hooks_url":"https://api.github.com/repos/GoogleChrome/lighthouse/hooks","issue_events_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleChrome/lighthouse/events","assignees_url":"https://api.github.com/repos/GoogleChrome/lighthouse/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleChrome/lighthouse/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleChrome/lighthouse/tags","blobs_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleChrome/lighthouse/languages","stargazers_url":"https://api.github.com/repos/GoogleChrome/lighthouse/stargazers","contributors_url":"https://api.github.com/repos/GoogleChrome/lighthouse/contributors","subscribers_url":"https://api.github.com/repos/GoogleChrome/lighthouse/subscribers","subscription_url":"https://api.github.com/repos/GoogleChrome/lighthouse/subscription","commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleChrome/lighthouse/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleChrome/lighthouse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleChrome/lighthouse/merges","archive_url":"https://api.github.com/repos/GoogleChrome/lighthouse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleChrome/lighthouse/downloads","issues_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleChrome/lighthouse/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleChrome/lighthouse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleChrome/lighthouse/labels{/name}","releases_url":"https://api.github.com/repos/GoogleChrome/lighthouse/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/deployments","created_at":"2016-03-08T01:03:11Z","updated_at":"2016-10-18T00:21:08Z","pushed_at":"2016-10-17T15:33:30Z","git_url":"git://github.com/GoogleChrome/lighthouse.git","ssh_url":"git@github.com:GoogleChrome/lighthouse.git","clone_url":"https://github.com/GoogleChrome/lighthouse.git","svn_url":"https://github.com/GoogleChrome/lighthouse","homepage":"","size":10210,"stargazers_count":2673,"watchers_count":2673,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":110,"mirror_url":null,"open_issues_count":92,"forks":110,"open_issues":92,"watchers":2673,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/639"},"html":{"href":"https://github.com/GoogleChrome/lighthouse/pull/639"},"issue":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/639"},"comments":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/639/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/639/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/639/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/acc3c4f089e4e03b0c4d5c1a167fc7788d7be3bf"}}}}
{"actor":{"display_login":"brendankenny"}}