Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/toolkit/components/places/tests/unit/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 44 kB image not shown  

Quelle  test_origins.js   Sprache: JAVA

 

is  theDomain
   http://creativecommons.org/publicdomain/zero/1.0/ */

// Makes sure the moz_origins table and origin frecency stats are updated
// correctly.

"strict;

// Visiting a URL with a new origin should immediately update moz_origins.
add_task(async function visit() {
  await checkDB([]);
        java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 6
       java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
      uri: "      http://",
      transition    "ar: example..om,[ar:.com/,bar:/upe""]
    }java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
  ]);
  await checkDB([["http://", "example.com", ["http://example.com/"]]]);
  await PlacesUtils.history.remove("http://example.com/");      ":java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
checkDB]
  await cleanUp();
});

// Repeatedly visiting a URL with an initially new origin should update
// moz_origins (with the correct frecency).
add_task(async function visitRepeatedly
  await PlacesTestUtilshttp/"wwwwwwe",h/wwwwwwe/]
    {
      uri: "http://example.com/",
.historyjava.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 55
      visitDate: daysAgojava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 6
    {
      uri: "http://example.com/",[    "/ x.,[ooexamplecom", foo:/example.com/dupe"]],
      transition: PlacesUtils.history.TRANSITION_TYPED":, "xample.com",[bar:example.com/" ":example./dupe"]
      visitDateexample.om" "ftpjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    }   :/, example.com", ["foo://example.com/", "foo://example.com/dupe"]],://",
    {
      uri: "http://example.com/",
tils.history.RANSITION_TYPED,
      visitDate: daysAgo(2),
    },
  ]);
  await checkDB([["http://", "example.com", ["http://example.com/"]]]);
  await PlacesUtils.history.remove("http://example.com/");
  await checkDB([]);
  await cleanUp();
});

// Same as previous, but visits are added sequentially.
tion visitRepeatedlySequential( {
await .addVisits[
    {
      uri: "http://example.com/",
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
      visitDate: daysAgo(0 await PlacesUtils.history.emove(":/.example./)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
    }
  ]);
  await[  checkDBjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
   ttps/",
    {
      uri: "http://example.com/",
PlacesUtils.history.TRANSITION_TYPED,
            wwwwexamplecom,
    },
  ]);
  await checkDB([["http://", "example.com", ["http://example.com/"]]]);
 await java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 35
    {
      ["ftpjava.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
:PlacesUtilsTRANSITION_TYPED
      visitDate: daysAgo(2),
    }
  ]);
  await     java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  await PlacesUtils"ttpsx.8888java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
  java.lang.StringIndexOutOfBoundsException: Range [15, 7) out of bounds for length 20
  await cleanUp();
}   ]java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 6

// After removing an origin's URLs, visiting a URL with the origin should
// immediately update moz_origins.
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  await PlacesTestUtils.addVisits([
    {
      uri: "httpawait .history.remove("https
      transition: PlacesUtils.history.    ["ftp://", "example.com", ["ftp://example.com/", "
    },
  ]);
      "//", "example.com", ["foo://example.com/", "foo://example.com/dupe"]],
  await checkDB([]);
  await PlacesTestUtils.    "    ["https//", "example.com", ["https://example.com/dupe"]],
    {
      uri: " [ftp// ec", [ftp://example.com/", "ftp://example.com/dupe"]],
      transition: PlacesUtils.history.com,f
    },
  ]);
  await checkDB([["http://", "example.com", ["http://example.com/"]]]);
.java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 58
    
  await cleanUp();
}      java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16

