blob: 4804200915f3657b74d5b693168966b715800481 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Tests that nsBrowserGlue correctly restores default bookmarks if database is
* corrupt, nor a JSON backup nor bookmarks.html are available.
*/
Components.utils.import("resource://gre/modules/AppConstants.jsm");
function run_test() {
// Remove bookmarks.html from profile.
remove_bookmarks_html();
// Remove JSON backup from profile.
remove_all_JSON_backups();
run_next_test();
}
add_task(function* () {
// Create a corrupt database.
yield createCorruptDB();
// Initialize nsBrowserGlue before Places.
Cc["@mozilla.org/browser/browserglue;1"].getService(Ci.nsISupports);
// Check the database was corrupt.
// nsBrowserGlue uses databaseStatus to manage initialization.
Assert.equal(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_CORRUPT);
// The test will continue once import has finished and smart bookmarks
// have been created.
yield promiseTopicObserved("places-browser-init-complete");
let bm = yield PlacesUtils.bookmarks.fetch({
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: 0
});
yield checkItemHasAnnotation(bm.guid, SMART_BOOKMARKS_ANNO);
// Check that default bookmarks have been restored.
bm = yield PlacesUtils.bookmarks.fetch({
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
index: SMART_BOOKMARKS_ON_TOOLBAR
});
// Bug 1283076: Nightly bookmark points to Get Involved page, not Getting Started one
let chanTitle = AppConstants.NIGHTLY_BUILD ? "Get Involved" : "Getting Started";
do_check_eq(bm.title, chanTitle);
});
|