{"action":"created","comment":{"url":"https://api.github.com/repos/ftlabs/screens/pulls/comments/48688502","id":48688502,"diff_hunk":"@@ -2,48 +2,70 @@\n \n module.exports = function(client) {\n \n-\tconst handles = {};\n-\n \t// set the current tab to the admin page.\n-\tconst loaded = client\n-\t.getCurrentTabId()\n-\t.then(handle => handles.about = handle)\n-\t.newWindow('/viewer')\n-\t.getCurrentTabId()\n-\t.then(handle => handles.viewer = handle)\n-\t.newWindow('/admin')\n-\t.getCurrentTabId()\n-\t.then(handle => handles.admin = handle);\n-\n-\tfunction loadTab(name) {\n-\t\treturn loaded\n-\t\t.getCurrentTabId()\n-\t\t.then(id => {\n-\n-\t\t\t// if you try to switch to the current tab it will switch to the\n-\t\t\t// first tab :/\n-\t\t\tif (id !== handles[name]) {\n-\t\t\t\treturn loaded\n-\t\t\t\t.switchTab(handles[name]);\n+\tconst tabs = {};\n+\tlet loaded = client;\n+\n+\tclass Tab {\n+\t\tconstructor(name, options) {\n+\n+\t\t\tconst url = options.url;\n+\t\t\tconst handle = options.handle;\n+\n+\t\t\tif (url) loaded = loaded\n+\t\t\t.newWindow(url)\n+\t\t\t.getCurrentTabId()\n+\t\t\t.then(handle => {\n+\t\t\t\tthis.handle = handle;\n+\t\t\t});\n+\n+\t\t\tif (handle) {\n+\t\t\t\tthis.handle = handle;\n \t\t\t}\n-\t\t});\n-\t}\n-\t\n-\tconst fnInterface = {\n-\t\tadmin() {\n-\t\t\treturn loadTab('admin');\n-\t\t},\n-\t\tviewer() {\n-\t\t\treturn loadTab('viewer');\n-\t\t},\n-\t\tabout() {\n-\t\t\treturn loadTab('about');\n+\n+\t\t\tthis.name = name;\n+\n+\t\t\ttabs[name] = this;\n+\t\t}\n+\n+\t\tready() {\n+\t\t\treturn loaded\n+\t\t\t.then(() => this);\n+\t\t}\n+\n+\t\tswitchTo() {\n+\n+\t\t\tloaded = loaded\n+\t\t\t.getCurrentTabId()\n+\t\t\t.then(id => {\n+\t\t\t\tif (id !== this.handle) {\n+\t\t\t\t\treturn client.switchTab(this.handle);\n+\t\t\t\t}\n+\t\t\t});\n+\n+\t\t\treturn loaded\n+\t\t\t.then(() => this);\n \t\t}\n+\n+\t\tclose () {\n+\t\t\tloaded = this.switchTo()\n+\t\t\t.window()","path":"tests/integration/lib/tabs.js","position":85,"original_position":85,"commit_id":"e34b1ff0a2ab65228f53c8cf1e45e2aed466a1e0","original_commit_id":"e34b1ff0a2ab65228f53c8cf1e45e2aed466a1e0","user":{"login":"JakeChampion","id":1569131,"avatar_url":"https://avatars.githubusercontent.com/u/1569131?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeChampion","html_url":"https://github.com/JakeChampion","followers_url":"https://api.github.com/users/JakeChampion/followers","following_url":"https://api.github.com/users/JakeChampion/following{/other_user}","gists_url":"https://api.github.com/users/JakeChampion/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeChampion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeChampion/subscriptions","organizations_url":"https://api.github.com/users/JakeChampion/orgs","repos_url":"https://api.github.com/users/JakeChampion/repos","events_url":"https://api.github.com/users/JakeChampion/events{/privacy}","received_events_url":"https://api.github.com/users/JakeChampion/received_events","type":"User","site_admin":false},"body":"I think `.close()` is more appropriate here, `window()` is an implementation detail of Selenium","created_at":"2016-01-02T22:58:55Z","updated_at":"2016-01-02T22:58:55Z","html_url":"https://github.com/ftlabs/screens/pull/73#discussion_r48688502","pull_request_url":"https://api.github.com/repos/ftlabs/screens/pulls/73","_links":{"self":{"href":"https://api.github.com/repos/ftlabs/screens/pulls/comments/48688502"},"html":{"href":"https://github.com/ftlabs/screens/pull/73#discussion_r48688502"},"pull_request":{"href":"https://api.github.com/repos/ftlabs/screens/pulls/73"}}},"pull_request":{"url":"https://api.github.com/repos/ftlabs/screens/pulls/73","id":54895994,"html_url":"https://github.com/ftlabs/screens/pull/73","diff_url":"https://github.com/ftlabs/screens/pull/73.diff","patch_url":"https://github.com/ftlabs/screens/pull/73.patch","issue_url":"https://api.github.com/repos/ftlabs/screens/issues/73","number":73,"state":"open","locked":false,"title":"Collision test","user":{"login":"AdaRoseEdwards","id":4225330,"avatar_url":"https://avatars.githubusercontent.com/u/4225330?v=3","gravatar_id":"","url":"https://api.github.com/users/AdaRoseEdwards","html_url":"https://github.com/AdaRoseEdwards","followers_url":"https://api.github.com/users/AdaRoseEdwards/followers","following_url":"https://api.github.com/users/AdaRoseEdwards/following{/other_user}","gists_url":"https://api.github.com/users/AdaRoseEdwards/gists{/gist_id}","starred_url":"https://api.github.com/users/AdaRoseEdwards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdaRoseEdwards/subscriptions","organizations_url":"https://api.github.com/users/AdaRoseEdwards/orgs","repos_url":"https://api.github.com/users/AdaRoseEdwards/repos","events_url":"https://api.github.com/users/AdaRoseEdwards/events{/privacy}","received_events_url":"https://api.github.com/users/AdaRoseEdwards/received_events","type":"User","site_admin":false},"body":"Create new tabs for some of the tests, use this to test the browser starting with different parameters so trigger a url reassign.\r\n\r\nfixes #66 ","created_at":"2016-01-01T20:25:38Z","updated_at":"2016-01-02T22:58:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a16b9bcec2a50af6a6d7a057208f5a0e1aeae8b4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ftlabs/screens/pulls/73/commits","review_comments_url":"https://api.github.com/repos/ftlabs/screens/pulls/73/comments","review_comment_url":"https://api.github.com/repos/ftlabs/screens/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ftlabs/screens/issues/73/comments","statuses_url":"https://api.github.com/repos/ftlabs/screens/statuses/e34b1ff0a2ab65228f53c8cf1e45e2aed466a1e0","head":{"label":"ftlabs:collision-test","ref":"collision-test","sha":"e34b1ff0a2ab65228f53c8cf1e45e2aed466a1e0","user":{"login":"ftlabs","id":1432696,"avatar_url":"https://avatars.githubusercontent.com/u/1432696?v=3","gravatar_id":"","url":"https://api.github.com/users/ftlabs","html_url":"https://github.com/ftlabs","followers_url":"https://api.github.com/users/ftlabs/followers","following_url":"https://api.github.com/users/ftlabs/following{/other_user}","gists_url":"https://api.github.com/users/ftlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/ftlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ftlabs/subscriptions","organizations_url":"https://api.github.com/users/ftlabs/orgs","repos_url":"https://api.github.com/users/ftlabs/repos","events_url":"https://api.github.com/users/ftlabs/events{/privacy}","received_events_url":"https://api.github.com/users/ftlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":45405593,"name":"screens","full_name":"ftlabs/screens","owner":{"login":"ftlabs","id":1432696,"avatar_url":"https://avatars.githubusercontent.com/u/1432696?v=3","gravatar_id":"","url":"https://api.github.com/users/ftlabs","html_url":"https://github.com/ftlabs","followers_url":"https://api.github.com/users/ftlabs/followers","following_url":"https://api.github.com/users/ftlabs/following{/other_user}","gists_url":"https://api.github.com/users/ftlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/ftlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ftlabs/subscriptions","organizations_url":"https://api.github.com/users/ftlabs/orgs","repos_url":"https://api.github.com/users/ftlabs/repos","events_url":"https://api.github.com/users/ftlabs/events{/privacy}","received_events_url":"https://api.github.com/users/ftlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ftlabs/screens","description":"A way to distribute websites to multiple displays","fork":false,"url":"https://api.github.com/repos/ftlabs/screens","forks_url":"https://api.github.com/repos/ftlabs/screens/forks","keys_url":"https://api.github.com/repos/ftlabs/screens/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ftlabs/screens/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ftlabs/screens/teams","hooks_url":"https://api.github.com/repos/ftlabs/screens/hooks","issue_events_url":"https://api.github.com/repos/ftlabs/screens/issues/events{/number}","events_url":"https://api.github.com/repos/ftlabs/screens/events","assignees_url":"https://api.github.com/repos/ftlabs/screens/assignees{/user}","branches_url":"https://api.github.com/repos/ftlabs/screens/branches{/branch}","tags_url":"https://api.github.com/repos/ftlabs/screens/tags","blobs_url":"https://api.github.com/repos/ftlabs/screens/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ftlabs/screens/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ftlabs/screens/git/refs{/sha}","trees_url":"https://api.github.com/repos/ftlabs/screens/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ftlabs/screens/statuses/{sha}","languages_url":"https://api.github.com/repos/ftlabs/screens/languages","stargazers_url":"https://api.github.com/repos/ftlabs/screens/stargazers","contributors_url":"https://api.github.com/repos/ftlabs/screens/contributors","subscribers_url":"https://api.github.com/repos/ftlabs/screens/subscribers","subscription_url":"https://api.github.com/repos/ftlabs/screens/subscription","commits_url":"https://api.github.com/repos/ftlabs/screens/commits{/sha}","git_commits_url":"https://api.github.com/repos/ftlabs/screens/git/commits{/sha}","comments_url":"https://api.github.com/repos/ftlabs/screens/comments{/number}","issue_comment_url":"https://api.github.com/repos/ftlabs/screens/issues/comments{/number}","contents_url":"https://api.github.com/repos/ftlabs/screens/contents/{+path}","compare_url":"https://api.github.com/repos/ftlabs/screens/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ftlabs/screens/merges","archive_url":"https://api.github.com/repos/ftlabs/screens/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ftlabs/screens/downloads","issues_url":"https://api.github.com/repos/ftlabs/screens/issues{/number}","pulls_url":"https://api.github.com/repos/ftlabs/screens/pulls{/number}","milestones_url":"https://api.github.com/repos/ftlabs/screens/milestones{/number}","notifications_url":"https://api.github.com/repos/ftlabs/screens/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ftlabs/screens/labels{/name}","releases_url":"https://api.github.com/repos/ftlabs/screens/releases{/id}","created_at":"2015-11-02T16:09:21Z","updated_at":"2015-12-30T12:13:41Z","pushed_at":"2016-01-01T20:51:51Z","git_url":"git://github.com/ftlabs/screens.git","ssh_url":"git@github.com:ftlabs/screens.git","clone_url":"https://github.com/ftlabs/screens.git","svn_url":"https://github.com/ftlabs/screens","homepage":null,"size":706,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":17,"forks":1,"open_issues":17,"watchers":0,"default_branch":"master"}},"base":{"label":"ftlabs:circleci","ref":"circleci","sha":"ef63e42d2ad9be90dae38d9e9bac60ee171f410c","user":{"login":"ftlabs","id":1432696,"avatar_url":"https://avatars.githubusercontent.com/u/1432696?v=3","gravatar_id":"","url":"https://api.github.com/users/ftlabs","html_url":"https://github.com/ftlabs","followers_url":"https://api.github.com/users/ftlabs/followers","following_url":"https://api.github.com/users/ftlabs/following{/other_user}","gists_url":"https://api.github.com/users/ftlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/ftlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ftlabs/subscriptions","organizations_url":"https://api.github.com/users/ftlabs/orgs","repos_url":"https://api.github.com/users/ftlabs/repos","events_url":"https://api.github.com/users/ftlabs/events{/privacy}","received_events_url":"https://api.github.com/users/ftlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":45405593,"name":"screens","full_name":"ftlabs/screens","owner":{"login":"ftlabs","id":1432696,"avatar_url":"https://avatars.githubusercontent.com/u/1432696?v=3","gravatar_id":"","url":"https://api.github.com/users/ftlabs","html_url":"https://github.com/ftlabs","followers_url":"https://api.github.com/users/ftlabs/followers","following_url":"https://api.github.com/users/ftlabs/following{/other_user}","gists_url":"https://api.github.com/users/ftlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/ftlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ftlabs/subscriptions","organizations_url":"https://api.github.com/users/ftlabs/orgs","repos_url":"https://api.github.com/users/ftlabs/repos","events_url":"https://api.github.com/users/ftlabs/events{/privacy}","received_events_url":"https://api.github.com/users/ftlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ftlabs/screens","description":"A way to distribute websites to multiple displays","fork":false,"url":"https://api.github.com/repos/ftlabs/screens","forks_url":"https://api.github.com/repos/ftlabs/screens/forks","keys_url":"https://api.github.com/repos/ftlabs/screens/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ftlabs/screens/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ftlabs/screens/teams","hooks_url":"https://api.github.com/repos/ftlabs/screens/hooks","issue_events_url":"https://api.github.com/repos/ftlabs/screens/issues/events{/number}","events_url":"https://api.github.com/repos/ftlabs/screens/events","assignees_url":"https://api.github.com/repos/ftlabs/screens/assignees{/user}","branches_url":"https://api.github.com/repos/ftlabs/screens/branches{/branch}","tags_url":"https://api.github.com/repos/ftlabs/screens/tags","blobs_url":"https://api.github.com/repos/ftlabs/screens/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ftlabs/screens/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ftlabs/screens/git/refs{/sha}","trees_url":"https://api.github.com/repos/ftlabs/screens/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ftlabs/screens/statuses/{sha}","languages_url":"https://api.github.com/repos/ftlabs/screens/languages","stargazers_url":"https://api.github.com/repos/ftlabs/screens/stargazers","contributors_url":"https://api.github.com/repos/ftlabs/screens/contributors","subscribers_url":"https://api.github.com/repos/ftlabs/screens/subscribers","subscription_url":"https://api.github.com/repos/ftlabs/screens/subscription","commits_url":"https://api.github.com/repos/ftlabs/screens/commits{/sha}","git_commits_url":"https://api.github.com/repos/ftlabs/screens/git/commits{/sha}","comments_url":"https://api.github.com/repos/ftlabs/screens/comments{/number}","issue_comment_url":"https://api.github.com/repos/ftlabs/screens/issues/comments{/number}","contents_url":"https://api.github.com/repos/ftlabs/screens/contents/{+path}","compare_url":"https://api.github.com/repos/ftlabs/screens/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ftlabs/screens/merges","archive_url":"https://api.github.com/repos/ftlabs/screens/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ftlabs/screens/downloads","issues_url":"https://api.github.com/repos/ftlabs/screens/issues{/number}","pulls_url":"https://api.github.com/repos/ftlabs/screens/pulls{/number}","milestones_url":"https://api.github.com/repos/ftlabs/screens/milestones{/number}","notifications_url":"https://api.github.com/repos/ftlabs/screens/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ftlabs/screens/labels{/name}","releases_url":"https://api.github.com/repos/ftlabs/screens/releases{/id}","created_at":"2015-11-02T16:09:21Z","updated_at":"2015-12-30T12:13:41Z","pushed_at":"2016-01-01T20:51:51Z","git_url":"git://github.com/ftlabs/screens.git","ssh_url":"git@github.com:ftlabs/screens.git","clone_url":"https://github.com/ftlabs/screens.git","svn_url":"https://github.com/ftlabs/screens","homepage":null,"size":706,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":17,"forks":1,"open_issues":17,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ftlabs/screens/pulls/73"},"html":{"href":"https://github.com/ftlabs/screens/pull/73"},"issue":{"href":"https://api.github.com/repos/ftlabs/screens/issues/73"},"comments":{"href":"https://api.github.com/repos/ftlabs/screens/issues/73/comments"},"review_comments":{"href":"https://api.github.com/repos/ftlabs/screens/pulls/73/comments"},"review_comment":{"href":"https://api.github.com/repos/ftlabs/screens/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ftlabs/screens/pulls/73/commits"},"statuses":{"href":"https://api.github.com/repos/ftlabs/screens/statuses/e34b1ff0a2ab65228f53c8cf1e45e2aed466a1e0"}}}}