Bug 1010255 - Fixing uncaught promise error in test_bookmarks_restore_notification.js. r=mak

This commit is contained in:
David Rajchenbach-Teller 2014-05-14 08:06:00 +02:00
parent 8552b7733b
commit a2bfabb74b
2 changed files with 14 additions and 16 deletions

View File

@ -179,9 +179,9 @@ this.BookmarkHTMLUtils = Object.freeze({
return Task.spawn(function* () {
notifyObservers(PlacesUtils.TOPIC_BOOKMARKS_RESTORE_BEGIN, aInitialImport);
try {
if (!(yield OS.File.exists(aFilePath)))
throw new Error("Cannot import from nonexisting html file");
if (!(yield OS.File.exists(aFilePath))) {
throw new Error("Cannot import from nonexisting html file: " + aFilePath);
}
let importer = new BookmarkImporter(aInitialImport);
yield importer.importFromURL(OS.Path.toFileURI(aFilePath));

View File

@ -91,7 +91,7 @@ var tests = [
folderId: null,
run: function () {
this.file = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
this.file.append("this file doesn't exist because nobody created it");
this.file.append("this file doesn't exist because nobody created it 1");
Task.spawn(function() {
try {
yield BookmarkJSONUtils.importFromFile(this.file, true);
@ -152,16 +152,15 @@ var tests = [
finalTopic: NSIOBSERVER_TOPIC_FAILED,
data: NSIOBSERVER_DATA_HTML,
folderId: null,
run: function () {
run: Task.async(function* () {
this.file = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
this.file.append("this file doesn't exist because nobody created it");
this.file.append("this file doesn't exist because nobody created it 2");
try {
BookmarkHTMLUtils.importFromFile(this.file, false)
.then(function onSuccess() do_throw("Should fail!"),
null);
yield BookmarkHTMLUtils.importFromFile(this.file, false);
do_throw("Should fail!");
}
catch (e) {}
}
}.bind(this))
},
{
@ -213,16 +212,15 @@ var tests = [
finalTopic: NSIOBSERVER_TOPIC_FAILED,
data: NSIOBSERVER_DATA_HTML_INIT,
folderId: null,
run: function () {
run: Task.async(function* () {
this.file = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
this.file.append("this file doesn't exist because nobody created it");
this.file.append("this file doesn't exist because nobody created it 3");
try {
BookmarkHTMLUtils.importFromFile(this.file, true)
.then(function onSuccess() do_throw("Should fail!"),
null);
yield BookmarkHTMLUtils.importFromFile(this.file, true);
do_throw("Should fail!");
}
catch (e) {}
}
}.bind(this))
}
];