44
55import { assert } from 'chai' ;
66
7- import { click , getBrowserAndPages , waitForFunction } from '../../shared/helper.js' ;
87import {
98 getPieChartLegendRows ,
109 getQuotaUsage ,
1110 navigateToApplicationTab ,
1211 navigateToStorage ,
1312 waitForQuotaUsage ,
14- } from '../helpers/application-helpers.js' ;
13+ } from '../../e2e/helpers/application-helpers.js' ;
14+ import type { DevToolsPage } from '../shared/frontend-helper.js' ;
15+ import type { InspectedPage } from '../shared/target-helper.js' ;
1516
1617// The parent suffix makes sure we wait for the Cookies item to have children before trying to click it.
1718const CLEAR_SITE_DATA_BUTTON_SELECTOR = '#storage-view-clear-button' ;
1819
20+ async function navigateToAppStorage ( devToolsPage : DevToolsPage , inspectedPage : InspectedPage ) {
21+ await navigateToApplicationTab ( 'storage-quota' , devToolsPage , inspectedPage ) ;
22+ await navigateToStorage ( devToolsPage ) ;
23+ }
24+
1925describe ( 'The Application Tab' , ( ) => {
2026 describe ( 'contains a Storage pane' , function ( ) {
21- // The tests in this suite are particularly slow, as they perform a lot of actions
22- this . timeout ( 20000 ) ;
23- beforeEach ( async ( ) => {
24- await navigateToApplicationTab ( 'storage-quota' ) ;
25- await navigateToStorage ( ) ;
26- } ) ;
27+ // TODO (liviurau): Update navigateToApplicationTab helper to work in docked
28+ // mode and remove the setup below.
29+ setup ( { dockingMode : 'undocked' } ) ;
2730
28- it ( 'which clears storage correctly using the clear button' , async ( ) => {
29- const { target } = getBrowserAndPages ( ) ;
30- await target . bringToFront ( ) ;
31- await target . evaluate ( async ( ) => {
31+ it ( 'which clears storage correctly using the clear button' , async ( { devToolsPage , inspectedPage } ) => {
32+ await navigateToAppStorage ( devToolsPage , inspectedPage ) ;
33+ await inspectedPage . bringToFront ( ) ;
34+ await inspectedPage . evaluate ( async ( ) => {
3235 const array : number [ ] = [ ] ;
3336 for ( let i = 0 ; i < 20000 ; i ++ ) {
3437 array . push ( i % 10 ) ;
@@ -41,23 +44,21 @@ describe('The Application Tab', () => {
4144 await new Promise ( resolve => addIDBValue ( resolve , 'Database1' , 'Store1' , { key : 1 , value : array } , '' ) ) ;
4245 } ) ;
4346
44- await waitForQuotaUsage ( quota => quota > 800 ) ;
47+ await waitForQuotaUsage ( quota => quota > 800 , devToolsPage ) ;
4548
4649 // We may click too early. If the total quota exceeds 2999, some remaining
4750 // quota may show. Instead,
4851 // try to click another time, if necessary.
49- await waitForFunction ( async ( ) => {
50- await click ( CLEAR_SITE_DATA_BUTTON_SELECTOR , { clickOptions : { delay : 250 } } ) ;
51- const quota = await getQuotaUsage ( ) ;
52+ await devToolsPage . waitForFunction ( async ( ) => {
53+ await devToolsPage . click ( CLEAR_SITE_DATA_BUTTON_SELECTOR , { clickOptions : { delay : 250 } } ) ;
54+ const quota = await getQuotaUsage ( devToolsPage ) ;
5255 return quota === 0 ;
5356 } ) ;
5457 } ) ;
5558
56- // Fails because backend does not report IndexedDb quoate after clearing site data.
57- it . skip ( '[crbug.com/347114248] which reports storage correctly, including the pie chart legend' , async ( ) => {
58- const { target} = getBrowserAndPages ( ) ;
59-
60- await target . evaluate ( async ( ) => {
59+ it ( 'which reports storage correctly, including the pie chart legend' , async ( { devToolsPage, inspectedPage} ) => {
60+ await navigateToAppStorage ( devToolsPage , inspectedPage ) ;
61+ await inspectedPage . evaluate ( async ( ) => {
6162 const array : number [ ] = [ ] ;
6263 for ( let i = 0 ; i < 20000 ; i ++ ) {
6364 array . push ( i % 10 ) ;
@@ -70,9 +71,9 @@ describe('The Application Tab', () => {
7071 await new Promise ( resolve => addIDBValue ( resolve , 'Database1' , 'Store1' , { key : 1 , value : array } , '' ) ) ;
7172 } ) ;
7273
73- await waitForQuotaUsage ( quota => quota > 800 ) ;
74+ await waitForQuotaUsage ( quota => quota > 800 , devToolsPage ) ;
7475
75- const rows = await getPieChartLegendRows ( ) ;
76+ const rows = await getPieChartLegendRows ( devToolsPage ) ;
7677 // Only assert that the legend entries are correct.
7778 assert . lengthOf ( rows , 2 ) ;
7879 assert . strictEqual ( rows [ 0 ] [ 2 ] , 'IndexedDB' ) ;
0 commit comments