mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-11 14:14:36 +08:00
[Dom Storage]: Handle undefined storage case
Description: There are a ton of moving parts in this code which lends itself to being out of sync at the time of these failures. Navigation, frame addition and frame removal all trigger a series of separate events that change the main security origin, remove unused origins and add new origins. The failure is occurs when ClearStorageView._securityOrigin has a mismatch of what origins are in the DOMStorageModel._storages map at the time the user clears the site data. Issue: - DomStorageModel.clearForOrigin does not protect against the case where _storages[key] is undefined Changes: - Adding !storage check to clearForOrigin - we return early because there is no storage to clear and thus a noop is expected - also if we resume execution, the following code will attempt to remove the missing storage (will result in no-op) then re-add it (will add a storage that wasn't there previously). Notes: - We don't need to worry about the mismatch in the fix since SecurityOriginManager.updateSecurityOrigins will eventually resync the available origins and their storages. Bug: 1084631 Change-Id: I7bb1abe9182e83239d63478a1c6b68feb7d6451e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2208720 Reviewed-by: Shane Clifford <shanejc@microsoft.com> Reviewed-by: Robert Paveza <Rob.Paveza@microsoft.com> Reviewed-by: Vidal Diazleal <vidorteg@microsoft.com> Commit-Queue: Michael Liao <michael.liao@microsoft.com>
This commit is contained in:
@@ -151,6 +151,9 @@ export class DOMStorageModel extends SDK.SDKModel.SDKModel {
|
||||
for (const isLocal of [true, false]) {
|
||||
const key = this._storageKey(origin, isLocal);
|
||||
const storage = this._storages[key];
|
||||
if (!storage) {
|
||||
return;
|
||||
}
|
||||
storage.clear();
|
||||
}
|
||||
this._removeOrigin(origin);
|
||||
|
||||
Reference in New Issue
Block a user