bug 837729 - don't create text-runs for JS source code loaded in a hidden-window iframe, and remove source text from the DOM as soon as we've extracted it. r=gavin,markh a=akeybl
authorJonathan Kew <jkew@mozilla.com>
Tue, 05 Feb 2013 09:18:15 +0000
changeset 127424 5385979f826d60f0f30418c956bc7cb19a4b494c
parent 127423 c7115618ac6ee8dc86f275620a76210639a8f214
child 127425 43710cb56191e9f2ea10280a34af67451c93706d
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin, markh, akeybl
bugs837729
milestone20.0a2
bug 837729 - don't create text-runs for JS source code loaded in a hidden-window iframe, and remove source text from the DOM as soon as we've extracted it. r=gavin,markh a=akeybl
toolkit/components/social/FrameWorker.jsm
--- a/toolkit/components/social/FrameWorker.jsm
+++ b/toolkit/components/social/FrameWorker.jsm
@@ -197,16 +197,20 @@ FrameWorker.prototype = {
       // no script, error out now rather than creating ports, etc
       let scriptText = workerWindow.document.body.textContent.trim();
       if (!scriptText) {
         Cu.reportError("FrameWorker: Empty worker script received");
         notifyWorkerError(worker);
         return;
       }
 
+      // now that we've got the script text, remove it from the DOM;
+      // no need for it to keep occupying memory there
+      workerWindow.document.body.textContent = "";
+
       // the iframe has loaded the js file as text - first inject the magic
       // port-handling code into the sandbox.
       try {
         Services.scriptloader.loadSubScript("resource://gre/modules/MessagePortBase.jsm", sandbox);
         Services.scriptloader.loadSubScript("resource://gre/modules/MessagePortWorker.js", sandbox);
       }
       catch (e) {
         Cu.reportError("FrameWorker: Error injecting port code into content side of the worker: " + e + "\n" + e.stack);
@@ -311,16 +315,18 @@ FrameWorker.prototype = {
 };
 
 function makeHiddenFrame() {
   let hiddenDoc = Services.appShell.hiddenDOMWindow.document;
   let iframe = hiddenDoc.createElementNS("http://www.w3.org/1999/xhtml", "iframe");
   iframe.setAttribute("mozframetype", "content");
   // allow-same-origin is necessary for localStorage to work in the sandbox.
   iframe.setAttribute("sandbox", "allow-same-origin");
+  // don't create text frames and runs for the JS source!
+  iframe.style.display = "none";
 
   hiddenDoc.documentElement.appendChild(iframe);
 
   // Disable some types of content
   let docShell = iframe.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDocShell);
   docShell.allowAuth = false;
   docShell.allowPlugins = false;
   docShell.allowImages = false;