gecko-dev/browser/components/backup/content/debug.html
Mike Conley 67df85a3a0 Bug 1897498 - Add a mechanism for exporting backup snapshots to a single file archive. r=Gijs,valentin,backup-reviewers,frontend-codestyle-reviewers,Standard8,kpatenio
There are a number of interesting things going on this patch that I think are worth highlighting
here for my reviewers:

1. The single-file archive format is an HTML file that uses an inlined multipart/mixed MIME
   message within a HTML document comment in order to embed the backup data into the archive.
2. We use the multipart/mixed nsIStreamConverter to extract the JSON and binary data from
   the MIME block.
3. We use a Archive Worker to do the archive creation, allowing us to do the work of construction
   off of the main thread.
4. The Archive Worker is only parsing the header and getting the byte offset of the MIME block.
   Extraction is happening in the parent process. This is mainly for simplicity for now, since
   the Archive Worker cannot invoke an nsIStreamConverter. Down the line, if we determine that
   we'd prefer the Archive Worker do the base64 decoding off of the main thread, we may need
   to use a Message Channel to send the byte sfrom the nsIStreamConverter to it, and add
   stream-writing support to IOUtils so that the Archive Worker can take care of sending the
   decoded bytes to disk.
5. The patch doesn't expose the extraction mechanism in any way except through the debug
   interface right now. That will come down the line. In the meantime, this mechanism
   can be manually tested in the debug interface by creating a backup, which should also
   create an "archive.html" file in the backups folder. Using the "Extract from archive"
   button in the debug tool will let you select that HTML file and extract the ZIP as
   a file in the backups folder called "extraction.zip".
6. The test template contains Unicode characters because certain locales might involve
   us writing Unicode characters in the HTML template when generating the archive. The
   fun part about that is calculating where the byte offset is for the MIME block! See
   the comment in the Archive.worker.mjs script for how that works.

Differential Revision: https://phabricator.services.mozilla.com/D211588
2024-06-11 13:05:58 +00:00

75 lines
2.7 KiB
HTML

<!-- 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 http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Profile backup debug tool</title>
<link rel="stylesheet" href="chrome://global/skin/in-content/common.css" />
</head>
<body>
<header>
<h1>Profile backup debug tool</h1>
</header>
<main>
<section>
<h2>State</h2>
<ol>
<li>
<input
type="checkbox"
preference="browser.backup.enabled"
/>BackupService component enabled
</li>
<li>
<input
type="checkbox"
preference="browser.backup.log"
/>BackupService debug logging enabled
</li>
<li>
<input id="encryption-enabled" type="checkbox" />Encryption enabled
</li>
</ol>
</section>
<section id="controls">
<h2>Controls</h2>
<button id="create-backup">Create backup</button>
<p>
Clicking "Create backup" will create a backup, and then attempt to
show an OS notification with the total time it took to create it. This
notification may not appear if your OS has not granted the browser to
display notifications.
</p>
<p id="last-backup-status"></p>
<button id="open-backup-folder">Open backups folder</button>
<button id="recover-from-staging">
Recover from staging folder and launch
</button>
<p>
Clicking "Recover from staging folder and launch" will open a file
picker to allow you to select a staging folder. Once selected, a new
user profile will be created and the data stores from the staging
folder will be copied into that new profile. The new profile will then
be launched.
</p>
<p id="last-recovery-status"></p>
<button id="extract-from-archive">Extract from archive</button>
<p id="extraction-status"></p>
<p>
Clicking "Extract from archive" will open a file picker to allow you
to select an single-file archive (the HTML file). Once selected, the
ZIP file contained inside will be extracted into the same folder,
named extraction.zip.
</p>
</section>
</main>
<script src="chrome://global/content/preferencesBindings.js"></script>
<script src="chrome://browser/content/backup/debug.js"></script>
</body>
</html>