Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b6c4bd399 |
+1
-1
@@ -220,7 +220,7 @@ async function widenApprovalWindow() {
|
||||
async function init() {
|
||||
// First, before anything can save: showView() saves on every navigation
|
||||
// without awaiting, so a save that fails from here on has somewhere to be
|
||||
// reported rather than being swallowed by the save queue
|
||||
// reported rather than reaching only the console
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/362). Registered ahead of
|
||||
// the approval-window branch below too, since that window saves as well.
|
||||
//
|
||||
|
||||
@@ -143,6 +143,8 @@ async function resetProfile() {
|
||||
try {
|
||||
// Under the lock every write of the stored record takes, so the erase
|
||||
// cannot land between another write's read and its write and be undone.
|
||||
// A page in a Firefox private window is the exception: Firefox gives
|
||||
// it locks of its own (README, "Stored state and its version").
|
||||
await withLock("autistmask", () => storageRemove("autistmask"));
|
||||
} catch (e) {
|
||||
log.errorf("state recovery: reset failed:", e);
|
||||
|
||||
+2
-2
@@ -529,8 +529,8 @@ async function saveStateOnce() {
|
||||
rawState.hasWallet = rawState.wallets.length > 0;
|
||||
|
||||
// What this save compared and wrote, not the page's state now: a change
|
||||
// made during the save must still differ from the baseline, or the save
|
||||
// queued after it finds nothing to store
|
||||
// made during the save must still differ from the baseline, or the next
|
||||
// save finds nothing to store
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/448).
|
||||
baseline = current;
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ describe("a save that fails", () => {
|
||||
return storage;
|
||||
}
|
||||
|
||||
test("is reported, not swallowed by the save queue", async () => {
|
||||
test("is reported when the caller does not await it", async () => {
|
||||
const storage = failingStorage(unversionedValidProfile());
|
||||
const { state, loadState, saveState, onSaveFailure } =
|
||||
loadStateModule(storage);
|
||||
|
||||
@@ -160,7 +160,7 @@ describe("the approval-window reproduction", () => {
|
||||
await approvalWindow.state.loadState();
|
||||
approvalWindow.helpers.showView("approve-tx");
|
||||
// showView() does not await its own saveState(); an extra save
|
||||
// joins the same queue and only resolves once that one has too,
|
||||
// waits for the lock behind that one and so resolves only after it,
|
||||
// which is the black-box way to know it landed.
|
||||
await approvalWindow.state.saveState();
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
// used to be able to land between that read and that write, and the popup's
|
||||
// write then put the old network back
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/641). Every write of the record
|
||||
// now holds one lock from its read to its write.
|
||||
// now holds a lock from its read to its write.
|
||||
//
|
||||
// The popup and the background run here as the real modules over one shared
|
||||
// storage stub, and share the lock the way the extension's pages and its
|
||||
// background share the browser's (tests/support/navigatorLocks.js).
|
||||
// storage stub, and share the lock the way the background and a page outside
|
||||
// a Firefox private window share the browser's
|
||||
// (tests/support/navigatorLocks.js).
|
||||
|
||||
const { makeStorageStub } = require("./support/storageStub");
|
||||
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
// the callback settles, whether it resolved or rejected. That is what the
|
||||
// browser's own does for the one call the extension makes,
|
||||
// `navigator.locks.request(name, callback)`. Every module a test file loads
|
||||
// shares it, as every page of the extension and its background share the
|
||||
// browser's.
|
||||
// shares it, as the extension's background and its pages share the browser's,
|
||||
// except a page in a Firefox private window (README, "Stored state and its
|
||||
// version").
|
||||
//
|
||||
// Run before each test file by `setupFiles` in package.json.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user