54 "http://example.com/1",
55 "http://example.com/2",
56 "http://example.com/3",
57 "http://example.com/4",
58 "http://example.com/5",
75 desc:
"JSON restore: normal restore should succeed",
83 PlacesUtils.backupBookmarksToFile(this.
file);
86 PlacesUtils.restoreBookmarksFromJSONFile(this.
file);
89 do_throw(
" Restore should not have failed");
95 desc:
"JSON restore: empty file should succeed",
101 this.
file =
createFile(
"bookmarks-test_restoreNotification.json");
103 PlacesUtils.restoreBookmarksFromJSONFile(this.
file);
106 do_throw(
" Restore should not have failed");
112 desc:
"JSON restore: nonexisting file should fail",
119 this.
file.append(
"this file doesn't exist because nobody created it");
121 PlacesUtils.restoreBookmarksFromJSONFile(this.
file);
122 do_throw(
" Restore should have failed");
129 desc:
"HTML restore: normal restore should succeed",
135 this.
file =
createFile(
"bookmarks-test_restoreNotification.html");
143 do_throw(
" Restore should not have failed");
149 desc:
"HTML restore: empty file should succeed",
155 this.
file =
createFile(
"bookmarks-test_restoreNotification.init.html");
160 do_throw(
" Restore should not have failed");
166 desc:
"HTML restore: nonexisting file should fail",
173 this.
file.append(
"this file doesn't exist because nobody created it");
176 do_throw(
" Restore should have failed");
183 desc:
"HTML initial restore: normal restore should succeed",
189 this.
file =
createFile(
"bookmarks-test_restoreNotification.init.html");
197 do_throw(
" Restore should not have failed");
203 desc:
"HTML initial restore: empty file should succeed",
209 this.
file =
createFile(
"bookmarks-test_restoreNotification.init.html");
214 do_throw(
" Restore should not have failed");
220 desc:
"HTML initial restore: nonexisting file should fail",
227 this.
file.append(
"this file doesn't exist because nobody created it");
230 do_throw(
" Restore should have failed");
237 desc:
"HTML restore into folder: normal restore should succeed",
242 this.
file =
createFile(
"bookmarks-test_restoreNotification.html");
246 this.folderId =
bmsvc.createFolder(
bmsvc.unfiledBookmarksFolder,
248 bmsvc.DEFAULT_INDEX);
249 print(
" Sanity check: createFolder() should have succeeded");
250 do_check_true(this.folderId > 0);
252 importer.importHTMLFromFileToFolder(this.
file, this.folderId,
false);
255 do_throw(
" Restore should not have failed");
261 desc:
"HTML restore into folder: empty file should succeed",
266 this.
file =
createFile(
"bookmarks-test_restoreNotification.init.html");
267 this.folderId =
bmsvc.createFolder(
bmsvc.unfiledBookmarksFolder,
269 bmsvc.DEFAULT_INDEX);
270 print(
" Sanity check: createFolder() should have succeeded");
271 do_check_true(this.folderId > 0);
273 importer.importHTMLFromFileToFolder(this.
file, this.folderId,
false);
276 do_throw(
" Restore should not have failed");
282 desc:
"HTML restore into folder: nonexisting file should fail",
288 this.
file.append(
"this file doesn't exist because nobody created it");
289 this.folderId =
bmsvc.createFolder(
bmsvc.unfiledBookmarksFolder,
291 bmsvc.DEFAULT_INDEX);
292 print(
" Sanity check: createFolder() should have succeeded");
293 do_check_true(this.folderId > 0);
295 importer.importHTMLFromFileToFolder(this.
file, this.folderId,
false);
296 do_throw(
" Restore should have failed");
305 observe:
function _beginObserver(aSubject, aTopic,
aData) {
308 print(
" Observed " + aTopic);
309 print(
" Topic for current test should be what is expected");
312 print(
" Data for current test should be what is expected");
316 test.currTopic = test.finalTopic;
323 observe:
function _successAndFailedObserver(aSubject, aTopic,
aData) {
326 print(
" Observed " + aTopic);
327 print(
" Topic for current test should be what is expected");
330 print(
" Data for current test should be what is expected");
335 test.file.remove(
false);
342 do_check_eq(aSubject.QueryInterface(
Ci.nsISupportsPRInt64).data,
357 Components.utils.import(
"resource://gre/modules/utils.js");
359 var
bmsvc =
Cc[
"@mozilla.org/browser/nav-bookmarks-service;1"].
362 var
obssvc =
Cc[
"@mozilla.org/observer-service;1"].
365 var
importer =
Cc[
"@mozilla.org/browser/places/import-export-service;1"].
374 uris.forEach(
function (u) bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder,
387 var
hs =
Cc[
"@mozilla.org/browser/nav-history-service;1"].
389 var queries =
uris.map(
function (u) {
390 var q = hs.getNewQuery();
394 var
options = hs.getNewQueryOptions();
395 options.queryType = options.QUERY_TYPE_BOOKMARKS;
396 var root = hs.executeQueries(queries,
uris.length, options).root;
397 root.containerOpen =
true;
399 root.containerOpen =
false;
411 file.append(aBasename);
414 file.create(file.NORMAL_FILE_TYPE, 0666);
416 do_throw(
"Couldn't create file: " + aBasename);
425 if (currTestIndex >=
tests.length) {
433 print(
"Running test: " + test.desc);
do_check_eq(typeof PlacesUtils,"object")
const NSIOBSERVER_TOPIC_FAILED
function remove_all_bookmarks()
const NSIOBSERVER_DATA_HTML_INIT
getService(Ci.sbIFaceplateManager)
var successAndFailedObserver
const NSIOBSERVER_DATA_JSON
const NSIOBSERVER_TOPIC_BEGIN
function createFile(aBasename)
function checkBookmarksExist()
const NSIOBSERVER_TOPIC_SUCCESS
_updateTextAndScrollDataForFrame aData
const NSIOBSERVER_DATA_HTML
sbDeviceFirmwareAutoCheckForUpdate prototype observe