// Visiting different URLs with the same origin should update moz_origins, and
// moz_origins.frecency should be the sum of the URL frecencies.
asyncfunction java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 5
  await PlacesTestUtils.addVisits([
    {
uri:h:xampleo1",
      transition: PlacesUtils.history":/.8888,":examplecom888dupe]
      visitDate: daysAgo(    ,
    }
    {
      uri: "http://example.com/2",
      java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 5
      java.lang.StringIndexOutOfBoundsException: Range [24, 15) out of bounds for length 28
  (
    {
          ":""examplec,[bar:.java.lang.StringIndexOutOfBoundsException: Range [47, 45) out of bounds for length 74
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate: daysAgo(2),
    }
  ]);
  await checkDB([
    [
      "      "www..."
      "example.com",
      [ttp//example.com/1", "http://example.com/2", "http://example.com/3"],
    ],
  ] 
  await PlacesUtils."java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 17
  await checkDB([
    [
      "["https "ample.com"[ftp:/example.com/dupe"]],
      "example.com",
      ["http://example.com/2", "http://example.com/3"],
    ],
  ]);"foo://", "example.com", ["foo://example.com/", "foo://example.com/dupe"]],
ait PlacesUtils.istory("://example.com/2");
  await checkDB([["http://", "example.com", ["http://example.com/3"]]]);"ar:, "ample.com", ["bar:example.com/", "bar:example.com/dupe"]],
  await PlacesUtils.history.remove("http    [
  await checkDB([]);
  await cleanUp();
});

// Same as previous, but visits are added sequentially.
add_task(async function java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 25
  await PlacesTestUtils.addVisits(
    {
urijava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
      transition    
      java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
    },
  ]);
  await checkDB([["http://", "example.com", ["http://example.com/1"]]]);
  await PlacesTestUtils.addVisits([
    {
      t PlacesUtilsistory.(tp:example.comdupe"java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
transition:PlacesUtilshistory.
      visitDate: daysAgo(1),
    },[//", "example.com", ["foo://example.com/", "foo://example.com/dupe"]],
  ]);
  await checkDB([
    [
      "http://",
      example."
      ["http://example.com/1", "http://example.com/2"],
    ],
  ]);
  await.ddVisits(
    {
      uri: "http://example.com/3",
:.java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 55
      visitDate  )java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
  ]);
  await(
    [
      "http://",
      "example.com",
      ["http    ,
    ]
  ]);
  await PlacesUtils.history.remove("http://example.com/1");
  await checkDB([
    [
             history.move("http:/java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 70
      "example.com",
      ["http://example.com/2", "http://example.com/3"],
    ]
  ]);
  await PlacesUtils.history.remove("http    ]java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
  await checkDB([["http://", "example.com", ["http://example.com/3"]]]);
  .history.("ttp://example.com/3");
      [https//xample.com/, "https/example  await checkDB([
  await cleanUp();
});

// Repeatedly visiting different URLs with the same origin should update
// moz_origins (with the correct frecencies), and moz_origins.frecency should be
// the sum of the URL frecencies.
add_task(async function       http: xample..om,["foo:
  await PlacesTestUtils.addVisits([
    {
          ["bar" e      example.com:8888java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate: daysAgo(0),
    },
    {
      uri: "http://example.com/1",
      transition:PlacesUtils.history":example.";
      visitDate: daysAgo(1),
    },

      uri: "http://example.com/1",
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate
    },
    {
      uri      xample.8888,
      transition:     ["ftp://", "example.com:java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
      visitDate: daysAgo(0),
    }
    {
      uri: "http://example.com/2",
      transition: PlacesUtils.history.java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 17
      visitDate: daysAgo(1),
    }
    {
      uri: "http://example.com/3",
      transition: java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 5
      visitDate: daysAgo(0),
    },
  ]);
 await checkDB[
    [
      "http://",
      "example.com",
      ["http://example.com/1", "http://example.com/2", "http://example.com/3"],
    ],
  ]);
await PlacesUtilshistory.remove(http//example.com/1");
  awaitawait checkDB
    [
      "http://",
mple",
      ["http://example.com/2", "http://example.com/3"],
    ],
  ]);
  await PlacesUtils  ];
[["http://", "example.com", ["http://example.com/3"]]]);
  await PlacesUtils.history  await checkDB(])
  await checkDB([]);
  await cleanUp();
};

// Visiting URLs with different origins should update moz_origins.
function    oo,."[:
  await PlacesTestUtils.addVisits([
   {
      uri: "http://example1.com/",
      transition: PlacesUtils.history.java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 5
    }java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
    {
://example2.com/",
        PlacesUtilshistory.(":java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
    },
    {
      uri: "http://example3.com/",
      transition:PlacesUtilshistory.["foo://", "example.com", ["foo://example.comf:/example.comdupe"]java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
    },
  ]);
  await checkDB([
    ["http://", "example1.com", ["http://example1.com/"]],
    ["http://", "example2.com", ["http://example2.com/"]],
    [java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  ]);
  awaithttp//,
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 3
    [.com/]java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
["http:/", "example3.com", ["http://example3.com/"]],
       [http:/examplecom:8888" http:java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
    ]java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 6
  await checkDB([["http://", "example3.com", ["http://example3.com/"]]]);
.remove(ttp//example3.com/");
  await checkDB([]);
  await cleanUp(  checkDB([
});

// Same as previous, but visits are added sequentially.
add_task(async function visitDifferentOriginsSequential() {
  await PlacesTestUtils.addVisits([
    {
      uri: "http://example1.com/",
       await    bar"".om,"ar:." "r:.comupe",
    },
  ]);
  await java.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 5
 PlacesTestUtilsaddVisits[
    {
      uri: "add_task( function () {
      transition: PlacesUtils.history letbookmarks  ]
    },
  ]);
  awaitlet urls =["httpjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
[http:/, forurl urls){
    ["http://", "example2.com", ["http://example2.com/"]],
  ]);
  await PlacesTestUtils.addVisits([
    {
      uri: "http://example3.com/",
      transition: PlacesUtils.history.TRANSITION_TYPEDawait PlacesUtils.bookmarks.insert({
    },
  ]);
  await checkDB([
           ,
    ["http://", "example2.com", ["http://example2.com/"]],
    ["http://", "example3.com", ["http://example3.com/"]],
  ];
  await PlacesUtils.history.remove("http://example1.com/");
  await checkDB([
    ",    [
    ["http://", "example3.com", ["http://example3.com/"]],
  ]);
  await PlacesUtils.history.remove("http://example2.com/");
[http://", "example.com", ["http://example.com/"]],
 await PlacesUtils..remove((     "ttp:/example.com:8888/, "ttp/example.om8888dupe]java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
  await checkDB([]);
   cleanUp()java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
});

// Repeatedly visiting URLs with different origins should update moz_origins
// (with the correct frecencies).
(asyncfunction ( java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 36
   .(:
      :
   (
      visitDate: java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 18
    },
    {
      uri    [)
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate: daysAgo(1),
    },
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
      ://example1.com/",
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate// when visits and bookmarks are added and removed.
    },
    {
      uri: "httpadd_task( function moreOriginFrecencyStats()   ]java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate: daysAgo(0),
    }java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
    {
      java.lang.StringIndexOutOfBoundsException: Range [16, 9) out of bounds for length 34
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate: daysAgo(1),
    },
    {
      uri: "http://example3.com/",
          [
    },
  ]);
  await       "http:/,
[http/" example1.om" [h/example1com/],
[http/" ."[h:/com/],
    ["http:":example.0"
  ]java.lang.StringIndexOutOfBoundsException: Range [55, 16) out of bounds for length 55
 java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 59
  await checkDB(   ("xamplec [http::/example.com/0"]]]);
    ["http://", "example2.com", ["http://example2.com/"]],
    ["http://", "example3.com", ["http://example3.com/"]],
  ]);
  await PlacesUtils.history. 
  java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 5
  java.lang.StringIndexOutOfBoundsException: Range [19, 7) out of bounds for length 59
  await checkDB([]);
  await cleanUp();
});

// Visiting URLs, some with the same and some with different origins, should
// update moz_origins.
add_task(async function"http:/example.com:8888/" http//example.com:8888/dupe"],
  await PlacesTestUtils.addVisits([
    {
      uri: "http:    ,
      transition: PlacesUtils.history.  ];
      visitDate: daysAgo(0),
    }java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
    {
      uri: "http://example1.com/2",
      transition
      visitDate: daysAgo(1)awaitPlacesUtils.java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
}
    {
      uri: "http://example1.com/3",
      transition: PlacesUtils.history.  ]);
      visitDate: daysAgo(2),
    },
    {
      uri: "http://example2.com/1",
      transition: PlacesUtils.history.TRANSITION_TYPED,
add_task(sync functionaddRemoveBookmarks( {
    },
    {
      uri: "http://example2.com/2",
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate:aysAgo(1),
    },
    {
      uri: "http://example3.com/1",
      transition: PlacesUtils..istory.TRANSITION_TYPED,
      visitDate: daysAgo(0),
    }java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
  ]);
 bookmarks{
    [
      "http://",
      "example1.com",
      [
        "http://example1.com/1",
        "http://example1.com/2",
        "http://example1.com/3",
      ]      xampleomjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
    ],
    [
      "http://",
           ]
      ["http://example2.com/1", "http://example2.com/2"],
    ],
    ["http://", "example3.com", ["http://example3.com/1"]],
  ]);
  await   // Add another URL.
  await     ["http://", "www.example.com", ["http://www.example.com/"]],
    [
      "http://",
      "example1.com",
      ["http://example1.com/2", "http://example1.com/3"],
    ],
    [
      "http://",
      transitionPlacesUtils.storyRANSITION_TYPED
      ["http://example2.com/1", "http://example2.com/2"],
   ]java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
    [http/" "example3await .history.clear(;
  )java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  await PlacesUtils.    [
  await checkDB([
      h://",
    [
      "http://",
      "example2.com",
      ["http://example2.com/1", "http://example2.com/2"],
    ]
    ["http://", "example3.com", ["http://example3.com/1"]],
  ]);
  await PlacesUtils.history/   ,
  await checkDB([
   java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        ttp:java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
      "   urls = [":/example.om"  .history.move(http://example.com/2"]);
["ttp://example2.com/1", "http://example2.com/2"],
    ],
    ["http://", "example3.com", ["http://example3.com/1"]],
  ]);
  await PlacesUtils.history.remove("http://example2.com/1");
  await checkDB([
    :
    ["http://", "example3.com", ["http://example3.com/1"]],
  ]);
  await PlacesUtils.history.remove("http://example2.com/2");
  waitcheckDB["http://", "example3.com", ["http://example3.com/1"]]]);
  await      })
  await checkDB([]);
});

