From 8842213969382581e3c01d24236e71ae1d3700d7 Mon Sep 17 00:00:00 2001 From: David Rajchenbach-Teller Date: Thu, 11 Apr 2013 08:27:11 +0200 Subject: [PATCH] Bug 857201 - Restoring PageThumbsStorage.getFileForURL, with deprecation warning;r=ttaubert --- toolkit/components/thumbnails/PageThumbs.jsm | 10 ++++++++++ .../test/browser_thumbnails_storage_migrate3.js | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/toolkit/components/thumbnails/PageThumbs.jsm b/toolkit/components/thumbnails/PageThumbs.jsm index d4b7922ada11..0f70d0d90809 100644 --- a/toolkit/components/thumbnails/PageThumbs.jsm +++ b/toolkit/components/thumbnails/PageThumbs.jsm @@ -60,6 +60,8 @@ XPCOMUtils.defineLazyGetter(this, "gUnicodeConverter", function () { XPCOMUtils.defineLazyModuleGetter(this, "Task", "resource://gre/modules/Task.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "Deprecated", + "resource://gre/modules/Deprecated.jsm"); /** * Utilities for dealing with promises and Task.jsm @@ -521,6 +523,14 @@ this.PageThumbsStorage = { for (let i = 0; i < aData.length; i++) hex += ("0" + aData.charCodeAt(i).toString(16)).slice(-2); return hex; + }, + + // Deprecated, please do not use + getFileForURL: function Storage_getFileForURL_DEPRECATED(aURL) { + Deprecated.warning("PageThumbs.getFileForURL is deprecated. Please use PageThumbs.getFilePathForURL and OS.File", + "https://developer.mozilla.org/docs/JavaScript_OS.File"); + // Note: Once this method has been removed, we can get rid of the dependency towards FileUtils + return new FileUtils.File(PageThumbsStorage.getFilePathForURL(aURL)); } }; diff --git a/toolkit/components/thumbnails/test/browser_thumbnails_storage_migrate3.js b/toolkit/components/thumbnails/test/browser_thumbnails_storage_migrate3.js index e6aacef1ae15..30071a38af64 100644 --- a/toolkit/components/thumbnails/test/browser_thumbnails_storage_migrate3.js +++ b/toolkit/components/thumbnails/test/browser_thumbnails_storage_migrate3.js @@ -69,6 +69,15 @@ function runTests() { // Check that our existing thumbnail wasn't overwritten. is(getFileContents(file), "no-overwrite-plz", "existing thumbnail was not overwritten"); + + // Sanity check: ensure that, until it is removed, deprecated + // function |getFileForURL| points to the same path as + // |getFilePathForURL|. + if ("getFileForURL" in PageThumbsStorage) { + let file = PageThumbsStorage.getFileForURL(URL); + is(file.path, PageThumbsStorage.getFilePathForURL(URL), + "Deprecated getFileForURL and getFilePathForURL return the same path"); + } } function changeLocation(aLocation, aNewDir) {