Closed Bug 525299 Opened 15 years ago Closed 15 years ago

Make Library left pane creation more robust

Categories

(Firefox :: Bookmarks & History, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 3.7a1

People

(Reporter: mak, Assigned: mak)

References

Details

Attachments

(1 file, 3 obsolete files)

Zpao sent me a db with this problem, while we should investigate if we can find what caused that, we should also make the left pane building code more robust to these kind of corruptions.

while touching that code would be nice to fix bug 523361 and bug 498162
And Bug 489681, uargh :(
Attached patch patch v1.0 (obsolete) — Splinter Review
this needs some test.
Flags: in-testsuite?
Blocks: 523361, 498162, 489681
Summary: Library leftpane can go corrupt with queries pointing to the wrong parent → Make Library left pane creation more robust
Attached patch patch v1.1 (obsolete) — Splinter Review
first impl of a test, still missing test cases but good first infrastructure.
Attachment #409216 - Attachment is obsolete: true
Attached patch patch v1.2 (obsolete) — Splinter Review
The test is quite complete, covers a large variety of possibile corruptions, and i learned a couple useful tricks for future tests.
Attachment #409362 - Attachment is obsolete: true
Attachment #409503 - Flags: review?(dietrich)
Comment on attachment 409503 [details] [diff] [review]
patch v1.2

>diff --git a/browser/components/pl
>+    // This is the list of the left pane queries.
>+    let queries = {
>+      "PlacesRoot": { title: "" },
>+      "History": { title: this.getString("OrganizerQueryHistory") },
>+      "Tags": { title: this.getString("OrganizerQueryTags") },
>+      "AllBookmarks": { title: this.getString("OrganizerQueryAllBookmarks") },
>+      //"Downloads": { title: this.getString("OrganizerQueryDownloads") },

just leave it out. we can add back in when we actually implement that feature.

>+      "BookmarksToolbar":
>+        { title: null,
>+          concreteTitle: PlacesUtils.getString("BookmarksToolbarFolderTitle"),
>+          concreteId: PlacesUtils.toolbarFolderId },
>+      "BookmarksMenu":
>+        { title: null,
>+          concreteTitle: PlacesUtils.getString("BookmarksMenuFolderTitle"),
>+          concreteId: PlacesUtils.bookmarksMenuFolderId },
>+      "UnfiledBookmarks":
>+        { title: null,
>+          concreteTitle: PlacesUtils.getString("UnsortedBookmarksFolderTitle"),
>+          concreteId: PlacesUtils.unfiledBookmarksFolderId },
>+    };
>+    // All queries but PlacesRoot.
>+    const EXPECTED_QUERIES = 6;

EXPECTED_QUERY_COUNT ?

>+
>+    // Removes an item and associated annotations, ignoring eventual errors.
>+    function safeRemoveItem(aItemId) {
>+      try {
>+        if (as.itemHasAnnotation(aItemId, ORGANIZER_QUERY_ANNO) &&
>+            !(as.getItemAnnotation(aItemId, ORGANIZER_QUERY_ANNO) in queries)) {
>+          // Some extension did annotate their roots with our query annotation,
>+          // we should avoid to delete them for dataloss issues.

s/did annotate/annotated/

and the whole next line is confusing, maybe "so we should not delete them."?

>+          return;
>+        }
>+        // removeItemAnnotation does not check if item exists, nor the anno,
>+        // so this is safe to do.
>+        as.removeItemAnnotation(aItemId, ORGANIZER_FOLDER_ANNO);
>+        as.removeItemAnnotation(aItemId, ORGANIZER_QUERY_ANNO);
>+        // This will throw if the annotation is orphan.
>+        bs.removeItem(aItemId);

"is an orphan"

to here....
Comment on attachment 409503 [details] [diff] [review]
patch v1.2

                                                .getItemTitle(itemId) });
>+    var query = { name: queryName,
>+                  itemId: itemId,
>+                  correctTitle: PlacesUtils.bookmarks.getItemTitle(itemId) }
>+    switch (queryName) {
>+      case "BookmarksToolbar":
>+        query.concreteId = PlacesUtils.toolbarFolderId;
>+        query.concreteTitle = PlacesUtils.bookmarks.getItemTitle(query.concreteId)
>+        break;
>+      case "BookmarksMenu":
>+        query.concreteId = PlacesUtils.bookmarksMenuFolderId;
>+        query.concreteTitle = PlacesUtils.bookmarks.getItemTitle(query.concreteId)
>+        break;
>+      case "UnfiledBookmarks":
>+        query.concreteId = PlacesUtils.unfiledBookmarksFolderId;
>+        query.concreteTitle = PlacesUtils.bookmarks.getItemTitle(query.concreteId)
>+        break;
>+    }
>+    leftPaneQueries.push(query);
>     // Rename to a bad title.

missing end statement semicolons on a bunch of lines above.

r=me. please cc l10n for the string changes if necessary.
Attachment #409503 - Flags: review?(dietrich) → review+
if we want this on 1.9.2 i can make a version without string changes. would make sense.
Attached patch patch v1.3Splinter Review
Attachment #409503 - Attachment is obsolete: true
http://hg.mozilla.org/mozilla-central/rev/5dce7c1445d5
Status: NEW → RESOLVED
Closed: 15 years ago
Flags: in-testsuite? → in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → Firefox 3.7a1
Blocks: 532936
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: