GitHub PullRequestReviewCommentEvent at 2014-03-02 10:52:52
Repository: gecko-dev
Actor: ekr
Payload: {"comment":{"url":"https://api.github.com/repos/adamroach/gecko-dev/pulls/comments/10194957","id":10194957,"diff_hunk":"@@ -0,0 +1,64 @@\n+/* This Source Code Form is subject to the terms of the Mozilla Public\n+ * License, v. 2.0. If a copy of the MPL was not distributed with this\n+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n+\n+\"use strict\";\n+\n+/**\n+ * A privileged wrapper around an iframe. The wrapper injects a\n+ * MessageChannel into the iframe's JS context for communication\n+ * between the iframe and the wrapper.\n+ *\n+ * @param templateId The \"id\" attribute of the template that\n+ *                   is to be injected into the iframe as its\n+ *                   body contents.\n+ *\n+ * @param iframeId   The \"id\" attribute of the iframe that the\n+ *                   wrapper is to inject the contents into and\n+ *                   communicate with.\n+ */\n+\n+function LoopWrapper(templateId, iframeId) {\n+  this.template = document.getElementById(templateId);\n+  this.iframe = document.getElementById(iframeId);\n+  var documentFragment = this.template.content.cloneNode(true);\n+  this.iframe.contentDocument.body.appendChild(documentFragment);\n+  this.messageChannel = this.iframe.contentWindow.MessageChannel();\n+  Object.defineProperty(this.iframe.contentWindow.wrappedJSObject,\n+                          \"wrapperPort\",\n+                          {\n+                            value: this.messageChannel.port2\n+                          });\n+  this.messageChannel.port1.onmessage = this.processMessage.bind(this);\n+}\n+\n+LoopWrapper.prototype = {\n+  /**\n+   * Send a message to the wrapped iframe\n+   *\n+   * @param msg  Object representing the message to send. Must\n+   *             contain an \"operation\" attribute. Additional\n+   *             attributes are optional, and evaluated based on\n+   *             the operation.\n+   */\n+  sendMessage: function(msg) {\n+    this.messageChannel.port1.postMessage(JSON.stringify(msg));\n+  },\n+\n+  /**\n+   * Handle a message received from the wrapped iframe\n+   *\n+   * @param msg  JSON-serialized representation of the message. Must\n+   *             contain an \"operation\" attribute. Additional\n+   *             attributes are optional, and evaluated based on\n+   *             the operation.\n+   */\n+  processMessage: function(msg) {\n+    var message = JSON.parse(msg.data);\n+    console.log(\"Received message from content frame: \" + msg.data);\n+    if (message.operation == \"init_done\") {","path":"browser/components/loop/content/wrapper.js","position":59,"original_position":59,"commit_id":"219e8239e38f67dd3fc995c95623a9871a446043","original_commit_id":"219e8239e38f67dd3fc995c95623a9871a446043","user":{"login":"ekr","id":1111457,"avatar_url":"https://avatars.githubusercontent.com/u/1111457","gravatar_id":"f3b5a842a3ef240e7ba5b3efab681531","url":"https://api.github.com/users/ekr","html_url":"https://github.com/ekr","followers_url":"https://api.github.com/users/ekr/followers","following_url":"https://api.github.com/users/ekr/following{/other_user}","gists_url":"https://api.github.com/users/ekr/gists{/gist_id}","starred_url":"https://api.github.com/users/ekr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ekr/subscriptions","organizations_url":"https://api.github.com/users/ekr/orgs","repos_url":"https://api.github.com/users/ekr/repos","events_url":"https://api.github.com/users/ekr/events{/privacy}","received_events_url":"https://api.github.com/users/ekr/received_events","type":"User","site_admin":false},"body":"Use === for comparisons where possible.","created_at":"2014-03-02T10:52:52Z","updated_at":"2014-03-02T10:52:52Z","html_url":"https://github.com/adamroach/gecko-dev/pull/3#discussion_r10194957","pull_request_url":"https://api.github.com/repos/adamroach/gecko-dev/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/adamroach/gecko-dev/pulls/comments/10194957"},"html":{"href":"https://github.com/adamroach/gecko-dev/pull/3#discussion_r10194957"},"pull_request":{"href":"https://api.github.com/repos/adamroach/gecko-dev/pulls/3"}}}}