Bug 857201 - Restoring PageThumbsStorage.getFileForURL, with deprecation warning;r=ttaubert

This commit is contained in:
David Rajchenbach-Teller 2013-04-11 08:27:11 +02:00
parent e6fcd196f1
commit 8842213969
2 changed files with 19 additions and 0 deletions

View File

@ -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));
}
};

View File

@ -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) {