Bug 1229195: explicitly link 'content' to the frame script global scope to prevent out-of-scope errors. r=Standard8, a=sylvestre
☠☠ backed out by c860a0060c09 ☠ ☠
authorMike de Boer <mdeboer@mozilla.com>
Tue, 16 Feb 2016 10:30:11 +0000
changeset 311272 a4b809b4d3b1a8667d8488c95c8ca5fb89ac4717
parent 311271 e5952737bbba92cd6c3c413977d19387940162ca
child 311273 df507d35f1dbfad036bc418e4b26b9da2f7ca0ee
push id5624
push usermbanner@mozilla.com
push dateTue, 16 Feb 2016 13:09:03 +0000
treeherdermozilla-beta@149fdfdb40d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, sylvestre
bugs1229195
milestone45.0
Bug 1229195: explicitly link 'content' to the frame script global scope to prevent out-of-scope errors. r=Standard8, a=sylvestre --HG-- extra : transplant_source : %2AB%EE%96tq%11X%DA-%CD%B7g%9C%EC%A2%8A%FC%C8%CC
browser/base/content/social-content.js
--- a/browser/base/content/social-content.js
+++ b/browser/base/content/social-content.js
@@ -6,32 +6,37 @@
 /* This content script should work in any browser or iframe and should not
  * depend on the frame being contained in tabbrowser. */
 
 var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
+// Tie `content` to this frame scripts' global scope explicitly. If we don't, then
+// `content` might be out of eval's scope and GC'ed before this script is done.
+// See bug 1229195 for empirical proof.
+var gContent = content;
+
 // social frames are always treated as app tabs
 docShell.isAppTab = true;
 
 var gDOMContentLoaded = false;
 addEventListener("DOMContentLoaded", function() {
   gDOMContentLoaded = true;
   sendAsyncMessage("DOMContentLoaded");
 });
 var gDOMTitleChangedByUs = false;
 addEventListener("DOMTitleChanged", function(e) {
   if (!gDOMTitleChangedByUs) {
     sendAsyncMessage("DOMTitleChanged", {
       title: e.target.title
     });
-    gDOMTitleChangedByUs = false;
   }
+  gDOMTitleChangedByUs = false;
 });
 
 // Error handling class used to listen for network errors in the social frames
 // and replace them with a social-specific error page
 SocialErrorListener = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMEventListener,
                                          Ci.nsIWebProgressListener,
                                          Ci.nsISupportsWeakReference,