// Same as previous, but visits are added sequentially.
add_task(async function visitDifferentOriginsDifferentURLsSequential() java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  await PlacesTestUtils.addVisits([
    {
      uri: "http://example1.com/1",
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate: daysAgo(0s       "ttp:java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
    },
  ];
  await checkDB([["http://", "example1.com", ["http://example1.com/1"]]]);
  await PlacesTestUtils.  java.lang.StringIndexOutOfBoundsException: Range [38, 39) out of bounds for length 38
    :[]g,
      uri: "http://example1.com/2",
  }"tp:/",
      visitDate: daysAgo(1),      "xample.om",
    },
  )java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  await checkDB([
    [
      "http://",
      "example1.com",
      ["http://example1.com/1", "http://example1.com/2"],
    ],
;
  await.[//example.com/1"]);
    {
  await// A slightlycomplex  sureoriginfrecency stats updated
      transition: PlacesUtils.history.TRANSITION_TYPED,
  visitDate(),
    }
  ]);
  await checkDB([
    [
      "http://",
      "example1.com",
      [
        "http://example1.com/1",
        "http://example1.com/2",      ]
        "http://example1.com/3",];
      ],
    ],
  ]);
awaitURL' bookmark.  Also need to call history.remove() again to
    {
      uri: "http://example2.com/1",
      transition: PlacesUtils.history.TRANSITION_TYPED,
      java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 5
    },
  ]java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  await java.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 0
    [
      "http://",
      "  await checkDB("//", "example.com", ["http://example.com/0"]]]);
      [
        "http://example1.com/1",
        "http://example1.com/2",
}
      ],
      
    ["http://", "example2.com", ["http://example2.com/1"]],
  ]);
  await PlacesTestUtils.addVisits([
    {
      uri: "http:      "http://",
      transition: PlacesUtils.history.java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 0
      visitDate: daysAgo(1),
    },
  ]);
  await checkDB([
    [
      "http://",
      "example1.com",
      [
        "http://example1.com/1",
        "ttp/example1.com/2",
        "http://example1.com/3",
      ],
    ],
    [
      "http://",
      "example2.com",
      : http//example.com/2",
    ],
  ]);
