GitHub PullRequestReviewCommentEvent at 2014-07-01 16:53:59
Repository: addon-sdk
Actor: jsantell
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/addon-sdk/pulls/comments/14415605","id":14415605,"diff_hunk":"@@ -16,11 +30,41 @@ let { emit } = require(\"./core\");\n function open(target, type, options) {\n   let output = {};\n   let capture = options && options.capture ? true : false;\n+  let listener = (event) => emit(output, \"data\", event);\n+\n+  // `open` is currently used only on DOM Window objects, however it was made\n+  // to be used to any kind of `target` that supports `addEventListener`,\n+  // therefore is safer get the `window` from the `target` instead assuming\n+  // that `target` is the `window`.\n+  let window = getWindowFrom(target);\n+\n+  // If we're not able to get a `window` from `target`, there is something\n+  // wrong. We cannot add listeners that can leak later, or results in\n+  // \"dead object\" exception.\n+  // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1001833\n+  if (window)\n+    throw new Error(\"Unable to obtain the owner window from the target given.\");\n \n-  target.addEventListener(type, function(event) {\n-    emit(output, \"data\", event);\n-  }, capture);\n+  let cleaners = listeners.get(window) || [];\n+  cleaners.push(() => target.removeEventListener(type, listener, capture));\n+\n+  listeners.set(window, cleaners);\n+\n+  // We need to remove from our map the `window` once is closed, to prevent\n+  // memory leak\n+  window.addEventListener(\"DOMWindowClose\", removeFromListeners);","path":"lib/sdk/event/dom.js","position":51,"original_position":51,"commit_id":"ce894adf59af7561a3a04da084f87e06543540f2","original_commit_id":"ce894adf59af7561a3a04da084f87e06543540f2","user":{"login":"jsantell","id":641267,"avatar_url":"https://avatars.githubusercontent.com/u/641267?","gravatar_id":"595768eaea3925799b659b979de0f93a","url":"https://api.github.com/users/jsantell","html_url":"https://github.com/jsantell","followers_url":"https://api.github.com/users/jsantell/followers","following_url":"https://api.github.com/users/jsantell/following{/other_user}","gists_url":"https://api.github.com/users/jsantell/gists{/gist_id}","starred_url":"https://api.github.com/users/jsantell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsantell/subscriptions","organizations_url":"https://api.github.com/users/jsantell/orgs","repos_url":"https://api.github.com/users/jsantell/repos","events_url":"https://api.github.com/users/jsantell/events{/privacy}","received_events_url":"https://api.github.com/users/jsantell/received_events","type":"User","site_admin":false},"body":"Do we also need to remove this listener on the window in `removeFromListeners`?","created_at":"2014-07-01T16:53:59Z","updated_at":"2014-07-01T16:53:59Z","html_url":"https://github.com/mozilla/addon-sdk/pull/1476#discussion_r14415605","pull_request_url":"https://api.github.com/repos/mozilla/addon-sdk/pulls/1476","_links":{"self":{"href":"https://api.github.com/repos/mozilla/addon-sdk/pulls/comments/14415605"},"html":{"href":"https://github.com/mozilla/addon-sdk/pull/1476#discussion_r14415605"},"pull_request":{"href":"https://api.github.com/repos/mozilla/addon-sdk/pulls/1476"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/addon-sdk/pulls/1476","id":15209705,"html_url":"https://github.com/mozilla/addon-sdk/pull/1476","diff_url":"https://github.com/mozilla/addon-sdk/pull/1476.diff","patch_url":"https://github.com/mozilla/addon-sdk/pull/1476.patch","issue_url":"https://api.github.com/repos/mozilla/addon-sdk/issues/1476","number":1476,"state":"open","title":"Bug 1001833 - \"TypeError: can't access dead object\" due leaks of event/dom module","user":{"login":"ZER0","id":283718,"avatar_url":"https://avatars.githubusercontent.com/u/283718?","gravatar_id":"a907812e22b64f65caf8eaa92b651467","url":"https://api.github.com/users/ZER0","html_url":"https://github.com/ZER0","followers_url":"https://api.github.com/users/ZER0/followers","following_url":"https://api.github.com/users/ZER0/following{/other_user}","gists_url":"https://api.github.com/users/ZER0/gists{/gist_id}","starred_url":"https://api.github.com/users/ZER0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZER0/subscriptions","organizations_url":"https://api.github.com/users/ZER0/orgs","repos_url":"https://api.github.com/users/ZER0/repos","events_url":"https://api.github.com/users/ZER0/events{/privacy}","received_events_url":"https://api.github.com/users/ZER0/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-04-27T07:03:50Z","updated_at":"2014-07-01T16:53:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"545559251ac1856cd44dcc45cb87a7b870d86884","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/addon-sdk/pulls/1476/commits","review_comments_url":"https://api.github.com/repos/mozilla/addon-sdk/pulls/1476/comments","review_comment_url":"https://api.github.com/repos/mozilla/addon-sdk/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mozilla/addon-sdk/issues/1476/comments","statuses_url":"https://api.github.com/repos/mozilla/addon-sdk/statuses/ce894adf59af7561a3a04da084f87e06543540f2","head":{"label":"ZER0:dead-object/1001833","ref":"dead-object/1001833","sha":"ce894adf59af7561a3a04da084f87e06543540f2","user":{"login":"ZER0","id":283718,"avatar_url":"https://avatars.githubusercontent.com/u/283718?","gravatar_id":"a907812e22b64f65caf8eaa92b651467","url":"https://api.github.com/users/ZER0","html_url":"https://github.com/ZER0","followers_url":"https://api.github.com/users/ZER0/followers","following_url":"https://api.github.com/users/ZER0/following{/other_user}","gists_url":"https://api.github.com/users/ZER0/gists{/gist_id}","starred_url":"https://api.github.com/users/ZER0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZER0/subscriptions","organizations_url":"https://api.github.com/users/ZER0/orgs","repos_url":"https://api.github.com/users/ZER0/repos","events_url":"https://api.github.com/users/ZER0/events{/privacy}","received_events_url":"https://api.github.com/users/ZER0/received_events","type":"User","site_admin":false},"repo":{"id":1584102,"name":"addon-sdk","full_name":"ZER0/addon-sdk","owner":{"login":"ZER0","id":283718,"avatar_url":"https://avatars.githubusercontent.com/u/283718?","gravatar_id":"a907812e22b64f65caf8eaa92b651467","url":"https://api.github.com/users/ZER0","html_url":"https://github.com/ZER0","followers_url":"https://api.github.com/users/ZER0/followers","following_url":"https://api.github.com/users/ZER0/following{/other_user}","gists_url":"https://api.github.com/users/ZER0/gists{/gist_id}","starred_url":"https://api.github.com/users/ZER0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZER0/subscriptions","organizations_url":"https://api.github.com/users/ZER0/orgs","repos_url":"https://api.github.com/users/ZER0/repos","events_url":"https://api.github.com/users/ZER0/events{/privacy}","received_events_url":"https://api.github.com/users/ZER0/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ZER0/addon-sdk","description":"The Add-on SDK repository.","fork":true,"url":"https://api.github.com/repos/ZER0/addon-sdk","forks_url":"https://api.github.com/repos/ZER0/addon-sdk/forks","keys_url":"https://api.github.com/repos/ZER0/addon-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ZER0/addon-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ZER0/addon-sdk/teams","hooks_url":"https://api.github.com/repos/ZER0/addon-sdk/hooks","issue_events_url":"https://api.github.com/repos/ZER0/addon-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/ZER0/addon-sdk/events","assignees_url":"https://api.github.com/repos/ZER0/addon-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/ZER0/addon-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/ZER0/addon-sdk/tags","blobs_url":"https://api.github.com/repos/ZER0/addon-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ZER0/addon-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ZER0/addon-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/ZER0/addon-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ZER0/addon-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/ZER0/addon-sdk/languages","stargazers_url":"https://api.github.com/repos/ZER0/addon-sdk/stargazers","contributors_url":"https://api.github.com/repos/ZER0/addon-sdk/contributors","subscribers_url":"https://api.github.com/repos/ZER0/addon-sdk/subscribers","subscription_url":"https://api.github.com/repos/ZER0/addon-sdk/subscription","commits_url":"https://api.github.com/repos/ZER0/addon-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/ZER0/addon-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/ZER0/addon-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/ZER0/addon-sdk/issues/comments/{number}","contents_url":"https://api.github.com/repos/ZER0/addon-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/ZER0/addon-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ZER0/addon-sdk/merges","archive_url":"https://api.github.com/repos/ZER0/addon-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ZER0/addon-sdk/downloads","issues_url":"https://api.github.com/repos/ZER0/addon-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/ZER0/addon-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/ZER0/addon-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/ZER0/addon-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ZER0/addon-sdk/labels{/name}","releases_url":"https://api.github.com/repos/ZER0/addon-sdk/releases{/id}","created_at":"2011-04-07T19:58:10Z","updated_at":"2014-05-12T20:49:25Z","pushed_at":"2014-06-27T21:38:19Z","git_url":"git://github.com/ZER0/addon-sdk.git","ssh_url":"git@github.com:ZER0/addon-sdk.git","clone_url":"https://github.com/ZER0/addon-sdk.git","svn_url":"https://github.com/ZER0/addon-sdk","homepage":"https://wiki.mozilla.org/Labs/Jetpack","size":16886,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"2a45fca8530f3b00ba2e685c345369f91a75e98a","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?","gravatar_id":"9ba739c8f3288e256b13553e4d257b5e","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":748030,"name":"addon-sdk","full_name":"mozilla/addon-sdk","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?","gravatar_id":"9ba739c8f3288e256b13553e4d257b5e","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/addon-sdk","description":"The Add-on SDK repository.","fork":false,"url":"https://api.github.com/repos/mozilla/addon-sdk","forks_url":"https://api.github.com/repos/mozilla/addon-sdk/forks","keys_url":"https://api.github.com/repos/mozilla/addon-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/addon-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/addon-sdk/teams","hooks_url":"https://api.github.com/repos/mozilla/addon-sdk/hooks","issue_events_url":"https://api.github.com/repos/mozilla/addon-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/addon-sdk/events","assignees_url":"https://api.github.com/repos/mozilla/addon-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/addon-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/addon-sdk/tags","blobs_url":"https://api.github.com/repos/mozilla/addon-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/addon-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/addon-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/addon-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/addon-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/addon-sdk/languages","stargazers_url":"https://api.github.com/repos/mozilla/addon-sdk/stargazers","contributors_url":"https://api.github.com/repos/mozilla/addon-sdk/contributors","subscribers_url":"https://api.github.com/repos/mozilla/addon-sdk/subscribers","subscription_url":"https://api.github.com/repos/mozilla/addon-sdk/subscription","commits_url":"https://api.github.com/repos/mozilla/addon-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/addon-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/addon-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/addon-sdk/issues/comments/{number}","contents_url":"https://api.github.com/repos/mozilla/addon-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/addon-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/addon-sdk/merges","archive_url":"https://api.github.com/repos/mozilla/addon-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/addon-sdk/downloads","issues_url":"https://api.github.com/repos/mozilla/addon-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/addon-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/addon-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/addon-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/addon-sdk/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/addon-sdk/releases{/id}","created_at":"2010-06-30T00:38:20Z","updated_at":"2014-07-01T14:45:36Z","pushed_at":"2014-07-01T15:52:51Z","git_url":"git://github.com/mozilla/addon-sdk.git","ssh_url":"git@github.com:mozilla/addon-sdk.git","clone_url":"https://github.com/mozilla/addon-sdk.git","svn_url":"https://github.com/mozilla/addon-sdk","homepage":"https://wiki.mozilla.org/Labs/Jetpack","size":44301,"stargazers_count":461,"watchers_count":461,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":221,"mirror_url":null,"open_issues_count":83,"forks":221,"open_issues":83,"watchers":461,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/addon-sdk/pulls/1476"},"html":{"href":"https://github.com/mozilla/addon-sdk/pull/1476"},"issue":{"href":"https://api.github.com/repos/mozilla/addon-sdk/issues/1476"},"comments":{"href":"https://api.github.com/repos/mozilla/addon-sdk/issues/1476/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/addon-sdk/pulls/1476/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/addon-sdk/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mozilla/addon-sdk/pulls/1476/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/addon-sdk/statuses/ce894adf59af7561a3a04da084f87e06543540f2"}}}}