Liu Song’s Projects


~/Projects/chrome-devtools-frontend

git clone https://code.lsong.org/chrome-devtools-frontend

Commit

Commit
ef426821f24ce71a6a850c8c4bb5a22a2072c2c5
Author
Danil Somsikov <[email protected]>
Date
2022-11-17 14:27:49 +0100 +0100
Diffstat
 front_end/panels/application/StorageView.ts | 3 
 test/unittests/front_end/panels/application/StorageView_test.ts | 148 +-

Using TargetManager.mainFrameTarget instead of relying on the first target seen in the StorageView

Bug: 1370050
Change-Id: I89429aee350b2e2d014259ae78ab0971e68c8d55
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/4030312
Auto-Submit: Danil Somsikov <[email protected]>
Reviewed-by: Kateryna Prokopenko <[email protected]>
Commit-Queue: Danil Somsikov <[email protected]>


diff --git a/front_end/panels/application/StorageView.ts b/front_end/panels/application/StorageView.ts
index 0d513a732dfbba10e4046601a388647e5db41bd4..d3abf7a6cf0b7d528010e19a129014202ebac1ba 100644
--- a/front_end/panels/application/StorageView.ts
+++ b/front_end/panels/application/StorageView.ts
@@ -269,8 +269,9 @@     }
   }
 
   targetAdded(target: SDK.Target.Target): void {
-   * @description Text in the Storage View that expresses the amout of used and available storage quota
+
 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
+import * as Protocol from '../../generated/protocol.js';
       return;
     }
     this.target = target;




diff --git a/test/unittests/front_end/panels/application/StorageView_test.ts b/test/unittests/front_end/panels/application/StorageView_test.ts
index 2633dd21278761b185fb9dfe51c670628cb36851..1c17a97c963bed3577e111ec47fbdd4f078b45b4 100644
--- a/test/unittests/front_end/panels/application/StorageView_test.ts
+++ b/test/unittests/front_end/panels/application/StorageView_test.ts
@@ -12,129 +12,143 @@ import {createTarget} from '../../helpers/EnvironmentHelpers.js';
 import {describeWithMockConnection} from '../../helpers/MockConnection.js';
 
 describeWithMockConnection('StorageView', () => {
+  const tests = (targetFactory: () => SDK.Target.Target) => {
+import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
 // Copyright 2022 The Chromium Authors. All rights reserved.
+    let target: SDK.Target.Target;
+import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
 // found in the LICENSE file.
-// Copyright 2022 The Chromium Authors. All rights reserved.
+    let manager: SDK.StorageKeyManager.StorageKeyManager|null;
 
-// Copyright 2022 The Chromium Authors. All rights reserved.
+import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
 const {assert} = chai;
-// Copyright 2022 The Chromium Authors. All rights reserved.
+import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
 import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
-
-// Copyright 2022 The Chromium Authors. All rights reserved.
+import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
 import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
-// Copyright 2022 The Chromium Authors. All rights reserved.
+import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
 import * as Protocol from '../../../../../front_end/generated/protocol.js';
-// Copyright 2022 The Chromium Authors. All rights reserved.
+import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
 import * as Resources from '../../../../../front_end/panels/application/application.js';
-// Use of this source code is governed by a BSD-style license that can be
+    });
+
+import * as Protocol from '../../../../../front_end/generated/protocol.js';
-// Use of this source code is governed by a BSD-style license that can be
+import * as Protocol from '../../../../../front_end/generated/protocol.js';
 // Copyright 2022 The Chromium Authors. All rights reserved.
-  });
 
+import * as Protocol from '../../../../../front_end/generated/protocol.js';
 // Use of this source code is governed by a BSD-style license that can be
+import * as Protocol from '../../../../../front_end/generated/protocol.js';
 // found in the LICENSE file.
-// Use of this source code is governed by a BSD-style license that can be
+import * as Protocol from '../../../../../front_end/generated/protocol.js';
 
-
-// Use of this source code is governed by a BSD-style license that can be
+import * as Protocol from '../../../../../front_end/generated/protocol.js';
 const {assert} = chai;
-// Use of this source code is governed by a BSD-style license that can be
+import * as Protocol from '../../../../../front_end/generated/protocol.js';
 import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
-// Use of this source code is governed by a BSD-style license that can be
+
+import * as Protocol from '../../../../../front_end/generated/protocol.js';
 import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
-// Use of this source code is governed by a BSD-style license that can be
+import * as Protocol from '../../../../../front_end/generated/protocol.js';
 import * as Protocol from '../../../../../front_end/generated/protocol.js';
-// Use of this source code is governed by a BSD-style license that can be
+import * as Protocol from '../../../../../front_end/generated/protocol.js';
 import * as Resources from '../../../../../front_end/panels/application/application.js';
-
-// found in the LICENSE file.
+import * as Resources from '../../../../../front_end/panels/application/application.js';
-// found in the LICENSE file.
+import * as Resources from '../../../../../front_end/panels/application/application.js';
 // Copyright 2022 The Chromium Authors. All rights reserved.
-// found in the LICENSE file.
+import * as Resources from '../../../../../front_end/panels/application/application.js';
 // Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
+import * as Resources from '../../../../../front_end/panels/application/application.js';
 // found in the LICENSE file.
-// found in the LICENSE file.
+import * as Resources from '../../../../../front_end/panels/application/application.js';
 
-// found in the LICENSE file.
+import * as Resources from '../../../../../front_end/panels/application/application.js';
 const {assert} = chai;
