{"action":"created","comment":{"url":"https://api.github.com/repos/ampproject/amphtml/pulls/comments/92858089","pull_request_review_id":13378587,"id":92858089,"diff_hunk":"@@ -0,0 +1,327 @@\n+/**\n+ * Copyright 2015 The AMP HTML Authors. All Rights Reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS-IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+import {validateData, loadScript} from '../../3p/3p';\n+import {tryParseJson} from '../../src/json.js';\n+\n+// Keep track of current height of AMP iframe\n+let currentAmpHeight = null;\n+\n+/**\n+ * Request Custom Search Ads (Adsense for Search or AdSense for Shopping).\n+ * @param {!Window} global The window object of the iframe\n+ * @param {!Object} data\n+ */\n+export function csa(global, data) {\n+\n+  // Get parent width in case we want to override\n+  const width = global.document.body.clientWidth;\n+\n+  validateData(data, [], [\n+    'afshPageOptions',\n+    'afshAdblockOptions',\n+    'afsPageOptions',\n+    'afsAdblockOptions',\n+    'ampSlotIndex',\n+  ]);\n+\n+  // Add the ad container to the document\n+  const csaContainerDiv = global.document.createElement('div');\n+  const containerId = 'csacontainer';\n+  csaContainerDiv.id = containerId;\n+  global.document.body.appendChild(csaContainerDiv);\n+\n+  // Parse AFSh page options\n+  const afshPageOptions = Object.assign(\n+    Object(tryParseJson(data['afshPageOptions'])),\n+    {source: 'amp', referer: global.context.referrer});\n+\n+\n+  // Parse AFSh adblock options\n+  const afshAdblockOptions = Object.assign(\n+    Object(tryParseJson(data['afshAdblockOptions'])),\n+    {container: containerId});\n+\n+  // Set the width to the width of the screen if necessary\n+  if (afshAdblockOptions != null &&\n+    afshAdblockOptions['width'] == 'auto') {\n+    afshAdblockOptions['width'] = width;\n+  }\n+\n+  // Parse AFS page options\n+  const afsPageOptions = Object.assign(\n+    Object(tryParseJson(data['afsPageOptions'])),\n+    {source: 'amp', referer: global.context.referrer});\n+\n+  // Parse AFS adblock options\n+  const afsAdblockOptions = Object.assign(\n+    Object(tryParseJson(data['afsAdblockOptions'])),\n+    {container: containerId});\n+\n+  /* Time in ms to wait before executing orientation change function logic */\n+  const orientationChangeTimeout = 250;\n+\n+  /**\n+   * Resize the AMP iframe if the CSA container changes in size upon rotation.\n+   * This is needed for an iOS bug found in versions 10.0.1 and below that\n+   * doesn't properly reflow the iframe upon orientation change.\n+   */\n+  global.addEventListener('orientationchange', () => {\n+\n+    // Save the height of the container before the event listener triggers\n+    const oldHeight =\n+      global.document.getElementById('csacontainer').style.height;","path":"ads/google/csa.js","position":85,"original_position":85,"commit_id":"3186351bd9c4e9f28304fa8a7047665f3cce3572","original_commit_id":"3186351bd9c4e9f28304fa8a7047665f3cce3572","user":{"login":"lannka","id":8496897,"avatar_url":"https://avatars.githubusercontent.com/u/8496897?v=3","gravatar_id":"","url":"https://api.github.com/users/lannka","html_url":"https://github.com/lannka","followers_url":"https://api.github.com/users/lannka/followers","following_url":"https://api.github.com/users/lannka/following{/other_user}","gists_url":"https://api.github.com/users/lannka/gists{/gist_id}","starred_url":"https://api.github.com/users/lannka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lannka/subscriptions","organizations_url":"https://api.github.com/users/lannka/orgs","repos_url":"https://api.github.com/users/lannka/repos","events_url":"https://api.github.com/users/lannka/events{/privacy}","received_events_url":"https://api.github.com/users/lannka/received_events","type":"User","site_admin":false},"body":"indent 4 spaces for line break.","created_at":"2016-12-16T18:08:43Z","updated_at":"2016-12-16T18:24:00Z","html_url":"https://github.com/ampproject/amphtml/pull/6518#discussion_r92858089","pull_request_url":"https://api.github.com/repos/ampproject/amphtml/pulls/6518","_links":{"self":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/comments/92858089"},"html":{"href":"https://github.com/ampproject/amphtml/pull/6518#discussion_r92858089"},"pull_request":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/6518"}}},"pull_request":{"url":"https://api.github.com/repos/ampproject/amphtml/pulls/6518","id":96973915,"html_url":"https://github.com/ampproject/amphtml/pull/6518","diff_url":"https://github.com/ampproject/amphtml/pull/6518.diff","patch_url":"https://github.com/ampproject/amphtml/pull/6518.patch","issue_url":"https://api.github.com/repos/ampproject/amphtml/issues/6518","number":6518,"state":"open","locked":false,"title":"Integrate Google AdSense for Search and Adsense for Shopping (on the Custom Search Ads protocol) with AMP","user":{"login":"megankj","id":20996958,"avatar_url":"https://avatars.githubusercontent.com/u/20996958?v=3","gravatar_id":"","url":"https://api.github.com/users/megankj","html_url":"https://github.com/megankj","followers_url":"https://api.github.com/users/megankj/followers","following_url":"https://api.github.com/users/megankj/following{/other_user}","gists_url":"https://api.github.com/users/megankj/gists{/gist_id}","starred_url":"https://api.github.com/users/megankj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/megankj/subscriptions","organizations_url":"https://api.github.com/users/megankj/orgs","repos_url":"https://api.github.com/users/megankj/repos","events_url":"https://api.github.com/users/megankj/events{/privacy}","received_events_url":"https://api.github.com/users/megankj/received_events","type":"User","site_admin":false},"body":"This change allows publishers to request Google AdSense for Search and AdSense for Shopping on the Custom Search Ads protocol.  We introduce a new AMP ad type, called \"csa\". \r\n\r\n#2659","created_at":"2016-12-07T17:49:49Z","updated_at":"2016-12-16T18:24:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":{"login":"lannka","id":8496897,"avatar_url":"https://avatars.githubusercontent.com/u/8496897?v=3","gravatar_id":"","url":"https://api.github.com/users/lannka","html_url":"https://github.com/lannka","followers_url":"https://api.github.com/users/lannka/followers","following_url":"https://api.github.com/users/lannka/following{/other_user}","gists_url":"https://api.github.com/users/lannka/gists{/gist_id}","starred_url":"https://api.github.com/users/lannka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lannka/subscriptions","organizations_url":"https://api.github.com/users/lannka/orgs","repos_url":"https://api.github.com/users/lannka/repos","events_url":"https://api.github.com/users/lannka/events{/privacy}","received_events_url":"https://api.github.com/users/lannka/received_events","type":"User","site_admin":false},"assignees":[{"login":"lannka","id":8496897,"avatar_url":"https://avatars.githubusercontent.com/u/8496897?v=3","gravatar_id":"","url":"https://api.github.com/users/lannka","html_url":"https://github.com/lannka","followers_url":"https://api.github.com/users/lannka/followers","following_url":"https://api.github.com/users/lannka/following{/other_user}","gists_url":"https://api.github.com/users/lannka/gists{/gist_id}","starred_url":"https://api.github.com/users/lannka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lannka/subscriptions","organizations_url":"https://api.github.com/users/lannka/orgs","repos_url":"https://api.github.com/users/lannka/repos","events_url":"https://api.github.com/users/lannka/events{/privacy}","received_events_url":"https://api.github.com/users/lannka/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ampproject/amphtml/pulls/6518/commits","review_comments_url":"https://api.github.com/repos/ampproject/amphtml/pulls/6518/comments","review_comment_url":"https://api.github.com/repos/ampproject/amphtml/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ampproject/amphtml/issues/6518/comments","statuses_url":"https://api.github.com/repos/ampproject/amphtml/statuses/3186351bd9c4e9f28304fa8a7047665f3cce3572","head":{"label":"megankj:csa-integration","ref":"csa-integration","sha":"3186351bd9c4e9f28304fa8a7047665f3cce3572","user":{"login":"megankj","id":20996958,"avatar_url":"https://avatars.githubusercontent.com/u/20996958?v=3","gravatar_id":"","url":"https://api.github.com/users/megankj","html_url":"https://github.com/megankj","followers_url":"https://api.github.com/users/megankj/followers","following_url":"https://api.github.com/users/megankj/following{/other_user}","gists_url":"https://api.github.com/users/megankj/gists{/gist_id}","starred_url":"https://api.github.com/users/megankj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/megankj/subscriptions","organizations_url":"https://api.github.com/users/megankj/orgs","repos_url":"https://api.github.com/users/megankj/repos","events_url":"https://api.github.com/users/megankj/events{/privacy}","received_events_url":"https://api.github.com/users/megankj/received_events","type":"User","site_admin":false},"repo":{"id":72797955,"name":"amphtml","full_name":"megankj/amphtml","owner":{"login":"megankj","id":20996958,"avatar_url":"https://avatars.githubusercontent.com/u/20996958?v=3","gravatar_id":"","url":"https://api.github.com/users/megankj","html_url":"https://github.com/megankj","followers_url":"https://api.github.com/users/megankj/followers","following_url":"https://api.github.com/users/megankj/following{/other_user}","gists_url":"https://api.github.com/users/megankj/gists{/gist_id}","starred_url":"https://api.github.com/users/megankj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/megankj/subscriptions","organizations_url":"https://api.github.com/users/megankj/orgs","repos_url":"https://api.github.com/users/megankj/repos","events_url":"https://api.github.com/users/megankj/events{/privacy}","received_events_url":"https://api.github.com/users/megankj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/megankj/amphtml","description":"AMP HTML source code, samples, and documentation.  See below for more info.","fork":true,"url":"https://api.github.com/repos/megankj/amphtml","forks_url":"https://api.github.com/repos/megankj/amphtml/forks","keys_url":"https://api.github.com/repos/megankj/amphtml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/megankj/amphtml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/megankj/amphtml/teams","hooks_url":"https://api.github.com/repos/megankj/amphtml/hooks","issue_events_url":"https://api.github.com/repos/megankj/amphtml/issues/events{/number}","events_url":"https://api.github.com/repos/megankj/amphtml/events","assignees_url":"https://api.github.com/repos/megankj/amphtml/assignees{/user}","branches_url":"https://api.github.com/repos/megankj/amphtml/branches{/branch}","tags_url":"https://api.github.com/repos/megankj/amphtml/tags","blobs_url":"https://api.github.com/repos/megankj/amphtml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/megankj/amphtml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/megankj/amphtml/git/refs{/sha}","trees_url":"https://api.github.com/repos/megankj/amphtml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/megankj/amphtml/statuses/{sha}","languages_url":"https://api.github.com/repos/megankj/amphtml/languages","stargazers_url":"https://api.github.com/repos/megankj/amphtml/stargazers","contributors_url":"https://api.github.com/repos/megankj/amphtml/contributors","subscribers_url":"https://api.github.com/repos/megankj/amphtml/subscribers","subscription_url":"https://api.github.com/repos/megankj/amphtml/subscription","commits_url":"https://api.github.com/repos/megankj/amphtml/commits{/sha}","git_commits_url":"https://api.github.com/repos/megankj/amphtml/git/commits{/sha}","comments_url":"https://api.github.com/repos/megankj/amphtml/comments{/number}","issue_comment_url":"https://api.github.com/repos/megankj/amphtml/issues/comments{/number}","contents_url":"https://api.github.com/repos/megankj/amphtml/contents/{+path}","compare_url":"https://api.github.com/repos/megankj/amphtml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/megankj/amphtml/merges","archive_url":"https://api.github.com/repos/megankj/amphtml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/megankj/amphtml/downloads","issues_url":"https://api.github.com/repos/megankj/amphtml/issues{/number}","pulls_url":"https://api.github.com/repos/megankj/amphtml/pulls{/number}","milestones_url":"https://api.github.com/repos/megankj/amphtml/milestones{/number}","notifications_url":"https://api.github.com/repos/megankj/amphtml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/megankj/amphtml/labels{/name}","releases_url":"https://api.github.com/repos/megankj/amphtml/releases{/id}","deployments_url":"https://api.github.com/repos/megankj/amphtml/deployments","created_at":"2016-11-04T00:03:48Z","updated_at":"2016-11-04T00:03:53Z","pushed_at":"2016-12-16T05:13:33Z","git_url":"git://github.com/megankj/amphtml.git","ssh_url":"git@github.com:megankj/amphtml.git","clone_url":"https://github.com/megankj/amphtml.git","svn_url":"https://github.com/megankj/amphtml","homepage":"https://ampproject.org","size":218458,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ampproject:master","ref":"master","sha":"8894ba83bce85932e7ad060dde790f8a4d11f7a3","user":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars.githubusercontent.com/u/14114390?v=3","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://avatars.githubusercontent.com/u/14114390?v=3","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":"2016-12-16T16:15:59Z","pushed_at":"2016-12-16T18:21:58Z","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://ampproject.org","size":220293,"stargazers_count":9233,"watchers_count":9233,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1444,"mirror_url":null,"open_issues_count":1040,"forks":1444,"open_issues":1040,"watchers":9233,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/6518"},"html":{"href":"https://github.com/ampproject/amphtml/pull/6518"},"issue":{"href":"https://api.github.com/repos/ampproject/amphtml/issues/6518"},"comments":{"href":"https://api.github.com/repos/ampproject/amphtml/issues/6518/comments"},"review_comments":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/6518/comments"},"review_comment":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/6518/commits"},"statuses":{"href":"https://api.github.com/repos/ampproject/amphtml/statuses/3186351bd9c4e9f28304fa8a7047665f3cce3572"}}}}
{"actor":{"display_login":"lannka"}}