@@ -107,14 +107,18 @@ const BOOKMARKS = {
107
107
id : "big_stash" ,
108
108
title : "Big Stash" ,
109
109
children : [
110
- { id : "one" , title : "One" , url : `${ B } #1` } ,
111
- { id : "two" , title : "Two" , url : `${ B } #2` } ,
112
- { id : "three" , title : "Three" , url : `${ B } #3` } ,
113
- { id : "four" , title : "Four" , url : `${ B } #4` } ,
114
- { id : "five" , title : "Five" , url : `${ B } #5` } ,
115
- { id : "six" , title : "Six" , url : `${ B } #6` } ,
116
- { id : "seven" , title : "Seven" , url : `${ B } #7` } ,
117
- { id : "eight" , title : "Eight" , url : `${ B } #8` } ,
110
+ // The indexes in big_stash are intentionally corrupt/inconsistent
111
+ // with their actual positions in the folder, to simulate some
112
+ // common corruptions I've seen in Firefox's bookmarks DB (both
113
+ // duplicate indexes and negative indexes).
114
+ { _index : - 2 , id : "one" , title : "One" , url : `${ B } #1` } ,
115
+ { _index : - 1 , id : "two" , title : "Two" , url : `${ B } #2` } ,
116
+ { _index : 0 , id : "three" , title : "Three" , url : `${ B } #3` } ,
117
+ { _index : 2 , id : "four" , title : "Four" , url : `${ B } #4` } ,
118
+ { _index : 2 , id : "five" , title : "Five" , url : `${ B } #5` } ,
119
+ { _index : 5 , id : "six" , title : "Six" , url : `${ B } #6` } ,
120
+ { _index : 6 , id : "seven" , title : "Seven" , url : `${ B } #7` } ,
121
+ { _index : 7 , id : "eight" , title : "Eight" , url : `${ B } #8` } ,
118
122
] ,
119
123
} ,
120
124
{
@@ -227,10 +231,12 @@ type BookmarkNamesHere<B extends NamedBookmark> =
227
231
? BookmarkNamesHere < B [ "children" ] [ any ] >
228
232
: never ) ;
229
233
interface NamedBookmark {
234
+ readonly index ?: number ;
230
235
readonly id : string ;
231
236
readonly children ?: readonly NamedBookmark [ ] ;
232
237
}
233
238
interface NamedBookmarkFolder {
239
+ readonly index ?: number ;
234
240
readonly id : string ;
235
241
readonly children : readonly NamedBookmark [ ] ;
236
242
}
@@ -253,7 +259,7 @@ export async function make_bookmarks(): Promise<BookmarkFixture> {
253
259
254
260
async function gen (
255
261
id : BookmarkName ,
256
- bm : any ,
262
+ bm : NamedBookmark | NamedBookmarkFolder ,
257
263
parentId : string | undefined ,
258
264
) : Promise < Bookmarks . BookmarkTreeNode > {
259
265
/* c8 ignore next -- bug-checking */
@@ -266,8 +272,6 @@ export async function make_bookmarks(): Promise<BookmarkFixture> {
266
272
const new_kids : Bookmarks . BookmarkTreeNode [ ] = [ ] ;
267
273
res [ id ] ! . children = new_kids ;
268
274
for ( const c of bm . children ) {
269
- c . parentId = res [ id ] ! . id ;
270
- c . index = i ;
271
275
new_kids . push ( await gen ( c . id as BookmarkName , c , res [ id ] ! . id ) ) ;
272
276
++ i ;
273
277
}
0 commit comments