Bug 1229195: explicitly link 'content' to the frame script global scope to prevent out-of-scope errors. r=Standard8
--- 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,