{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/activity-stream/pulls/comments/130516865","pull_request_review_id":53398886,"id":130516865,"diff_hunk":"@@ -0,0 +1,93 @@\n+\"use strict\";\n+\n+function popPrefs() {\n+  return SpecialPowers.popPrefEnv();\n+}\n+function pushPrefs(...prefs) {\n+  return SpecialPowers.pushPrefEnv({set: prefs});\n+}\n+\n+// Activity Stream tests expect it to be enabled, and make sure to clear out any\n+// preloaded browsers that might have about:newtab that we don't want to test\n+const ACTIVITY_STREAM_PREF = \"browser.newtabpage.activity-stream.enabled\";\n+pushPrefs([ACTIVITY_STREAM_PREF, true]);\n+gBrowser.removePreloadedBrowser();\n+\n+/**\n+ * Helper to wait for potentially preloaded browsers to load\n+ */\n+async function waitForPreloaded(browser) {\n+  let readyState = await ContentTask.spawn(browser, {}, () => content.document.readyState);\n+  if (readyState !== \"complete\") {\n+    await BrowserTestUtils.browserLoaded(browser);\n+  }\n+}\n+\n+/**\n+ * Helper to run Activity Stream about:newtab test tasks in content.\n+ *\n+ * @param testInfo {Function|Object}\n+ *   {Function} This parameter will be used as if the function were called with\n+ *              an Object with this parameter as \"test\" key's value.\n+ *   {Object} The following keys are expected:\n+ *     before {Function} Optional. Runs before and returns an arg for \"test\"\n+ *     test   {Function} The test to run in the about:newtab content task taking\n+ *                       an arg from \"before\" and returns a result to \"after\"\n+ *     after  {Function} Optional. Runs after and with the result of \"test\"\n+ */\n+function test_newtab(testInfo) { // eslint-disable-line no-unused-vars\n+  // Extract any test parts or default to just the single content task\n+  let {before, test: contentTask, after} = testInfo;\n+  if (!before) {\n+    before = () => ({});\n+  }\n+  if (!contentTask) {\n+    contentTask = testInfo;\n+  }\n+  if (!after) {\n+    after = () => {};\n+  }\n+\n+  // Helper to push prefs for just this test and pop them when done\n+  let needPopPrefs = false;\n+  let scopedPushPrefs = async(...args) => {\n+    needPopPrefs = true;\n+    await pushPrefs(...args);\n+  };\n+  let scopedPopPrefs = async() => {\n+    if (needPopPrefs) {\n+      await popPrefs();\n+    }\n+  };\n+\n+  // Make the test task with optional before/after and content task to run in a\n+  // new tab that opens and closes.\n+  let testTask = async() => {\n+    // Open about:newtab without using the default load listener\n+    let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, \"about:newtab\", false);\n+\n+    // Specially wait for potentially preloaded browsers\n+    let browser = tab.linkedBrowser;\n+    await waitForPreloaded(browser);\n+\n+    // Wait for React to render something\n+    await BrowserTestUtils.waitForCondition(() => ContentTask.spawn(browser, {},\n+      () => content.document.getElementById(\"root\").children.length),\n+      \"Should render activity stream content\");\n+\n+    // Chain together before -> contentTask -> after data passing\n+    try {\n+      let contentArg = await before({pushPrefs: scopedPushPrefs, tab});\n+      let contentResult = await ContentTask.spawn(browser, contentArg, contentTask);\n+      await after(contentResult);\n+    } finally {\n+      // Clean up for next tests\n+      await scopedPopPrefs();\n+      await BrowserTestUtils.removeTab(tab);\n+    }\n+  };\n+","path":"system-addon/test/functional/mochitest/head.js","position":89,"original_position":89,"commit_id":"2ac41e955fd787983f1ee6b6b6167a2ab16aff0b","original_commit_id":"2ac41e955fd787983f1ee6b6b6167a2ab16aff0b","user":{"login":"Mardak","id":438537,"avatar_url":"https://avatars0.githubusercontent.com/u/438537?v=4","gravatar_id":"","url":"https://api.github.com/users/Mardak","html_url":"https://github.com/Mardak","followers_url":"https://api.github.com/users/Mardak/followers","following_url":"https://api.github.com/users/Mardak/following{/other_user}","gists_url":"https://api.github.com/users/Mardak/gists{/gist_id}","starred_url":"https://api.github.com/users/Mardak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mardak/subscriptions","organizations_url":"https://api.github.com/users/Mardak/orgs","repos_url":"https://api.github.com/users/Mardak/repos","events_url":"https://api.github.com/users/Mardak/events{/privacy}","received_events_url":"https://api.github.com/users/Mardak/received_events","type":"User","site_admin":false},"body":"The chaining? I suppose it's \"overengineered\" in that I didn't quite use all the functionality in the actual tests, but it did get me to write some additional actual activity-stream related tests to make sure the helper actually worked. :)","created_at":"2017-08-01T04:21:17Z","updated_at":"2017-08-01T04:21:17Z","html_url":"https://github.com/mozilla/activity-stream/pull/3026#discussion_r130516865","pull_request_url":"https://api.github.com/repos/mozilla/activity-stream/pulls/3026","_links":{"self":{"href":"https://api.github.com/repos/mozilla/activity-stream/pulls/comments/130516865"},"html":{"href":"https://github.com/mozilla/activity-stream/pull/3026#discussion_r130516865"},"pull_request":{"href":"https://api.github.com/repos/mozilla/activity-stream/pulls/3026"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/activity-stream/pulls/3026","id":133181130,"html_url":"https://github.com/mozilla/activity-stream/pull/3026","diff_url":"https://github.com/mozilla/activity-stream/pull/3026.diff","patch_url":"https://github.com/mozilla/activity-stream/pull/3026.patch","issue_url":"https://api.github.com/repos/mozilla/activity-stream/issues/3026","number":3026,"state":"open","locked":false,"title":"fix(tests): Add mochitests that run successfully whether enabled or not","user":{"login":"Mardak","id":438537,"avatar_url":"https://avatars0.githubusercontent.com/u/438537?v=4","gravatar_id":"","url":"https://api.github.com/users/Mardak","html_url":"https://github.com/Mardak","followers_url":"https://api.github.com/users/Mardak/followers","following_url":"https://api.github.com/users/Mardak/following{/other_user}","gists_url":"https://api.github.com/users/Mardak/gists{/gist_id}","starred_url":"https://api.github.com/users/Mardak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mardak/subscriptions","organizations_url":"https://api.github.com/users/Mardak/orgs","repos_url":"https://api.github.com/users/Mardak/repos","events_url":"https://api.github.com/users/Mardak/events{/privacy}","received_events_url":"https://api.github.com/users/Mardak/received_events","type":"User","site_admin":false},"body":"Fix #2880. r?@dmose Beefs up `as_load_location` to work preloaded or not and activity-stream.enabled or not. Adds a `head.js` that turns on activity-stream with a set of basic actual react rendering tests covering some of those itemized in #2127. Also cleans up eslint to use the fancy \"plugin:mozilla/browser-test\" that auto-globalizes-head.js helpers (and other test globals).\r\n\r\nTry looks good when a-s.enabled: https://treeherder.mozilla.org/#/jobs?repo=try&revision=2b1081f19bfc7b5adbd761e347a26fd264b55783\r\nAnd disabled: https://treeherder.mozilla.org/#/jobs?repo=try&revision=34f4c5cf8fbe1c0e2933c429e270e03817b55b2c","created_at":"2017-07-31T07:29:02Z","updated_at":"2017-08-01T04:21:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3d96a7cb6c9bd74a2f3726fd68fa30442913b8c4","assignee":{"login":"Mardak","id":438537,"avatar_url":"https://avatars0.githubusercontent.com/u/438537?v=4","gravatar_id":"","url":"https://api.github.com/users/Mardak","html_url":"https://github.com/Mardak","followers_url":"https://api.github.com/users/Mardak/followers","following_url":"https://api.github.com/users/Mardak/following{/other_user}","gists_url":"https://api.github.com/users/Mardak/gists{/gist_id}","starred_url":"https://api.github.com/users/Mardak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mardak/subscriptions","organizations_url":"https://api.github.com/users/Mardak/orgs","repos_url":"https://api.github.com/users/Mardak/repos","events_url":"https://api.github.com/users/Mardak/events{/privacy}","received_events_url":"https://api.github.com/users/Mardak/received_events","type":"User","site_admin":false},"assignees":[{"login":"Mardak","id":438537,"avatar_url":"https://avatars0.githubusercontent.com/u/438537?v=4","gravatar_id":"","url":"https://api.github.com/users/Mardak","html_url":"https://github.com/Mardak","followers_url":"https://api.github.com/users/Mardak/followers","following_url":"https://api.github.com/users/Mardak/following{/other_user}","gists_url":"https://api.github.com/users/Mardak/gists{/gist_id}","starred_url":"https://api.github.com/users/Mardak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mardak/subscriptions","organizations_url":"https://api.github.com/users/Mardak/orgs","repos_url":"https://api.github.com/users/Mardak/repos","events_url":"https://api.github.com/users/Mardak/events{/privacy}","received_events_url":"https://api.github.com/users/Mardak/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/activity-stream/pulls/3026/commits","review_comments_url":"https://api.github.com/repos/mozilla/activity-stream/pulls/3026/comments","review_comment_url":"https://api.github.com/repos/mozilla/activity-stream/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/activity-stream/issues/3026/comments","statuses_url":"https://api.github.com/repos/mozilla/activity-stream/statuses/2ac41e955fd787983f1ee6b6b6167a2ab16aff0b","head":{"label":"Mardak:gh2880-tests","ref":"gh2880-tests","sha":"2ac41e955fd787983f1ee6b6b6167a2ab16aff0b","user":{"login":"Mardak","id":438537,"avatar_url":"https://avatars0.githubusercontent.com/u/438537?v=4","gravatar_id":"","url":"https://api.github.com/users/Mardak","html_url":"https://github.com/Mardak","followers_url":"https://api.github.com/users/Mardak/followers","following_url":"https://api.github.com/users/Mardak/following{/other_user}","gists_url":"https://api.github.com/users/Mardak/gists{/gist_id}","starred_url":"https://api.github.com/users/Mardak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mardak/subscriptions","organizations_url":"https://api.github.com/users/Mardak/orgs","repos_url":"https://api.github.com/users/Mardak/repos","events_url":"https://api.github.com/users/Mardak/events{/privacy}","received_events_url":"https://api.github.com/users/Mardak/received_events","type":"User","site_admin":false},"repo":{"id":64378674,"name":"activity-stream","full_name":"Mardak/activity-stream","owner":{"login":"Mardak","id":438537,"avatar_url":"https://avatars0.githubusercontent.com/u/438537?v=4","gravatar_id":"","url":"https://api.github.com/users/Mardak","html_url":"https://github.com/Mardak","followers_url":"https://api.github.com/users/Mardak/followers","following_url":"https://api.github.com/users/Mardak/following{/other_user}","gists_url":"https://api.github.com/users/Mardak/gists{/gist_id}","starred_url":"https://api.github.com/users/Mardak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mardak/subscriptions","organizations_url":"https://api.github.com/users/Mardak/orgs","repos_url":"https://api.github.com/users/Mardak/repos","events_url":"https://api.github.com/users/Mardak/events{/privacy}","received_events_url":"https://api.github.com/users/Mardak/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Mardak/activity-stream","description":" MVP prototype add-on for activity streams","fork":true,"url":"https://api.github.com/repos/Mardak/activity-stream","forks_url":"https://api.github.com/repos/Mardak/activity-stream/forks","keys_url":"https://api.github.com/repos/Mardak/activity-stream/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mardak/activity-stream/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mardak/activity-stream/teams","hooks_url":"https://api.github.com/repos/Mardak/activity-stream/hooks","issue_events_url":"https://api.github.com/repos/Mardak/activity-stream/issues/events{/number}","events_url":"https://api.github.com/repos/Mardak/activity-stream/events","assignees_url":"https://api.github.com/repos/Mardak/activity-stream/assignees{/user}","branches_url":"https://api.github.com/repos/Mardak/activity-stream/branches{/branch}","tags_url":"https://api.github.com/repos/Mardak/activity-stream/tags","blobs_url":"https://api.github.com/repos/Mardak/activity-stream/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mardak/activity-stream/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mardak/activity-stream/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mardak/activity-stream/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mardak/activity-stream/statuses/{sha}","languages_url":"https://api.github.com/repos/Mardak/activity-stream/languages","stargazers_url":"https://api.github.com/repos/Mardak/activity-stream/stargazers","contributors_url":"https://api.github.com/repos/Mardak/activity-stream/contributors","subscribers_url":"https://api.github.com/repos/Mardak/activity-stream/subscribers","subscription_url":"https://api.github.com/repos/Mardak/activity-stream/subscription","commits_url":"https://api.github.com/repos/Mardak/activity-stream/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mardak/activity-stream/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mardak/activity-stream/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mardak/activity-stream/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mardak/activity-stream/contents/{+path}","compare_url":"https://api.github.com/repos/Mardak/activity-stream/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mardak/activity-stream/merges","archive_url":"https://api.github.com/repos/Mardak/activity-stream/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mardak/activity-stream/downloads","issues_url":"https://api.github.com/repos/Mardak/activity-stream/issues{/number}","pulls_url":"https://api.github.com/repos/Mardak/activity-stream/pulls{/number}","milestones_url":"https://api.github.com/repos/Mardak/activity-stream/milestones{/number}","notifications_url":"https://api.github.com/repos/Mardak/activity-stream/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mardak/activity-stream/labels{/name}","releases_url":"https://api.github.com/repos/Mardak/activity-stream/releases{/id}","deployments_url":"https://api.github.com/repos/Mardak/activity-stream/deployments","created_at":"2016-07-28T08:39:26Z","updated_at":"2016-07-28T08:39:28Z","pushed_at":"2017-07-31T22:45:42Z","git_url":"git://github.com/Mardak/activity-stream.git","ssh_url":"git@github.com:Mardak/activity-stream.git","clone_url":"https://github.com/Mardak/activity-stream.git","svn_url":"https://github.com/Mardak/activity-stream","homepage":"","size":4754,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"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":"mozilla:master","ref":"master","sha":"8c7a4d9424c615d4dddb4e68ef4d9d90eaefcc93","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars2.githubusercontent.com/u/131524?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":50695589,"name":"activity-stream","full_name":"mozilla/activity-stream","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars2.githubusercontent.com/u/131524?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/activity-stream","description":"A refreshed \"new tab page\" for Firefox","fork":false,"url":"https://api.github.com/repos/mozilla/activity-stream","forks_url":"https://api.github.com/repos/mozilla/activity-stream/forks","keys_url":"https://api.github.com/repos/mozilla/activity-stream/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/activity-stream/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/activity-stream/teams","hooks_url":"https://api.github.com/repos/mozilla/activity-stream/hooks","issue_events_url":"https://api.github.com/repos/mozilla/activity-stream/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/activity-stream/events","assignees_url":"https://api.github.com/repos/mozilla/activity-stream/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/activity-stream/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/activity-stream/tags","blobs_url":"https://api.github.com/repos/mozilla/activity-stream/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/activity-stream/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/activity-stream/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/activity-stream/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/activity-stream/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/activity-stream/languages","stargazers_url":"https://api.github.com/repos/mozilla/activity-stream/stargazers","contributors_url":"https://api.github.com/repos/mozilla/activity-stream/contributors","subscribers_url":"https://api.github.com/repos/mozilla/activity-stream/subscribers","subscription_url":"https://api.github.com/repos/mozilla/activity-stream/subscription","commits_url":"https://api.github.com/repos/mozilla/activity-stream/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/activity-stream/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/activity-stream/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/activity-stream/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/activity-stream/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/activity-stream/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/activity-stream/merges","archive_url":"https://api.github.com/repos/mozilla/activity-stream/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/activity-stream/downloads","issues_url":"https://api.github.com/repos/mozilla/activity-stream/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/activity-stream/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/activity-stream/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/activity-stream/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/activity-stream/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/activity-stream/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/activity-stream/deployments","created_at":"2016-01-29T22:28:26Z","updated_at":"2017-07-30T17:59:59Z","pushed_at":"2017-08-01T02:38:09Z","git_url":"git://github.com/mozilla/activity-stream.git","ssh_url":"git@github.com:mozilla/activity-stream.git","clone_url":"https://github.com/mozilla/activity-stream.git","svn_url":"https://github.com/mozilla/activity-stream","homepage":"","size":5404,"stargazers_count":113,"watchers_count":113,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":55,"mirror_url":null,"open_issues_count":153,"forks":55,"open_issues":153,"watchers":113,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/activity-stream/pulls/3026"},"html":{"href":"https://github.com/mozilla/activity-stream/pull/3026"},"issue":{"href":"https://api.github.com/repos/mozilla/activity-stream/issues/3026"},"comments":{"href":"https://api.github.com/repos/mozilla/activity-stream/issues/3026/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/activity-stream/pulls/3026/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/activity-stream/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/activity-stream/pulls/3026/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/activity-stream/statuses/2ac41e955fd787983f1ee6b6b6167a2ab16aff0b"}}}}
{"actor":{"display_login":"Mardak"}}