{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments/60144581","id":60144581,"diff_hunk":"@@ -18,99 +18,114 @@\n \n class GatherScheduler {\n \n-  static _runPhase(gatherers, gatherFun) {\n-    return gatherers.reduce(\n-      (chain, gatherer) => chain.then(_ => gatherFun(gatherer)),\n-      Promise.resolve()\n-    );\n+  static runSeries(fns) {\n+    const args = Array.from(arguments).slice(1);\n+\n+    return fns.reduce((prev, curr) => {\n+      return prev.then(_ => curr.apply(null, args));\n+    }, Promise.resolve());\n   }\n \n-  static run(gatherers, options) {\n-    const driver = options.driver;\n-    const url = options.url;\n+  static loadPage(driver, gatherers, options) {\n     const loadPage = options.flags.loadPage;\n-    const emulateMobileDevice = options.flags.mobile;\n-    const tracingData = {};\n-    const artifacts = [];\n+    const url = options.url;\n \n-    if (url === undefined || url === null) {\n-      throw new Error('You must provide a url to scheduler');\n+    if (loadPage) {\n+      return driver.gotoURL(url, driver.WAIT_FOR_LOADED);\n     }\n \n-    return driver.connect()\n-\n-      // Enable emulation.\n-      .then(_ => {\n-        if (emulateMobileDevice) {\n-          return driver.beginEmulation();\n-        }\n-\n-        return Promise.resolve();\n-      })\n+    return Promise.resolve();\n+  }\n \n-      // Clean all browser caches.\n-      .then(_ => driver.cleanAndDisableBrowserCaches())\n+  static reloadPage(driver, gatherers, options) {\n+    // Such a hack... since a Page.reload command does not let\n+    // a service worker take over we have to trick the browser into going away\n+    // and then coming back.\n+    return driver.sendCommand('Page.navigate', {url: 'about:blank'}).then(_ => {\n+      return driver.gotoURL(options.url, driver.WAIT_FOR_LOADED);\n+    });\n+  }\n \n+  static setupDriver(driver, gatherers, options) {\n+    return new Promise((res, _) => {\n+      // Enable emulation.\n+      if (options.flags.emulateMobileDevice) {\n+        return res(driver.beginEmulation());\n+      }\n+\n+      // noop if no mobile emulation\n+      res();\n+    }).then(_ => {\n+      return driver.cleanAndDisableBrowserCaches();\n+    }).then(_ => {\n       // Force SWs to update on load.\n-      .then(_ => driver.forceUpdateServiceWorkers())\n-\n-      // Gather: setup phase.\n-      .then(_ => this._runPhase(gatherers,\n-          gatherer => gatherer.setup(options)))\n-\n-      // Enable tracing and network record collection.\n-      .then(_ => driver.beginTrace())\n-      .then(_ => driver.beginNetworkCollect())\n-\n-      // Gather: beforePageLoad phase.\n-      .then(_ => this._runPhase(gatherers,\n-          gatherer => gatherer.beforePageLoad(options)))\n-\n-      // Load the page (if the CLI / extension want it loaded).\n-      .then(_ => {\n-        if (loadPage) {\n-          return driver.gotoURL(url, driver.WAIT_FOR_LOADED);\n-        }\n-\n-        return Promise.resolve();\n-      })\n+      return driver.forceUpdateServiceWorkers();\n+    });\n+  }\n \n-      // Gather: afterPageLoad phase\n-      .then(_ => this._runPhase(gatherers,\n-          gatherer => gatherer.afterPageLoad(options)))\n+  // Enable tracing and network record collection.\n+  static beginPassiveCollection(driver) {\n+    return driver.beginTrace().then(_ => {\n+      return driver.beginNetworkCollect();\n+    });\n+  }\n \n-      // Disable network collection; grab records.\n-      .then(_ => driver.endNetworkCollect())\n-      .then(networkRecords => {\n-        tracingData.networkRecords = networkRecords;\n-      })\n+  static endPassiveCollection(driver, gatherers, options, tracingData) {\n+    return driver.endNetworkCollect().then(networkRecords => {\n+      tracingData.networkRecords = networkRecords;\n+    }).then(_ => {\n+      return driver.endTrace();\n+    }).then(traceContents => {\n+      tracingData.traceContents = traceContents;\n+    });\n+  }\n \n-      // Disable tracing; grab records.\n-      .then(_ => driver.endTrace())\n-      .then(traceContents => {\n-        tracingData.traceContents = traceContents;\n-      })\n+  static _phase(phaseName) {\n+    return function(driver, gatherers, options, tracingData) {\n+      return GatherScheduler._runPhase(gatherers, gatherer => {\n+        return gatherer[phaseName](options, tracingData);\n+      });\n+    };\n+  }\n \n-      // Gather: afterTraceCollected phase.\n-      .then(_ => this._runPhase(gatherers,\n-          gatherer => gatherer.afterTraceCollected(options, tracingData)))\n+  static _runPhase(gatherers, gatherFun) {\n+    return gatherers.reduce((chain, gatherer) => {\n+      return chain.then(_ => gatherFun(gatherer));\n+    }, Promise.resolve());\n+  }\n \n-      // Disconnect the driver.\n-      .then(_ => driver.disconnect())\n+  static run(gatherers, options) {\n+    const driver = options.driver;\n+    const tracingData = {};\n+    const self = GatherScheduler;","path":"gather-scheduler.js","position":148,"original_position":148,"commit_id":"a5f89d117a3db6c280403229cad3c54ded1d7468","original_commit_id":"a5f89d117a3db6c280403229cad3c54ded1d7468","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":"that has the same issue","created_at":"2016-04-18T22:20:15Z","updated_at":"2016-04-18T22:20:15Z","html_url":"https://github.com/GoogleChrome/lighthouse/pull/187#discussion_r60144581","pull_request_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/187","_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments/60144581"},"html":{"href":"https://github.com/GoogleChrome/lighthouse/pull/187#discussion_r60144581"},"pull_request":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/187"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/187","id":66261553,"html_url":"https://github.com/GoogleChrome/lighthouse/pull/187","diff_url":"https://github.com/GoogleChrome/lighthouse/pull/187.diff","patch_url":"https://github.com/GoogleChrome/lighthouse/pull/187.patch","issue_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/187","number":187,"state":"open","locked":false,"title":"add smoke tests + fix service worker tests","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":"https://travis-ci.org/GoogleChrome/lighthouse/jobs/122697303#L1114\r\n^ Interesting... looks like we are not picking up the service worker at all ... curious if anyone has insight here... could it be due to the revert of the force update I did? Is something else going on? \r\n\r\n---\r\n\r\nLooks like the force update of service worker API changed a bit today\r\nhttps://travis-ci.org/GoogleChrome/lighthouse/jobs/122689130#L2606\r\n\r\nWhich is causing the test to fail until I reverted the commit that enabled this behavior","created_at":"2016-04-13T03:38:28Z","updated_at":"2016-04-18T22:20:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c9897a270267d36519aec0b703eb0d0159b04962","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/187/commits","review_comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/187/comments","review_comment_url":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/187/comments","statuses_url":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/a5f89d117a3db6c280403229cad3c54ded1d7468","head":{"label":"GoogleChrome:sjs/test-sketch","ref":"sjs/test-sketch","sha":"a5f89d117a3db6c280403229cad3c54ded1d7468","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":null,"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-04-18T03:14:23Z","pushed_at":"2016-04-18T13:27:11Z","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":null,"size":2707,"stargazers_count":71,"watchers_count":71,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":31,"forks":14,"open_issues":31,"watchers":71,"default_branch":"master"}},"base":{"label":"GoogleChrome:master","ref":"master","sha":"848605cde764fab84aa5a9103c43cb1bc39ddf36","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":null,"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-04-18T03:14:23Z","pushed_at":"2016-04-18T13:27:11Z","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":null,"size":2707,"stargazers_count":71,"watchers_count":71,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":31,"forks":14,"open_issues":31,"watchers":71,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/187"},"html":{"href":"https://github.com/GoogleChrome/lighthouse/pull/187"},"issue":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/187"},"comments":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/issues/187/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/187/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/pulls/187/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleChrome/lighthouse/statuses/a5f89d117a3db6c280403229cad3c54ded1d7468"}}}}