Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Storage Buckets to Chrome Devtools Protocol
This adds Storage Buckets to the Chrome Devtools Protocol and implements their backend. Bug: 1406017 Change-Id: I5eaf6a28b81e815bc821364ea203a786e42a20ef Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4298203 Reviewed-by: Andrey Kosyakov <caseq@chromium.org> Commit-Queue: Nathan Memmott <memmott@chromium.org> Cr-Commit-Position: refs/heads/main@{#1121438}
- Loading branch information
Nathan Memmott
authored and
Chromium LUCI CQ
committed
Mar 23, 2023
1 parent
abffa44
commit e2789f9
Showing
8 changed files
with
528 additions
and
63 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...tp/tests/inspector-protocol/storage/storage-bucket-storage-key-track-untrack-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Tests that tracking and untracking Storage Bucket for storage key works | ||
|
||
Create bucket | ||
bucket created successfully | ||
Created bucket: { | ||
durability : relaxed | ||
expiration : <number> | ||
id : <string> | ||
isDefault : false | ||
name : test-bucket | ||
persistent : false | ||
quota : 0 | ||
storageKey : <string> | ||
} | ||
bucket.expiration equals zero | ||
|
||
Update bucket | ||
bucket updated successfully | ||
Updated bucket: { | ||
durability : relaxed | ||
expiration : <number> | ||
id : <string> | ||
isDefault : false | ||
name : test-bucket | ||
persistent : false | ||
quota : 0 | ||
storageKey : <string> | ||
} | ||
bucket.expiration does not equal zero | ||
|
||
Delete bucket | ||
bucket deleted successfully | ||
Deleted bucket: { | ||
bucketId : <string> | ||
} | ||
|
||
Create another bucket after untracking. | ||
Another bucket opened successfully | ||
|
113 changes: 113 additions & 0 deletions
113
...b_tests/http/tests/inspector-protocol/storage/storage-bucket-storage-key-track-untrack.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
(async function(testRunner) { | ||
const stabilizeNames = | ||
[...TestRunner.stabilizeNames, 'storageKey', 'bucketId', 'expiration']; | ||
const {dp, session} = await testRunner.startBlank( | ||
`Tests that tracking and untracking Storage Bucket for storage key works\n`); | ||
await dp.Page.enable(); | ||
|
||
const frameId = (await dp.Page.getResourceTree()).result.frameTree.frame.id; | ||
const storageKey = (await dp.Storage.getStorageKeyForFrame({ | ||
frameId: frameId | ||
})).result.storageKey; | ||
|
||
await dp.Storage.setStorageBucketTracking({storageKey, enable: true}); | ||
|
||
{ | ||
testRunner.log(`Create bucket`); | ||
|
||
const eventPromise = dp.Storage.onceStorageBucketCreatedOrUpdated(); | ||
|
||
// Create bucket. | ||
const result = await session.evaluateAsync(` | ||
(async function() { | ||
try { | ||
await navigator.storageBuckets.open("test-bucket"); | ||
return 'bucket created successfully'; | ||
} catch (err) { | ||
return err; | ||
} | ||
})()`); | ||
|
||
testRunner.log(result); | ||
const {params: {bucket}} = await eventPromise; | ||
testRunner.log(bucket, `Created bucket: `, stabilizeNames); | ||
if (bucket.expiration === 0) { | ||
testRunner.log('bucket.expiration equals zero\n'); | ||
} else { | ||
testRunner.log(`bucket.expiration equals ${bucket.expiration}`); | ||
} | ||
} | ||
|
||
{ | ||
testRunner.log(`Update bucket`); | ||
|
||
const eventPromise = dp.Storage.onceStorageBucketCreatedOrUpdated(); | ||
|
||
// Update bucket. | ||
const result = await session.evaluateAsync(` | ||
(async function() { | ||
try { | ||
await navigator.storageBuckets.open("test-bucket", {expires: Number.MAX_SAFE_INTEGER}); | ||
return 'bucket updated successfully'; | ||
} catch (err) { | ||
return err; | ||
} | ||
})()`); | ||
|
||
testRunner.log(result); | ||
const {params: {bucket}} = await eventPromise; | ||
testRunner.log(bucket, `Updated bucket: `, stabilizeNames); | ||
if (bucket.expiration !== 0) { | ||
testRunner.log('bucket.expiration does not equal zero\n'); | ||
} else { | ||
testRunner.log(`bucket.expiration equals ${bucket.expiration}`); | ||
} | ||
} | ||
|
||
{ | ||
testRunner.log(`Delete bucket`); | ||
|
||
const eventPromise = dp.Storage.onceStorageBucketDeleted(); | ||
|
||
// Delete bucket. | ||
const result = await session.evaluateAsync(` | ||
(async function() { | ||
try { | ||
await navigator.storageBuckets.delete("test-bucket"); | ||
return 'bucket deleted successfully'; | ||
} catch (err) { | ||
return err; | ||
} | ||
})()`); | ||
|
||
testRunner.log(result); | ||
const {params} = await eventPromise; | ||
testRunner.log(params, `Deleted bucket: `, stabilizeNames); | ||
} | ||
|
||
await dp.Storage.setStorageBucketTracking({storageKey, enable: false}); | ||
|
||
{ | ||
dp.Storage.onStorageBucketCreatedOrUpdated( | ||
message => {testRunner.log(message.params.bucket)}); | ||
dp.Storage.onStorageBucketDeleted( | ||
message => {testRunner.log(message.params.bucketLocator)}); | ||
|
||
testRunner.log('\nCreate another bucket after untracking.'); | ||
|
||
// Create one more bucket. | ||
const result = await session.evaluateAsync(` | ||
(async function() { | ||
try { | ||
await navigator.storageBuckets.open("test-bucket-2"); | ||
return 'Another bucket opened successfully'; | ||
} catch (err) { | ||
return err; | ||
} | ||
})()`); | ||
|
||
testRunner.log(result); | ||
} | ||
|
||
testRunner.completeTest(); | ||
}) |
9 changes: 9 additions & 0 deletions
9
.../http/tests/inspector-protocol/storage/storage-buckets-delete-storage-bucket-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Tests that deleting a bucket works correctly | ||
|
||
Create bucket | ||
buckets added successfully | ||
Delete bucket | ||
Deleted bucket: { | ||
bucketId : <string> | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
.../web_tests/http/tests/inspector-protocol/storage/storage-buckets-delete-storage-bucket.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
(async function(testRunner) { | ||
const {dp, session} = await testRunner.startBlank( | ||
`Tests that deleting a bucket works correctly\n`); | ||
await dp.Page.enable(); | ||
|
||
const stabilizeNames = | ||
[...TestRunner.stabilizeNames, 'storageKey', 'bucketId']; | ||
|
||
const frameId = (await dp.Page.getResourceTree()).result.frameTree.frame.id; | ||
const storageKey = | ||
(await dp.Storage.getStorageKeyForFrame({frameId})).result.storageKey; | ||
await dp.Storage.setStorageBucketTracking({storageKey, enable: true}); | ||
const bucketName = 'test-bucket'; | ||
|
||
{ | ||
testRunner.log(`Create bucket`); | ||
const result = await session.evaluateAsync(` | ||
(async function() { | ||
try { | ||
await navigator.storageBuckets.open("${bucketName}"); | ||
return 'buckets added successfully'; | ||
} catch (err) { | ||
return err; | ||
} | ||
})() | ||
`); | ||
|
||
testRunner.log(result); | ||
} | ||
|
||
{ | ||
testRunner.log(`Delete bucket`); | ||
|
||
dp.Storage.deleteStorageBucket({storageKey, bucketName}); | ||
const {params} = await dp.Storage.onceStorageBucketDeleted(); | ||
testRunner.log(params, 'Deleted bucket: ', stabilizeNames); | ||
} | ||
|
||
testRunner.completeTest(); | ||
}) |