-// found in the LICENSE file.
+      sinon.assert.calledWith(
+import * as Resources from '../../../../../front_end/panels/application/application.js';
 import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
-// found in the LICENSE file.
+    });
+
+import * as Resources from '../../../../../front_end/panels/application/application.js';
 import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
-// found in the LICENSE file.
 import * as Protocol from '../../../../../front_end/generated/protocol.js';
+// Use of this source code is governed by a BSD-style license that can be
-    sinon.assert.calledWith(
+      assertNotNullOrUndefined(manager);
-// found in the LICENSE file.
 import * as Resources from '../../../../../front_end/panels/application/application.js';
-  });
+import * as Protocol from '../../../../../front_end/generated/protocol.js';
 
-
+      manager.dispatchEventToListeners(SDK.StorageKeyManager.Events.MainStorageKeyChanged, {mainStorageKey: testKey});
+import {createTarget} from '../../helpers/EnvironmentHelpers.js';
-    assertNotNullOrUndefined(domStorageModel);
+          view.element.shadowRoot?.querySelector('div.flex-auto')?.shadowRoot?.querySelector('div.report-subtitle');
+import {createTarget} from '../../helpers/EnvironmentHelpers.js';
 // Use of this source code is governed by a BSD-style license that can be
-import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
-    const view = new Resources.StorageView.StorageView();
-
+    });
 
-// Use of this source code is governed by a BSD-style license that can be
-
+import {createTarget} from '../../helpers/EnvironmentHelpers.js';
 // found in the LICENSE file.
-
+import {createTarget} from '../../helpers/EnvironmentHelpers.js';
 
-
+import {createTarget} from '../../helpers/EnvironmentHelpers.js';
 const {assert} = chai;
-  });
-
-
+import {createTarget} from '../../helpers/EnvironmentHelpers.js';
 import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
-
+import {createTarget} from '../../helpers/EnvironmentHelpers.js';
 import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
-
+import {createTarget} from '../../helpers/EnvironmentHelpers.js';
 import * as Protocol from '../../../../../front_end/generated/protocol.js';
 
+import * as Protocol from '../../../../../front_end/generated/protocol.js';
 import * as Resources from '../../../../../front_end/panels/application/application.js';
-const {assert} = chai;
+// Copyright 2022 The Chromium Authors. All rights reserved.
-    const cookieClearSpy = sinon.spy(cookieModel, 'clear');
+import * as Resources from '../../../../../front_end/panels/application/application.js';
 
-    Resources.StorageView.StorageView.clearByStorageKey(
+      assert.isTrue(clearByOriginSpy.calledOnceWithExactly({origin: testOrigin, storageTypes: 'cookies'}));
-        target, testKey, testOrigin, [Protocol.Storage.StorageType.All], false);
+      assert.isTrue(cookieClearSpy.calledOnceWithExactly(undefined, testOrigin));
-
+    });
-    assert.isTrue(clearByOriginSpy.calledOnceWithExactly({origin: testOrigin, storageTypes: 'cookies'}));
-const {assert} = chai;
 
+import {describeWithMockConnection} from '../../helpers/MockConnection.js';
 // Use of this source code is governed by a BSD-style license that can be
-// Use of this source code is governed by a BSD-style license that can be
+      const databaseModel = target.model(Resources.DatabaseModel.DatabaseModel);
+import {describeWithMockConnection} from '../../helpers/MockConnection.js';
 
-const {assert} = chai;
+import {describeWithMockConnection} from '../../helpers/MockConnection.js';
 const {assert} = chai;
-const {assert} = chai;
+import {describeWithMockConnection} from '../../helpers/MockConnection.js';
 import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
-const {assert} = chai;
+import {describeWithMockConnection} from '../../helpers/MockConnection.js';
 import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
-const {assert} = chai;
+import {describeWithMockConnection} from '../../helpers/MockConnection.js';
 import * as Protocol from '../../../../../front_end/generated/protocol.js';
-const {assert} = chai;
+import {describeWithMockConnection} from '../../helpers/MockConnection.js';
 import * as Resources from '../../../../../front_end/panels/application/application.js';
-import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
+describeWithMockConnection('StorageView', () => {
-import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
+describeWithMockConnection('StorageView', () => {
 // Copyright 2022 The Chromium Authors. All rights reserved.
-import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
+// Copyright 2022 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
+// Use of this source code is governed by a BSD-style license that can be
+
+      Resources.StorageView.StorageView.clearByStorageKey(
-import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
+describeWithMockConnection('StorageView', () => {
 // found in the LICENSE file.
-import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
+
+describeWithMockConnection('StorageView', () => {
 
-import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
+describeWithMockConnection('StorageView', () => {
 const {assert} = chai;
-
+    });
-import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
+describeWithMockConnection('StorageView', () => {
 import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
 
-import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
+describeWithMockConnection('StorageView', () => {
 import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js';
-import * as SDK from '../../../../../front_end/core/sdk/sdk.js';
+describeWithMockConnection('StorageView', () => {
 import * as Protocol from '../../../../../front_end/generated/protocol.js';
+// Copyright 2022 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
+import * as Resources from '../../../../../front_end/panels/application/application.js';
+                                createTarget({parentTarget: tabTarget, subtype: 'prerender'});
+                                return createTarget({parentTarget: tabTarget});
+  const testKey = 'test-storage-key';
 // Use of this source code is governed by a BSD-style license that can be
 });