Bug 901106 - Deserialize FastLoad scripts into the compilation scope, rather than the scope of the first document created. r=smaug
authorBobby Holley <bobbyholley@gmail.com>
Mon, 19 Aug 2013 16:24:26 -0700
changeset 143151 7187d131a09394dda1c01593fcad07535c898292
parent 143150 57ee0ba35de63fda5b9e026308583e46f2ca32e0
child 143152 14eeaab1e6680474403855fff10eb5d1362f4be2
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerssmaug
bugs901106
milestone26.0a1
Bug 901106 - Deserialize FastLoad scripts into the compilation scope, rather than the scope of the first document created. r=smaug This code dates back to 2003, and smaug and I both think it's probably a bug. In fact, it might cause leaks, because the prototype document would hold the script alive, the script would hold the document alive, and the document would hold the prototype document alive in the cache.
content/xul/document/src/nsXULContentSink.cpp
--- a/content/xul/document/src/nsXULContentSink.cpp
+++ b/content/xul/document/src/nsXULContentSink.cpp
@@ -981,18 +981,17 @@ XULContentSinkImpl::OpenScript(const PRU
           if (NS_FAILED(rv)) {
               return rv;
           }
 
           // Attempt to deserialize an out-of-line script from the FastLoad
           // file right away.  Otherwise we'll end up reloading the script and
           // corrupting the FastLoad file trying to serialize it, in the case
           // where it's already there.
-          if (globalObject)
-                script->DeserializeOutOfLine(nullptr, globalObject);
+          script->DeserializeOutOfLine(nullptr, mPrototype->GetScriptGlobalObject());
       }
 
       nsPrototypeArray* children = nullptr;
       rv = mContextStack.GetTopChildren(&children);
       if (NS_FAILED(rv)) {
           return rv;
       }