From 3216b07af44a5374617a1402412044d3b65c2163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A3o=20Gottwald?= Date: Thu, 26 Jan 2012 13:09:45 +0100 Subject: [PATCH] Bug 720984 - contentAreaUtils.js: getTargetFile leaks gDownloadLastDir into the global scope. r=gavin --- toolkit/content/contentAreaUtils.js | 5 +++-- .../tests/unit/test_privatebrowsing_downloadLastDir_c.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/toolkit/content/contentAreaUtils.js b/toolkit/content/contentAreaUtils.js index 731f59464b1e..4024d53aae62 100644 --- a/toolkit/content/contentAreaUtils.js +++ b/toolkit/content/contentAreaUtils.js @@ -563,8 +563,9 @@ function initFileInfo(aFI, aURL, aURLCharset, aDocument, */ function getTargetFile(aFpP, /* optional */ aSkipPrompt, /* optional */ aRelatedURI) { - if (typeof gDownloadLastDir != "object") - Components.utils.import("resource://gre/modules/DownloadLastDir.jsm"); + if (!getTargetFile.gDownloadLastDir) + Components.utils.import("resource://gre/modules/DownloadLastDir.jsm", getTargetFile); + var gDownloadLastDir = getTargetFile.gDownloadLastDir; var prefs = getPrefsBrowserDownload("browser.download."); var useDownloadDir = prefs.getBoolPref("useDownloadDir"); diff --git a/toolkit/content/tests/unit/test_privatebrowsing_downloadLastDir_c.js b/toolkit/content/tests/unit/test_privatebrowsing_downloadLastDir_c.js index b7c963c52b7e..df85c01ef3cb 100644 --- a/toolkit/content/tests/unit/test_privatebrowsing_downloadLastDir_c.js +++ b/toolkit/content/tests/unit/test_privatebrowsing_downloadLastDir_c.js @@ -43,6 +43,7 @@ function loadUtilsScript() { let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. getService(Ci.mozIJSSubScriptLoader); loader.loadSubScript("chrome://global/content/contentAreaUtils.js"); + Components.utils.import("resource://gre/modules/DownloadLastDir.jsm"); } do_get_profile();