{"action":"created","comment":{"url":"https://api.github.com/repos/ampproject/amphtml/pulls/comments/143744270","pull_request_review_id":68290138,"id":143744270,"diff_hunk":"@@ -51,303 +46,70 @@ describes.realWin('DoubleClick Fast Fetch RTC', {amp: true}, env => {\n       'type': 'doubleclick',\n       'layout': 'fixed',\n     });\n-    const rtcConf = createElementWithAttributes(\n-        env.win.document, 'script',\n-        {type: 'application/json', id: 'amp-rtc'});\n-    rtcConf.innerHTML = JSON.stringify({\n-      endpoint: 'https://example-publisher.com/rtc/',\n-    });\n-    env.win.document.head.appendChild(rtcConf);\n-    xhrMock = sandbox.stub(Xhr.prototype, 'fetchJson');\n+    impl = new AmpAdNetworkDoubleclickImpl(element, env.win.document, env.win);\n+    impl.populateAdUrlState();\n   });\n \n   afterEach(() => {\n     sandbox.restore();\n     impl = null;\n-    xhrMock = null;\n-    resetRtcStateForTesting();\n-    const rtcConf = env.win.document.getElementById('amp-rtc');\n-    env.win.document.head.removeChild(rtcConf);\n-  });\n-\n-  function mockRtcExecution(rtcResponse, element, opt_textFunction) {\n-    impl = new AmpAdNetworkDoubleclickImpl(element, env.win.document, env.win);\n-    let textFunction = () => {\n-      return Promise.resolve(JSON.stringify(rtcResponse));\n-    };\n-    textFunction = opt_textFunction || textFunction;\n-    xhrMock.returns(\n-        Promise.resolve({\n-          redirected: false,\n-          status: 200,\n-          text: textFunction,\n-        })\n-    );\n-    impl.populateAdUrlState();\n-    return impl.executeRtc_(env.win.document);\n-  }\n-\n-  function setRtcConfig(rtcConfigJson) {\n-    const rtcConf = env.win.document.getElementById('amp-rtc');\n-    rtcConf.innerText = JSON.stringify(rtcConfigJson);\n-  }\n-\n-  it('should add just targeting to impl', () => {\n-    const targeting = {'sport': 'baseball'};\n-    const jsonTargeting = {\n-      targeting,\n-    };\n-    return mockRtcExecution({\n-      targeting,\n-    }, element).then(() => {\n-      expect(impl.jsonTargeting_).to.deep.equal(jsonTargeting);\n-    });\n   });\n \n-  it('should add just categoryExclusions to impl', () => {\n-    const categoryExclusions = {'sport': 'baseball'};\n-    const jsonTargeting = {\n-      categoryExclusions,\n-    };\n-    return mockRtcExecution({\n-      categoryExclusions,\n-    }, element).then(() => {\n-      expect(impl.jsonTargeting_).to.deep.equal(jsonTargeting);\n+  describe('#mergeRtcResponses_', () => {\n+    function testMergeRtcResponses(\n+        rtcResponseArray, expectedParams, expectedJsonTargeting) {\n+      const rtcUrlParams = impl.mergeRtcResponses_(rtcResponseArray);\n+      expect(rtcUrlParams).to.deep.equal(expectedParams);\n+      expect(impl.jsonTargeting_).to.deep.equal(expectedJsonTargeting);\n+    }\n+    it('should properly merge RTC responses into jsonTargeting on impl', () => {\n+      const rtcResponseArray = [\n+        {response: {targeting: {'a': [1,2,3], 'b': {c: 'd'}}},\n+          callout: 'www.exampleA.com', rtcTime: 100},\n+        {response: {targeting: {'a': 'foo', 'b': {e: 'f'}}},\n+          callout: 'www.exampleB.com', rtcTime: 500},\n+        {response: {targeting: {'z': [{a: 'b'}, {c: 'd'}], 'b': {c: 'd'}}},\n+          callout: 'www.exampleC.com', rtcTime: 100},\n+      ];\n+      const expectedParams = {\n+        ati: '2,2,2',\n+        artc: '100,500,100',\n+        ard: 'www.exampleA.com,www.exampleB.com,www.exampleC.com',\n+      };\n+      const expectedJsonTargeting = {\n+        targeting: {\n+          'a': 'foo', 'b': {c: 'd', e: 'f'}, 'z': [{a: 'b'}, {c: 'd'}]},\n+      };\n+      testMergeRtcResponses(\n+          rtcResponseArray, expectedParams, expectedJsonTargeting);\n+    });\n+\n+    it('should only add params for callouts that were actually sent', () => {\n+      const rtcResponseArray = [","path":"extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-rtc.js","position":127,"original_position":127,"commit_id":"3c2ef2c6c8b8f92fa490430edfdb7653478a3853","original_commit_id":"db9d0957d823be6eefe249caa90f21c5584be460","user":{"login":"bradfrizzell","id":4276992,"avatar_url":"https://avatars1.githubusercontent.com/u/4276992?v=4","gravatar_id":"","url":"https://api.github.com/users/bradfrizzell","html_url":"https://github.com/bradfrizzell","followers_url":"https://api.github.com/users/bradfrizzell/followers","following_url":"https://api.github.com/users/bradfrizzell/following{/other_user}","gists_url":"https://api.github.com/users/bradfrizzell/gists{/gist_id}","starred_url":"https://api.github.com/users/bradfrizzell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradfrizzell/subscriptions","organizations_url":"https://api.github.com/users/bradfrizzell/orgs","repos_url":"https://api.github.com/users/bradfrizzell/repos","events_url":"https://api.github.com/users/bradfrizzell/events{/privacy}","received_events_url":"https://api.github.com/users/bradfrizzell/received_events","type":"User","site_admin":false},"body":"the second one was intermixed, but I'll add more ","created_at":"2017-10-10T14:27:00Z","updated_at":"2017-10-10T14:56:08Z","html_url":"https://github.com/ampproject/amphtml/pull/11607#discussion_r143744270","pull_request_url":"https://api.github.com/repos/ampproject/amphtml/pulls/11607","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/comments/143744270"},"html":{"href":"https://github.com/ampproject/amphtml/pull/11607#discussion_r143744270"},"pull_request":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/11607"}},"in_reply_to_id":143730859},"pull_request":{"url":"https://api.github.com/repos/ampproject/amphtml/pulls/11607","id":145459252,"html_url":"https://github.com/ampproject/amphtml/pull/11607","diff_url":"https://github.com/ampproject/amphtml/pull/11607.diff","patch_url":"https://github.com/ampproject/amphtml/pull/11607.patch","issue_url":"https://api.github.com/repos/ampproject/amphtml/issues/11607","number":11607,"state":"open","locked":false,"title":"Add RTC support to DoubleClick's Fast Fetch implementation","user":{"login":"bradfrizzell","id":4276992,"avatar_url":"https://avatars1.githubusercontent.com/u/4276992?v=4","gravatar_id":"","url":"https://api.github.com/users/bradfrizzell","html_url":"https://github.com/bradfrizzell","followers_url":"https://api.github.com/users/bradfrizzell/followers","following_url":"https://api.github.com/users/bradfrizzell/following{/other_user}","gists_url":"https://api.github.com/users/bradfrizzell/gists{/gist_id}","starred_url":"https://api.github.com/users/bradfrizzell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradfrizzell/subscriptions","organizations_url":"https://api.github.com/users/bradfrizzell/orgs","repos_url":"https://api.github.com/users/bradfrizzell/repos","events_url":"https://api.github.com/users/bradfrizzell/events{/privacy}","received_events_url":"https://api.github.com/users/bradfrizzell/received_events","type":"User","site_admin":false},"body":"See https://github.com/ampproject/amphtml/pull/11377","created_at":"2017-10-09T13:53:37Z","updated_at":"2017-10-10T14:56:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0e2441b8cf441bdc93622a6040395b0aa5fc0911","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":{"url":"https://api.github.com/repos/ampproject/amphtml/milestones/20","html_url":"https://github.com/ampproject/amphtml/milestone/20","labels_url":"https://api.github.com/repos/ampproject/amphtml/milestones/20/labels","id":1884542,"number":20,"title":"Pending Triage","description":"These issues need to get put into another milestone. They should be assigned to the person who can best decide the appropriate milestone. Optionally, the issue can then be assigned to the most likely implementer.","creator":{"login":"rudygalfi","id":3888212,"avatar_url":"https://avatars3.githubusercontent.com/u/3888212?v=4","gravatar_id":"","url":"https://api.github.com/users/rudygalfi","html_url":"https://github.com/rudygalfi","followers_url":"https://api.github.com/users/rudygalfi/followers","following_url":"https://api.github.com/users/rudygalfi/following{/other_user}","gists_url":"https://api.github.com/users/rudygalfi/gists{/gist_id}","starred_url":"https://api.github.com/users/rudygalfi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudygalfi/subscriptions","organizations_url":"https://api.github.com/users/rudygalfi/orgs","repos_url":"https://api.github.com/users/rudygalfi/repos","events_url":"https://api.github.com/users/rudygalfi/events{/privacy}","received_events_url":"https://api.github.com/users/rudygalfi/received_events","type":"User","site_admin":false},"open_issues":264,"closed_issues":335,"state":"open","created_at":"2016-07-14T23:13:22Z","updated_at":"2017-10-10T12:01:23Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/ampproject/amphtml/pulls/11607/commits","review_comments_url":"https://api.github.com/repos/ampproject/amphtml/pulls/11607/comments","review_comment_url":"https://api.github.com/repos/ampproject/amphtml/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ampproject/amphtml/issues/11607/comments","statuses_url":"https://api.github.com/repos/ampproject/amphtml/statuses/3c2ef2c6c8b8f92fa490430edfdb7653478a3853","head":{"label":"google:frizz-add-rtc-to-doubleclick","ref":"frizz-add-rtc-to-doubleclick","sha":"3c2ef2c6c8b8f92fa490430edfdb7653478a3853","user":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":51965089,"name":"amphtml","full_name":"google/amphtml","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/amphtml","description":"AMP HTML source code, samples, and documentation.  See below for more info.","fork":true,"url":"https://api.github.com/repos/google/amphtml","forks_url":"https://api.github.com/repos/google/amphtml/forks","keys_url":"https://api.github.com/repos/google/amphtml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/amphtml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/amphtml/teams","hooks_url":"https://api.github.com/repos/google/amphtml/hooks","issue_events_url":"https://api.github.com/repos/google/amphtml/issues/events{/number}","events_url":"https://api.github.com/repos/google/amphtml/events","assignees_url":"https://api.github.com/repos/google/amphtml/assignees{/user}","branches_url":"https://api.github.com/repos/google/amphtml/branches{/branch}","tags_url":"https://api.github.com/repos/google/amphtml/tags","blobs_url":"https://api.github.com/repos/google/amphtml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/amphtml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/amphtml/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/amphtml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/amphtml/statuses/{sha}","languages_url":"https://api.github.com/repos/google/amphtml/languages","stargazers_url":"https://api.github.com/repos/google/amphtml/stargazers","contributors_url":"https://api.github.com/repos/google/amphtml/contributors","subscribers_url":"https://api.github.com/repos/google/amphtml/subscribers","subscription_url":"https://api.github.com/repos/google/amphtml/subscription","commits_url":"https://api.github.com/repos/google/amphtml/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/amphtml/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/amphtml/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/amphtml/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/amphtml/contents/{+path}","compare_url":"https://api.github.com/repos/google/amphtml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/amphtml/merges","archive_url":"https://api.github.com/repos/google/amphtml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/amphtml/downloads","issues_url":"https://api.github.com/repos/google/amphtml/issues{/number}","pulls_url":"https://api.github.com/repos/google/amphtml/pulls{/number}","milestones_url":"https://api.github.com/repos/google/amphtml/milestones{/number}","notifications_url":"https://api.github.com/repos/google/amphtml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/amphtml/labels{/name}","releases_url":"https://api.github.com/repos/google/amphtml/releases{/id}","deployments_url":"https://api.github.com/repos/google/amphtml/deployments","created_at":"2016-02-18T00:04:16Z","updated_at":"2017-10-03T14:31:29Z","pushed_at":"2017-10-10T14:55:57Z","git_url":"git://github.com/google/amphtml.git","ssh_url":"git@github.com:google/amphtml.git","clone_url":"https://github.com/google/amphtml.git","svn_url":"https://github.com/google/amphtml","homepage":"https://ampproject.org","size":291180,"stargazers_count":115,"watchers_count":115,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":0,"forks":34,"open_issues":0,"watchers":115,"default_branch":"master"}},"base":{"label":"ampproject:master","ref":"master","sha":"cc9ed7daebad5a38b32c1009e1ed80d01e1646d1","user":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars3.githubusercontent.com/u/14114390?v=4","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"repo":{"id":41766002,"name":"amphtml","full_name":"ampproject/amphtml","owner":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars3.githubusercontent.com/u/14114390?v=4","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ampproject/amphtml","description":"AMP HTML source code, samples, and documentation.  See below for more info.","fork":false,"url":"https://api.github.com/repos/ampproject/amphtml","forks_url":"https://api.github.com/repos/ampproject/amphtml/forks","keys_url":"https://api.github.com/repos/ampproject/amphtml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ampproject/amphtml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ampproject/amphtml/teams","hooks_url":"https://api.github.com/repos/ampproject/amphtml/hooks","issue_events_url":"https://api.github.com/repos/ampproject/amphtml/issues/events{/number}","events_url":"https://api.github.com/repos/ampproject/amphtml/events","assignees_url":"https://api.github.com/repos/ampproject/amphtml/assignees{/user}","branches_url":"https://api.github.com/repos/ampproject/amphtml/branches{/branch}","tags_url":"https://api.github.com/repos/ampproject/amphtml/tags","blobs_url":"https://api.github.com/repos/ampproject/amphtml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ampproject/amphtml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ampproject/amphtml/git/refs{/sha}","trees_url":"https://api.github.com/repos/ampproject/amphtml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ampproject/amphtml/statuses/{sha}","languages_url":"https://api.github.com/repos/ampproject/amphtml/languages","stargazers_url":"https://api.github.com/repos/ampproject/amphtml/stargazers","contributors_url":"https://api.github.com/repos/ampproject/amphtml/contributors","subscribers_url":"https://api.github.com/repos/ampproject/amphtml/subscribers","subscription_url":"https://api.github.com/repos/ampproject/amphtml/subscription","commits_url":"https://api.github.com/repos/ampproject/amphtml/commits{/sha}","git_commits_url":"https://api.github.com/repos/ampproject/amphtml/git/commits{/sha}","comments_url":"https://api.github.com/repos/ampproject/amphtml/comments{/number}","issue_comment_url":"https://api.github.com/repos/ampproject/amphtml/issues/comments{/number}","contents_url":"https://api.github.com/repos/ampproject/amphtml/contents/{+path}","compare_url":"https://api.github.com/repos/ampproject/amphtml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ampproject/amphtml/merges","archive_url":"https://api.github.com/repos/ampproject/amphtml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ampproject/amphtml/downloads","issues_url":"https://api.github.com/repos/ampproject/amphtml/issues{/number}","pulls_url":"https://api.github.com/repos/ampproject/amphtml/pulls{/number}","milestones_url":"https://api.github.com/repos/ampproject/amphtml/milestones{/number}","notifications_url":"https://api.github.com/repos/ampproject/amphtml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ampproject/amphtml/labels{/name}","releases_url":"https://api.github.com/repos/ampproject/amphtml/releases{/id}","deployments_url":"https://api.github.com/repos/ampproject/amphtml/deployments","created_at":"2015-09-01T22:10:53Z","updated_at":"2017-10-10T08:08:13Z","pushed_at":"2017-10-10T14:56:01Z","git_url":"git://github.com/ampproject/amphtml.git","ssh_url":"git@github.com:ampproject/amphtml.git","clone_url":"https://github.com/ampproject/amphtml.git","svn_url":"https://github.com/ampproject/amphtml","homepage":"https://www.ampproject.org","size":289780,"stargazers_count":10529,"watchers_count":10529,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1972,"mirror_url":null,"open_issues_count":1007,"forks":1972,"open_issues":1007,"watchers":10529,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/11607"},"html":{"href":"https://github.com/ampproject/amphtml/pull/11607"},"issue":{"href":"https://api.github.com/repos/ampproject/amphtml/issues/11607"},"comments":{"href":"https://api.github.com/repos/ampproject/amphtml/issues/11607/comments"},"review_comments":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/11607/comments"},"review_comment":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/11607/commits"},"statuses":{"href":"https://api.github.com/repos/ampproject/amphtml/statuses/3c2ef2c6c8b8f92fa490430edfdb7653478a3853"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"bradfrizzell"}}