This test can be run via: ./mach marionette-test browser/components/backup/test/marionette/test_backup.py This also makes it so that BackupResource.copySqliteDatabases does not throw if one of the passed in database files doesn't exist - it'll just ignore it and move on. This required me to update some tests in order to create some fake SQLite databases to ensure that the fake Sqlite connection was made and the backup stub was called for the SQLite databases being copied. Finally, this also fixes something I noticed - some of our BackupResource's weren't returning null or objects as their ManifestEntry. This fixes that and adds tests to cover that case. Differential Revision: https://phabricator.services.mozilla.com/D207811
33 lines
978 B
JavaScript
33 lines
978 B
JavaScript
/* 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 https://mozilla.org/MPL/2.0/. */
|
|
|
|
import { BackupResource } from "resource:///modules/backup/BackupResource.sys.mjs";
|
|
|
|
/**
|
|
* Class representing Cookies database within a user profile.
|
|
*/
|
|
export class CookiesBackupResource extends BackupResource {
|
|
static get key() {
|
|
return "cookies";
|
|
}
|
|
|
|
static get requiresEncryption() {
|
|
return true;
|
|
}
|
|
|
|
async backup(stagingPath, profilePath = PathUtils.profileDir) {
|
|
await BackupResource.copySqliteDatabases(profilePath, stagingPath, [
|
|
"cookies.sqlite",
|
|
]);
|
|
return null;
|
|
}
|
|
|
|
async measure(profilePath = PathUtils.profileDir) {
|
|
let cookiesDBPath = PathUtils.join(profilePath, "cookies.sqlite");
|
|
let cookiesSize = await BackupResource.getFileSize(cookiesDBPath);
|
|
|
|
Glean.browserBackup.cookiesSize.set(cookiesSize);
|
|
}
|
|
}
|