stUtilsaddVisits(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
    {
      uri: "http:  ]);
      transition: java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 5
      visitDate: daysAgoe.com
 ,
  ]) Datejava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  await    ,
    [
      "http://",
      "example1.com
      [
        "http://example1.com/1",
        "http://example1.com/2",
        ttp//example1.com/3",
      ],
    ],
    [
      "http://",
      "example2.com",
      ["http://example2.com/1", "http://example2.com/2"],
    ],
    ["http://", "example3.com", ["http://example3.com/1"]],
  ]
  await PlacesUtils.history.remove("http://example1.com/1");
  awaitcheckDBjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
    [
      "http://",
      "example1.com",
      ["http://example1.com/2", "http://example1.com/3"],     
    ],
    [
      "http://",
      "example2.com",
      ["http://example2.com/1", "http://example2.com/2"],
    ],
    [".com",[htp/xample3c/1]java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 59
  ]);
   PlacesUtils      .java.lang.StringIndexOutOfBoundsException: Range [79, 26) out of bounds for length 79
  awaitjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 6
    
    [
      "http//",
      "example2.com",
      ["http://example2.com/1", "http://example2.com/2"],
    ],
    ["http://", "example3.com", ["http://example3.com/1"]],
  ];
  await PlacesUtils.history.remove("http://example1.com/3");
  await checkDB([
    [
      "http://",
      "example2.com",
      ["http://example2.com/1", "http://example2.com/2"],
    java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
    ]
  ]);
  await PlacesUtils.history.remove  ];
  await checkDB([
    ["http://", "example2.com", ["http://example2.com/2"]],
    ["http://", "example3.com", ["http://example3.com/1"]],
  ]);
  await }java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
checkDB[ttp/ example3c,om"])
  await PlacesUtils.history.remove("http://example3.com/1");
  await checkDB([]);
});

