Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
-
CI results over the last 21 days3,688Runs99.95%Pass2Failures0Timeouts0Crashes0Skips
Runs with issues per day (up to 4.1%) Oct 13Nov 2- Failures
- This test runs only with pattern: os != 'android'
- Manifest: toolkit/components/places/tests/history/xpcshell.toml
/* Any copyright is dedicated to the Public Domain.
// Tests the userContextId (container) of visits added through the JS APIs.
"use strict";
add_task(async function test_insert_invalid_userContextId() {
for (let userContextId of [-1, 1.5, 2 ** 32, "1", {}]) {
await Assert.rejects(
PlacesUtils.history.insert({
url: TEST_URL,
visits: [{ transition: TRANSITION_LINK, userContextId }],
}),
e => e.result === Cr.NS_ERROR_INVALID_ARG,
`History.insert should reject userContextId ${String(userContextId)}`
);
}
Assert.ok(
!(await PlacesUtils.history.hasVisits(TEST_URL)),
"No visit was added"
);
});
add_task(async function test_insert_valid_userContextId() {
await PlacesUtils.history.clear();
for (let userContextId of [0, 2, 2 ** 32 - 1]) {
let url = `${TEST_URL}/${userContextId}`;
let promiseVisited = PlacesTestUtils.waitForNotification(
"page-visited",
events => events.some(e => e.url === url)
);
await PlacesUtils.history.insert({
url,
visits: [{ transition: TRANSITION_LINK, userContextId }],
});
let events = await promiseVisited;
Assert.equal(
events.find(e => e.url === url).userContextId,
userContextId,
"page-visited reports the container of the visit"
);
let db = await PlacesUtils.promiseDBConnection();
let rows = await db.execute(
`SELECT v.userContextId FROM moz_historyvisits v
JOIN moz_places h ON h.id = v.place_id
WHERE h.url_hash = hash(:url) AND h.url = :url`,
{ url }
);
Assert.deepEqual(
rows.map(r => r.getResultByName("userContextId")),
[userContextId],
"The visit is stored in the right container"
);
}
await PlacesUtils.history.clear();
});