Bug 1400562 - BackgroundPageThumbs.captureIfMissing leaks when hidden capturing_disabled pref is true
MozReview-Commit-ID: 6zb3uBCYTk5
--- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
+++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
@@ -100,16 +100,23 @@ const BackgroundPageThumbs = {
* @param url The URL to capture.
* @param options An optional object that configures the capture. See
* capture() for description.
* unloadingPromise This option is resolved when the calling context is
* unloading, so things can be cleaned up to avoid leak.
* @return {Promise} A Promise that resolves when this task completes
*/
async captureIfMissing(url, options = {}) {
+ // Short circuit this function if pref is enabled, or else we leak observers.
+ // See Bug 1400562
+ if (!PageThumbs._prefEnabled()) {
+ if (options.onDone)
+ options.onDone(url);
+ return url;
+ }
// The fileExistsForURL call is an optimization, potentially but unlikely
// incorrect, and no big deal when it is. After the capture is done, we
// atomically test whether the file exists before writing it.
let exists = await PageThumbsStorage.fileExistsForURL(url);
if (exists) {
if (options.onDone) {
options.onDone(url);
}