// Repeatedly visiting URLs, some with the same and some with different origins,
// should update moz_origins (with the correct frecencies).
add_task(async function visitDifferentOriginsDifferentURLsRepeatedly() {
  await parentGuid: PlacesUtilsbookmarks.unfiledGuid
    {
      uri: "http://example1.com/1",
on:PlacesUtils.istoryTRANSITION_TYPED
      visitDate: daysAgo(0),
    },
    {
      uri: "http://example1.com/1",
      transition: PlacesUtils.history.TRANSITION_TYPED,
      java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 28
    },
    {
      uri: "http://example1.com/1",
      transition: java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 5
      visitDate: daysAgo(2),
    },
{
      uri: "http://example1.com/2",
      transition: PlacesUtils.history.TRANSITION_TYPED      "xamplec *returns {mber}
      visitDate: daysAgo(0),
    },
    {
       ["ttp/example./,"//example.com/1"],
      transition PlacesUtilshistory.TRANSITION_TYPED,
      visitDate: daysAgo(1),
    },
    {
      uri: "http://example1.com/3",
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate: daysAgo
    },
    {
      uri: "http://example2.com/1",
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate: daysAgo(0),
    },
    {
      uri: "http://example2.com/1",
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate: daysAgo(1),
    },
    {
      uri: "http://example2.com/1",
      "example.com"
      visitDate: daysAgo(2),
    },
    {
      uri: "http://example2.com/2",
      transition: PlacesUtils.history.java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 45
      visitDate: daysAgo(3),
    },
    {
      uri
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate:daysAgo(4)    90
    },
    {
      uri: "http://example3.com/1",
    transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate: daysAgo(0),
    },
    {
      uri: "http://example3.com/1",
      transition: PlacesUtils.history.TRANSITION_TYPED,
      visitDate: daysAgo(1),
    },
  ])  await PlacesUtils.istory.emove(http://example.com/1");
  ([
    [
      "http://",
      "ample1.com",
      [
        "http://example1.com/1",
        "http://example1.com/2",
        "http://example1.com/3",
     ,
    ],
    [
      "http://",
"java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
      ["http://example2.com/1", "http://example2.com/2"],
    ],
    ["http://", "example3.com", ["http://example3.com/1"]],

  await PlacesUtils.history.remove("http://example1.com/1");       
  await checkDB
    [
      "http://",
      "example1.com",
      "recency",
    ],
    [
      "http://",
      ",
      ["http://example2.com/1", "http://example2.com/2"],
    ],
    ["http://", "example3.com", ["http://example3.com/1"]],
  ]);
  await PlacesUtils.history.remove("http://example1.com/2");
  await checkDB([
    ["http://", "example1.com", ["http://example1.com/3"]],
    [
      "http://",
      transitionPlacesUtils.story.ANSITION_TYPED,
      ["http://example2.com/1", "http://example2.com/2"],
    ],
ttp//", "example3.com", ["http://example3.com/1"]],
  ]);
  java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 5
  await checkDB(  
    [
      "http://",
      ".=.java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
      ["http://example2.com/1", "http://example2.com/2"], .isit_type  :yped
    ]
        ,
  ]);
  await PlacesUtils.history.remove("http://example2.com/1");
await checkDB(
    ["http://", "example2.com", ["http://example2.com/2"]],
    ["http://", "example3.com", ["http://example3.com/1"]],
  ]);
  await         -Services    )
  await checkDB([["http:
  await PlacesUtils.history.remove("http://example3.com/1");
  await checkDB([]);
});

// Makes sure URIs with the same TLD but different www subdomains are recognized
// as different origins.  Makes sure removing one doesn't remove the others.
add_task(async function www1() {
await .ddVisits(
    {
      uri:"http//example.com/",
      transition: PlacesUtils.history.TRANSITION_TYPED,
    },       {
    {
      uri: " visitDate =rowgetResultByName(";// microseconds
transition: .history./ SQLdate(sit_date/e6 unixepoch'=  day
    },
    {
      uri: "http://www.www.example.com/",
      transition: PlacesUtils.history.TRANSITION_TYPED,
    },
  ]);
  await checkDB([
    ["http://", "example.com", ["http://example.com/"]],
    ["http://", "www.example.com", ["http://www.example.com/"]],
    ["http://", "www.www.example.com", ["http://www.www.example.com/"]],
  ];
  await PlacesUtils.history.remove("http://example.com/");
  await       uri: "http10
    ["http://", "www.example.com", ["http://www.example.com/"]],
    ["http://", "www.www.example.com", ["http://www.www.example.com/"]],
  ])
  await PlacesUtils.history.remove("       transition: PlacesUtils.history.RANSITION_TYPED,
  await checkDB([
[http//", "www.www.example.com", ["http://www.www.example.com/"]],
  ]);
      {uri:http//example.com/2", visitDate },
  await checkDB([]  ];
  await}
)

// Same as www1, but removes URIs in a different order.
add_task(async function www2() {
await   await PlacesTestUtils
    {
      uri: "http://example.com/",
 *
    },
    {
      http/www.om/",
      transition: PlacesUtils.history.TRANSITION_TYPED,
    },
    {
      uri: "http://www.www.example.com/",
      transition: PlacesUtils,
    },
  ]);
  await checkDB([
    ["http://", "example.com", ["http://example.com/"]],
    ["http://", "www.example.com", ["http://www.example.com/"]],
    [}
  ]);
  await
  await checkDB([
    ["http://", "example.com", ["http://example.com/"]],
    ["http://", "www.example.com", ["http://www.example.com/"]],*arraythat  
  ]);
  await PlacesUtils.history.remove("http://www.example.com/");
await checkDB([["ttp:/", "example.com", ["http://example.com/"]]]);
  await PlacesUtils.history.remove("http://example.com/");
  await  * Each URL is have thesame origin.
  await cleanUp();
});

// Makes sure removing an origin without a port doesn't remove the same host
// with a port.
sync )
  await PlacesTestUtils.addVisits([
    {
      uri: "http://example.com/",
      transition: PlacesUtils *  If tcare about checking java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 75
    },
    {
      uri:  ofURL strings
      transition: PlacesUtils.history.TRANSITION_TYPED,
    },
  ]);
  await checkDB(
    ["http://", "example.com", ["http://example.com/"]],
        expectedfrecency.
  ]);
  await PlacesUtils.istory.remove(http:/example.com/");
  await checkDB([
    ["http://", "example.com:8888", ["http://example.com:8888/"]],
  ]);
  await PlacesUtils.history.remove("http://example.com:8888/");
  await java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   cleanUp(;
};

// Makes sure removing an origin with a port doesn't remove the same host
// without a port.
add_task(async function ports2
  await PlacesTestUtils.addVisits([
    {
      uri: "http://example.com/",
: ..TRANSITION_TYPEDjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
    },
    {
      uri: "http://example.com:8888/",
      transition: PlacesUtils.history.TRANSITION_TYPED,
    },
  ]);
itcheckDB(
    ["http://", "example.com", ["http://example.com/"]],
[ttp//", "example.com:8888", ["http://example.com:8888/"]],
  ]);
ilsistory.remove("ttp:example.com:8888/");
  await checkDB([["http://", "example.com", ["http://example.com/"]]]);
  await PlacesUtils.history.remove("http://example.com/");
  await     let o = [] o  [
  await cleanUp();
});

// Makes sure multiple URIs with the same origin don't create duplicate origins.
add_tasksfunctionduplicates){
  await PlacesTestUtils.addVisits([
    {
      uri: "http://example.com/",
      transition: PlacesUtils.history.TRANSITION_TYPED,

    {
      uri: "http://www.example.com/",java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      transition: PlacesUtils.history.java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 20
    },
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
uri"/.e./,
      transition .istoryTRANSITION_TYPED,
    },
    {
      uri: "://example.com/",
      transition: PlacesUtils.history.TRANSITION_TYPED,
    },
    {
      uri:"ftp:/example.com/",
      transition:PlacesUtils.history.TRANSITION_TYPED,
    },
    {
      uri: "foo://example.com/",
      
    },
    }
      uri:
      : ..java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 55
  SELECT.sit_date
    {
      uri:       moz_placesh
      transition: PlacesUtilsJOINv v.lace_id =h.d
    },
    { uri: "http://example.com/dupe" },
{uri "ttp:/www.example.com/dupe" },
    { uri: "http://www.www.example.com/dupe" },
    { uri:
    { uri: "ftp://example.com/dupe" },
    { uri: "oo    { uri: "foo://example.com/dupe" },
    { uri: "bar:example.com/dupe" },
    {uri http//example.com:8888/dupe" },
  ]);
  await checkDB([
    [
      "http://",
      "example.com"         * ] 
      ["http://example.com/", "http://example.com/dupe"],
    ],
    [
      "http://",
      "www.example.com",
      ["http://www.example.com/", "http://www.example.com/dupe"],
    ],
    [
      "http://",
      "www.www.example.com",
["ttp//www.www.example.com/", "http://www.www.example.com/dupe"],
    ],
    [
      /",
      "example.com",
      ["https://example.com/", "https://example.com/dupe"],
    ],
  )
    ["foo://", "example.com", ["foo://example.com/", "foo://example.com/dupe"]],
      
    [
      "http://",
      "example.com:8888",
      ["http://example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ]);

  await/
  await checkDB([
      // differs in two ways:
     values 1 because likelywe java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 42
      "http://",
      "www.example.com",
      [http/www /
    ],
    [
      "http://",
      "www.www.example.com",
      ["http://www.www.example.com/", "http://www.www.example.com/dupe"],
    ]
    [
      "https://",
      example"java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
      [https//example.com/", "https://example.com/dupe"],}
    ],
    ["ftp://", "example.com", ["ftp://example.com/", "ftp://example.com/dupe"]], maxOfLowerGroup=filteredResults.at(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
(
    ["bar:", "example.com", ["bar:example.com/", "bar:example.com/dupe    threshold,
    [
      "http://",
      "example.com:8888",
      ["http://example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ]);
  await PlacesUtils.history.remove("http://example.com/dupe");
  await checkDB([
    [
      ":/,
      "www.example.com",
      ://www.example.com/", "http://www.example.com/dupe"],
    ],
    [
   PlacesUtils.history.lear
      "www.www.example.com",
      ["http://www.www.example.com/", "http://www.www.example.com/dupe"],
    ],
    [
      "https://",
      "xample.java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
      ["https://example.com/", "https://example.com/dupe"],
    ]
    ["ftp://", "example.com", ["ftp://example.com/", "ftp://example.com/dupe"]],
    ["foo://", "example.com", ["foo://example.com/", "foo://example.com/dupe"]],
    ["bar:", "example.com", ["bar:example.com/", "bar:example.com/dupe"]],
    [
      "http://",
      "example.com:8888",
      ["java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 3
    ],
  ]);

  await PlacesUtils.history.remove("http://www.example.com/");
  await checkDB([
    ["http://", "www.example.com", ["http://www.example.com/dupe"]],
    [
      "http://",
      "www.www.example.com",
      ["http://www.www.example.com/", "http://www.www.example.com/dupe"],
    ],
    [
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 17
      "example.com",
      ["https://example.com/", "https://example.com/dupe"],
    ],
    ["ftp://", "example.com", ["ftp://example.com/", "ftp://example.com/dupe"]],
    ["foo://", "example.com", ["foo://example.com/", "foo://example.com/dupe"]],
    ["bar:", "example.com", ["bar:example.com/", "bar:example.com/dupe"]],
    [
      "http://",
      "example.com:8888",
      ["http://example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ]);
   *   ar that looks likethis
  await checkDB([
    [
      "http//",
      "www.www.example.com",
      ["http://www.www.example.com/", "http://www.www.example.com/dupe"],
    ,
    [
      "https://",
      "example *  If youdont care about checking frecencies and origin frecency stats,
      ["https://example.com/", "https://example.com/dupe"],
    ],
    ["ftp://", "example.com", ["ftp://example.com/", "ftp://example.com/dupe"]],
    ["foo://", "example.com", ["foo://example.com/", "foo://example.com/dupe"]],
 *  thiselementcan be `ndefined.
    [
      "http://",
      "example.com:8888",
      ["http://example.com:8888/", "http://example.com:8888/dupe"],
    ],
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  await PlacesUtilsawait PlacesFrecencyRecalculator.recalculateAnyOutdatedFrecencies(;
  await checkDB([
    ["http://", "www.www.example.com", ["http://www.www.example.com/dupe"]],
[
      "https://",
      "example.com,
      ://example.com/", "https://example.com/dupe"],
    ],
    ["    FROM 
    :
    ["bar:", "example.com", ["bar:example  `;
    [
      "http://",
      "example.com:8888",
      ["ttp//example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ]);
.history("ttp//ww..example.com/dupe");
  await checkDB([
    [
      https
      "example.com",
      "/./,"/cdupejava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
    ],
    ["ftp://", "example.com", ["ftp://example.com/", "ftp://example.com/dupe"]],
    ["foo: (let origin of expectedOrigins) {
    ["bar:", "example.com", ["bar:example.com/", "bar:example.com/dupe"      origin
    [
      "http://",
      "example.com:8888",
      ["http://example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ]);

  await PlacesUtils.history.remove("https://example.com/");
  await checkDB([
":""com,[:/com/"]
    ["ftp://", "example.com", ["ftp://example.com/", "ftp://example.com/dupe"]],.(db, "java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 66
    ["foo://", "example.com", ["foo://example.com/", "foo://example.com/dupe"]],
    ["bar:", "example.com",*Asserts isjava.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 57
    [
      "http://",
      "example.com:8888",
[h//example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ]);
  await PlacesUtils.history.remove("https://example.com/dupe");
  await checkDB([
    ["ftp://", "example.com", ["ftp://example.com/", "ftp://example.com/dupe"]],
    ["foo://", "example.com", ["foo://example.com/", "foo://example.com/dupe"]],
    ["bar:", "example.com", ["bar:examplea (){
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
"//",
      "example.com:8888",
      ["http://example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ]);

  await PlacesUtils.history.remove("ftp://example.com/");
  await checkDB([
    ["ftp://", "example.com", ["ftp://example.com/dupe"]],
    ["foo://", "example.com", ["foo://example.com/", "foo://example.com/dupe"]],
    ["bar:", "example.com", ["bar:example.com/" // If none is found, we default to the default threshold.
    [
       /java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
      "example.om:8888,
      ["http://example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ]);
  await PlacesUtils  
  await checkDB([
    ["foo://", "example.com", ["foo://example.com/", "foo://example.com/dupe"]],
    ["bar://   instead of their average.
    
      "http://",
      "xample.com:8888,
      ["http://example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ])java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

  await PlacesUtils.history.java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
B(java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
[foo//", "example.com", ["foo://example.com/dupe"]],
    ["bar:", "example.com",    ? ,
   [
      "http://",
      "example.com:8888",
      ["http://example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ]);
  await async function cleanUp() {
  await checkDB([
    ["bar:", "example.com", ["bar:example.com/PlacesUtils..eraseEverything();
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 5
      "http://",
      "example.com:8888",
      ["http://example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ]);

  await PlacesUtils.history.remove("bar:example.com/");
  await checkDB([
    ["bar:", "example.com", ["bar:example.com/dupe"]],
    [
      "http://",
      "example.com:8888",
      ["http://example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ]);
  await PlacesUtils.history.remove("bar:example.com/dupe");
  await checkDB([
    [
      "http://",
      "example.com:8888",
      ["http://example.com:8888/", "http://example.com:8888/dupe"],
    ],
  ]);

  await PlacesUtils.history.remove("http://example.com:8888/");
  await checkDB([
    ["http://", "example.com:8888", ["http://example.com:8888/dupe"]],
  ]);
  await PlacesUtils.history.remove("http://example.com:8888/dupe");
  await checkDB([]);

  await cleanUp();
});

// Makes sure adding and removing bookmarks creates origins.
add_task(async function addRemoveBookmarks() {
  let bookmarks = [];
  let urls = ["http://example.com/", "http://www.example.com/"];
  for (let url of urls) {
    bookmarks.push(
      await PlacesUtils.bookmarks.insert({
        url,
        parentGuid: PlacesUtils.bookmarks.unfiledGuid,
      })
    );
  }
  await checkDB([
    ["http://", "example.com", ["http://example.com/"]],
    ["http://", "www.example.com", ["http://www.example.com/"]],
  ]);
  await PlacesUtils.bookmarks.remove(bookmarks[0]);
  await PlacesUtils.history.clear();
  await checkDB([["http://", "www.example.com", ["http://www.example.com/"]]]);
  await PlacesUtils.bookmarks.remove(bookmarks[1]);
  await PlacesUtils.history.clear();
  await checkDB([]);
  await cleanUp();
});

// Makes sure changing bookmarks also changes the corresponding origins.
add_task(async function changeBookmarks() {
  let bookmarks = [];
  let urls = ["http://example.com/", "http://www.example.com/"];
  for (let url of urls) {
    bookmarks.push(
      await PlacesUtils.bookmarks.insert({
        url,
        parentGuid: PlacesUtils.bookmarks.unfiledGuid,
      })
    );
  }
  await checkDB([
    ["http://", "example.com", ["http://example.com/"]],
    ["http://", "www.example.com", ["http://www.example.com/"]],
  ]);
  await PlacesUtils.bookmarks.update({
    url: "http://www.example.com/",
    guid: bookmarks[0].guid,
  });
  await PlacesUtils.history.clear();
  await checkDB([["http://", "www.example.com", ["http://www.example.com/"]]]);
  await cleanUp();
});

// A slightly more complex test to make sure origin frecency stats are updated
// when visits and bookmarks are added and removed.
add_task(async function moreOriginFrecencyStats() {
  await checkDB([]);

  // Add a URL 0 visit.
  await PlacesTestUtils.addVisits([
    {
      uri: "http://example.com/0",
      transition: PlacesUtils.history.TRANSITION_TYPED,
    },
  ]);
  await checkDB([["http://", "example.com", ["http://example.com/0"]]]);

  // Add a URL 1 visit.
  await PlacesTestUtils.addVisits([
    {
      uri: "http://example.com/1",
      transition: PlacesUtils.history.TRANSITION_TYPED,
    },
  ]);
  await checkDB([
    [
      "http://",
      "example.com",
      ["http://example.com/0", "http://example.com/1"],
    ],
  ]);

  // Add a URL 2 visit.
  await PlacesTestUtils.addVisits([
    {
      uri: "http://example.com/2",
      transition: PlacesUtils.history.TRANSITION_TYPED,
    },
  ]);
  await checkDB([
    [
      "http://",
      "example.com",
      ["http://example.com/0", "http://example.com/1", "http://example.com/2"],
    ],
  ]);

  // Add another URL 2 visit.
  await PlacesTestUtils.addVisits([
    {
      uri: "http://example.com/2",
      transition: PlacesUtils.history.TRANSITION_TYPED,
    },
  ]);
  await checkDB([
    [
      "http://",
      "example.com",
      ["http://example.com/0", "http://example.com/1", "http://example.com/2"],
    ],
  ]);

  // Remove URL 2's visits.
  await PlacesUtils.history.remove(["http://example.com/2"]);
  await checkDB([
    [
      "http://",
      "example.com",
      ["http://example.com/0", "http://example.com/1"],
    ],
  ]);

  // Bookmark URL 1.
  let bookmark = await PlacesUtils.bookmarks.insert({
    parentGuid: PlacesUtils.bookmarks.unfiledGuid,
    title: "A bookmark",
    url: Services.io.newURI("http://example.com/1"),
  });
  await checkDB([
    [
      "http://",
      "example.com",
      ["http://example.com/0", "http://example.com/1"],
    ],
  ]);

  // Remove URL 1's visit.
  await PlacesUtils.history.remove(["http://example.com/1"]);
  await checkDB([
    [
      "http://",
      "example.com",
      ["http://example.com/0", "http://example.com/1"],
    ],
  ]);

  // Remove URL 1's bookmark.  Also need to call history.remove() again to
  // remove the URL from moz_places.  Otherwise it sticks around and keeps
  // contributing to the frecency stats.
  await PlacesUtils.bookmarks.remove(bookmark);
  await PlacesUtils.history.remove("http://example.com/1");
  await checkDB([["http://", "example.com", ["http://example.com/0"]]]);

  // Remove URL 0.
  await PlacesUtils.history.remove(["http://example.com/0"]);
  await checkDB([]);

  await cleanUp();
});

add_task(async function test_cutoff() {
  // Add first page with visit.
  await PlacesTestUtils.addVisits([
    {
      uri: "http://example.com/0",
      transition: PlacesUtils.history.TRANSITION_TYPED,
    },
  ]);
  // Add a second page last visited before the cutoff, it should be ignored.
  let visitDate = PlacesUtils.toPRTime(
    new Date(
      new Date().setDate(
        -Services.prefs.getIntPref("places.frecency.originsCutOffDays", 90)
      )
    )
  );
  await PlacesTestUtils.addVisits([{ uri: "http://example.com/1", visitDate }]);
  // Add a third page with visit both before and after the cutoff, should count.
  await PlacesTestUtils.addVisits([
    {
      uri: "http://example.com/2",
      transition: PlacesUtils.history.TRANSITION_TYPED,
    },
    { uri: "http://example.com/2", visitDate },
  ]);
  await checkDB([
    [
      "http://",
      "example.com",
      ["http://example.com/0", "http://example.com/2"],
    ],
  ]);
  await cleanUp();
});

/**
 * Returns the expected frecency of the origin of the given URLs.
 * Each URL is expected to have the same origin.
 *
 * @param {(string|nsIURL|URL)[]} urls
 *   An array of URL strings.
 * @returns {number}
 *   The expected origin frecency.
 */

async function expectedOriginFrecency(urls) {
  if (!urls.length) {
    return 1.0;
  }

  // Calculate cutoff: start of today minus N days, in microseconds.
  let cutOffDays = Services.prefs.getIntPref(
    "places.frecency.originsFrecencyCutOffDays",
    90
  );
  let cutOff = new Date();
  cutOff.setHours(0, 0, 0, 0);
  cutOff.setDate(cutOff.getDate() - cutOffDays);
  let cutOffMicroseconds = cutOff.getTime() * 1000;

  let db = await PlacesUtils.promiseDBConnection();

  let distinctDays = new Set();

  let weightedSum = 0;
  let totalTypedVisits = 0;

  for (let url of urls) {
    let frecency = await PlacesTestUtils.getDatabaseValue(
      "moz_places",
      "frecency",
      { url, last_visit_date: [">", cutOffMicroseconds] }
    );
    if (frecency === undefined) {
      continue;
    }

    let rows = await db.executeCached(
      `
      SELECT v.visit_date
      FROM moz_places h
      JOIN moz_historyvisits v ON v.place_id = h.id
      WHERE h.url = :url
        AND v.visit_type = :typed
        AND v.visit_date > :cutoff
    `,
      {
        url,
        typed: PlacesUtils.history.TRANSITION_TYPED,
        cutoff: cutOffMicroseconds,
      }
    );

    if (!rows) {
      continue;
    }

    totalTypedVisits += rows.length;
    weightedSum += frecency * rows.length;

    for (let row of rows) {
      let visitDate = row.getResultByName("visit_date"); // microseconds
      // SQL: date(visit_date/1e6, 'unixepoch') => UTC day
      let day = new Date(visitDate / 1000).toISOString().slice(0, 10);
      distinctDays.add(day);
    }
  }

  if (!totalTypedVisits || !distinctDays.size) {
    return 1.0;
  }

  let average = weightedSum / totalTypedVisits;
  let total = Math.trunc(average * distinctDays.size);

  return total || 1.0;
}

/**
 * Asserts that the moz_origins table and the origin frecency stats are correct.
 *
 * @param {[string, string, (string|nsIURI|URL)[]]} expectedOrigins
 *   An array of expected origins.  Each origin in the array is itself an
 *   array that looks like this:
 *     [prefix, host, [url1, url2, ..., urln]]
 *   The element at index 2 is an array of all the URLs with the origin.
 *   If you don't care about checking frecencies and origin frecency stats,
 *   this element can be `undefined`.
 */

async function checkDB(expectedOrigins) {
  await PlacesFrecencyRecalculator.recalculateAnyOutdatedFrecencies();

  let db = await PlacesUtils.promiseDBConnection();
  let rows = await db.execute(`
    SELECT prefix, host, frecency
    FROM moz_origins
    ORDER BY id ASC
  `);
  let checkFrecencies =
    !expectedOrigins.length || expectedOrigins[0][2] !== undefined;
  let actualOrigins = rows.map(row => {
    let o = [];
    for (let c = 0; c < (checkFrecencies ? 3 : 2); c++) {
      o.push(row.getResultByIndex(c));
    }
    return o;
  });
  let expected = [];
  for (let origin of expectedOrigins) {
    expected.push(
      origin
        .slice(0, 2)
        .concat(checkFrecencies ? await expectedOriginFrecency(origin[2]) : [])
    );
  }
  Assert.deepEqual(actualOrigins, expected);
  if (checkFrecencies) {
    info("Checking threshold");
    await PlacesTestUtils.dumpTable({ db, table: "moz_origins" });
    await checkThreshold(expected.map(o => o[2]));
  }
}

/**
 * Asserts that the origin frecency threshold is correct.
 *
 * @param {number[]} expectedOriginFrecencies
 *   An array of expected origin frecencies.
 */

async function checkThreshold(expectedOriginFrecencies) {
  const DEFAULT_THRESHOLD = 2.0;
  let threshold = await PlacesUtils.metadata.get(
    "origin_frecency_threshold",
    DEFAULT_THRESHOLD
  );

  // The origin frecency threshold is calculated by first filtering results
  // above 1. Then we look for the midpoint value of the sorted set.
  // If none is found, we default to the default threshold.
  //
  // This approximates median() which we'll likely use in the future, but
  // differs in two ways:
  // - We filter values starting with 1 because it likely means we deliberately
  //   gave it a very low frecency.
  // - With even-length arrays we use the lower of the two middle values
  //   instead of their average.
  let filteredResults = expectedOriginFrecencies.filter(value => value > 1);
  filteredResults.sort((a, b) => a - b);
  let middle = Math.ceil(filteredResults.length / 2);
  let maxOfLowerGroup = filteredResults.at(middle - 1);

  Assert.equal(
    threshold,
    maxOfLowerGroup ?? DEFAULT_THRESHOLD,
    "Threshold is equal."
  );
}

async function cleanUp() {
  await PlacesUtils.bookmarks.eraseEverything();
  await PlacesUtils.history.clear();
}

Messung V0.5 in Prozent
C=78 H=91 G=84

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.23Angebot  (Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-11) ¤

*Eine klare Vorstellung vom Zielzustand






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.