{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments/84371781","pull_request_review_id":5154420,"id":84371781,"diff_hunk":"@@ -16,106 +16,77 @@\n  */\n 'use strict';\n \n-const Driver = require('./driver.js');\n-const chromeRemoteInterface = require('chrome-remote-interface');\n+const Connection = require('./connection.js');\n+const WebSocket = require('ws');\n+const http = require('http');\n const port = process.env.PORT || 9222;\n \n-const log = require('../../lib/log.js');\n-\n-class CriDriver extends Driver {\n-  constructor() {\n-    super();\n-\n-    /**\n-     * Chrome remote interface instance.\n-     */\n-    this._cri = null;\n-  }\n-\n+class CriConnection extends Connection {\n   /**\n-   * @return {!Promise<undefined>}\n+   * @override\n+   * @return {!Promise}\n    */\n   connect() {\n-    return new Promise((resolve, reject) => {\n-      if (this._cri) {\n-        return resolve();\n-      }\n-\n-      // Make a new tab, stopping Chrome from accidentally giving CRI an \"Other\" tab.\n-      // Also disable the lint check because CRI uses \"New\" for the function name.\n-      /* eslint-disable new-cap */\n-      chromeRemoteInterface.New((err, tab) => {\n-        if (err) {\n-          log.warn('CRI driver', 'cannot create new tab, will reuse tab.', err);\n-        }\n-\n-        chromeRemoteInterface({port: port, chooseTab: tab}, chrome => {\n-          this._tab = tab;\n-          this._cri = chrome;\n-          // The CRI instance is also an EventEmitter, so use directly for event dispatch.\n-          this._eventEmitter = chrome;\n-          this.enableRuntimeEvents().then(_ => {\n-            resolve();\n-          });\n-        }).on('error', e => reject(e));\n+    return this._runJsonCommand('new').then(response => {\n+      var url = response.webSocketDebuggerUrl;\n+      return new Promise((resolve, reject) => {\n+        var ws = new WebSocket(url);\n+        ws.on('open', () => {\n+          this._ws = ws;\n+          resolve();\n+        });\n+        ws.on('message', data => this.dispatchRawMessage(data));\n+        ws.on('close', this.dispose.bind(this));\n+        ws.on('error', reject);\n       });\n-      /* eslint-enable new-cap */\n     });\n   }\n \n-  disconnect() {\n+  /**\n+   * @return {!Promise<string>}\n+   */\n+  _runJsonCommand(command) {\n     return new Promise((resolve, reject) => {\n-      if (!this._tab) {\n-        this._cri.close();\n-        return resolve();\n-      }\n-\n-      /* eslint-disable new-cap */\n-      chromeRemoteInterface.Close({\n-        id: this._tab.id\n-      }, err => {\n-        if (err) {\n-          reject(err);\n-        } else {\n-          resolve();\n-        }\n+      http.get({\n+        hostname: 'localhost',","path":"lighthouse-core/gather/drivers/cri.js","position":89,"original_position":89,"commit_id":"9447ec1244f9f188b34b4c9a017a1458829ec8e9","original_commit_id":"9447ec1244f9f188b34b4c9a017a1458829ec8e9","user":{"login":"samccone","id":883126,"avatar_url":"https://avatars.githubusercontent.com/u/883126?v=3","gravatar_id":"","url":"https://api.github.com/users/samccone","html_url":"https://github.com/samccone","followers_url":"https://api.github.com/users/samccone/followers","following_url":"https://api.github.com/users/samccone/following{/other_user}","gists_url":"https://api.github.com/users/samccone/gists{/gist_id}","starred_url":"https://api.github.com/users/samccone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samccone/subscriptions","organizations_url":"https://api.github.com/users/samccone/orgs","repos_url":"https://api.github.com/users/samccone/repos","events_url":"https://api.github.com/users/samccone/events{/privacy}","received_events_url":"https://api.github.com/users/samccone/received_events","type":"User","site_admin":false},"body":"consider extracting localhost to a named module private const","created_at":"2016-10-20T20:43:07Z","updated_at":"2016-10-20T20:45:35Z","html_url":"https://github.com/GoogleChrome/lighthouse/pull/800#discussion_r84371781","pull_request_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/800","_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments/84371781"},"html":{"href":"https://github.com/GoogleChrome/lighthouse/pull/800#discussion_r84371781"},"pull_request":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/800"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/800","id":90109847,"html_url":"https://github.com/GoogleChrome/lighthouse/pull/800","diff_url":"https://github.com/GoogleChrome/lighthouse/pull/800.diff","patch_url":"https://github.com/GoogleChrome/lighthouse/pull/800.patch","issue_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/800","number":800,"state":"open","locked":false,"title":"Extract Connection delegate abstraction from driver.","user":{"login":"pavelfeldman","id":883973,"avatar_url":"https://avatars.githubusercontent.com/u/883973?v=3","gravatar_id":"","url":"https://api.github.com/users/pavelfeldman","html_url":"https://github.com/pavelfeldman","followers_url":"https://api.github.com/users/pavelfeldman/followers","following_url":"https://api.github.com/users/pavelfeldman/following{/other_user}","gists_url":"https://api.github.com/users/pavelfeldman/gists{/gist_id}","starred_url":"https://api.github.com/users/pavelfeldman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pavelfeldman/subscriptions","organizations_url":"https://api.github.com/users/pavelfeldman/orgs","repos_url":"https://api.github.com/users/pavelfeldman/repos","events_url":"https://api.github.com/users/pavelfeldman/events{/privacy}","received_events_url":"https://api.github.com/users/pavelfeldman/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-19T23:33:44Z","updated_at":"2016-10-20T20:45:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15bded5272cf7b3a15424c2b4b175a4aa199fca1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/800/commits","review_comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/800/comments","review_comment_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/800/comments","statuses_url":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/9447ec1244f9f188b34b4c9a017a1458829ec8e9","head":{"label":"pavelfeldman:connection_2","ref":"connection_2","sha":"9447ec1244f9f188b34b4c9a017a1458829ec8e9","user":{"login":"pavelfeldman","id":883973,"avatar_url":"https://avatars.githubusercontent.com/u/883973?v=3","gravatar_id":"","url":"https://api.github.com/users/pavelfeldman","html_url":"https://github.com/pavelfeldman","followers_url":"https://api.github.com/users/pavelfeldman/followers","following_url":"https://api.github.com/users/pavelfeldman/following{/other_user}","gists_url":"https://api.github.com/users/pavelfeldman/gists{/gist_id}","starred_url":"https://api.github.com/users/pavelfeldman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pavelfeldman/subscriptions","organizations_url":"https://api.github.com/users/pavelfeldman/orgs","repos_url":"https://api.github.com/users/pavelfeldman/repos","events_url":"https://api.github.com/users/pavelfeldman/events{/privacy}","received_events_url":"https://api.github.com/users/pavelfeldman/received_events","type":"User","site_admin":false},"repo":{"id":71307253,"name":"lighthouse","full_name":"pavelfeldman/lighthouse","owner":{"login":"pavelfeldman","id":883973,"avatar_url":"https://avatars.githubusercontent.com/u/883973?v=3","gravatar_id":"","url":"https://api.github.com/users/pavelfeldman","html_url":"https://github.com/pavelfeldman","followers_url":"https://api.github.com/users/pavelfeldman/followers","following_url":"https://api.github.com/users/pavelfeldman/following{/other_user}","gists_url":"https://api.github.com/users/pavelfeldman/gists{/gist_id}","starred_url":"https://api.github.com/users/pavelfeldman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pavelfeldman/subscriptions","organizations_url":"https://api.github.com/users/pavelfeldman/orgs","repos_url":"https://api.github.com/users/pavelfeldman/repos","events_url":"https://api.github.com/users/pavelfeldman/events{/privacy}","received_events_url":"https://api.github.com/users/pavelfeldman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pavelfeldman/lighthouse","description":"auditing and performance metrics for Progressive Web Apps","fork":true,"url":"https://api.github.com/repos/pavelfeldman/lighthouse","forks_url":"https://api.github.com/repos/pavelfeldman/lighthouse/forks","keys_url":"https://api.github.com/repos/pavelfeldman/lighthouse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pavelfeldman/lighthouse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pavelfeldman/lighthouse/teams","hooks_url":"https://api.github.com/repos/pavelfeldman/lighthouse/hooks","issue_events_url":"https://api.github.com/repos/pavelfeldman/lighthouse/issues/events{/number}","events_url":"https://api.github.com/repos/pavelfeldman/lighthouse/events","assignees_url":"https://api.github.com/repos/pavelfeldman/lighthouse/assignees{/user}","branches_url":"https://api.github.com/repos/pavelfeldman/lighthouse/branches{/branch}","tags_url":"https://api.github.com/repos/pavelfeldman/lighthouse/tags","blobs_url":"https://api.github.com/repos/pavelfeldman/lighthouse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pavelfeldman/lighthouse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pavelfeldman/lighthouse/git/refs{/sha}","trees_url":"https://api.github.com/repos/pavelfeldman/lighthouse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pavelfeldman/lighthouse/statuses/{sha}","languages_url":"https://api.github.com/repos/pavelfeldman/lighthouse/languages","stargazers_url":"https://api.github.com/repos/pavelfeldman/lighthouse/stargazers","contributors_url":"https://api.github.com/repos/pavelfeldman/lighthouse/contributors","subscribers_url":"https://api.github.com/repos/pavelfeldman/lighthouse/subscribers","subscription_url":"https://api.github.com/repos/pavelfeldman/lighthouse/subscription","commits_url":"https://api.github.com/repos/pavelfeldman/lighthouse/commits{/sha}","git_commits_url":"https://api.github.com/repos/pavelfeldman/lighthouse/git/commits{/sha}","comments_url":"https://api.github.com/repos/pavelfeldman/lighthouse/comments{/number}","issue_comment_url":"https://api.github.com/repos/pavelfeldman/lighthouse/issues/comments{/number}","contents_url":"https://api.github.com/repos/pavelfeldman/lighthouse/contents/{+path}","compare_url":"https://api.github.com/repos/pavelfeldman/lighthouse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pavelfeldman/lighthouse/merges","archive_url":"https://api.github.com/repos/pavelfeldman/lighthouse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pavelfeldman/lighthouse/downloads","issues_url":"https://api.github.com/repos/pavelfeldman/lighthouse/issues{/number}","pulls_url":"https://api.github.com/repos/pavelfeldman/lighthouse/pulls{/number}","milestones_url":"https://api.github.com/repos/pavelfeldman/lighthouse/milestones{/number}","notifications_url":"https://api.github.com/repos/pavelfeldman/lighthouse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pavelfeldman/lighthouse/labels{/name}","releases_url":"https://api.github.com/repos/pavelfeldman/lighthouse/releases{/id}","deployments_url":"https://api.github.com/repos/pavelfeldman/lighthouse/deployments","created_at":"2016-10-19T01:36:09Z","updated_at":"2016-10-19T01:36:11Z","pushed_at":"2016-10-19T23:45:22Z","git_url":"git://github.com/pavelfeldman/lighthouse.git","ssh_url":"git@github.com:pavelfeldman/lighthouse.git","clone_url":"https://github.com/pavelfeldman/lighthouse.git","svn_url":"https://github.com/pavelfeldman/lighthouse","homepage":"","size":8088,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleChrome:master","ref":"master","sha":"9c78853f0c6e86eae7383cc7f5ec9e3e6901dfa3","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-20T19:38:10Z","pushed_at":"2016-10-20T15:41:42Z","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":10220,"stargazers_count":2740,"watchers_count":2740,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":114,"mirror_url":null,"open_issues_count":91,"forks":114,"open_issues":91,"watchers":2740,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/800"},"html":{"href":"https://github.com/GoogleChrome/lighthouse/pull/800"},"issue":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/800"},"comments":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/800/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/800/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/800/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/9447ec1244f9f188b34b4c9a017a1458829ec8e9"}}}}
{"actor":{"display_login":"samccone"}}