Bug 1686727 - [devtools] Migrate browser_storage_updates to ResourceCommand. r=ladybenko

We should stop using StorageActor.listStores in favor of ResourceCommand.
listStores still forces to involve message manager in the server codebase.
This breaks when we enable JSWindowActor based targets.

Differential Revision: https://phabricator.services.mozilla.com/D116479
This commit is contained in:
Alexandre Poirot 2021-06-10 21:26:13 +00:00
Родитель 5bee607617
Коммит 406a7d2d5f
3 изменённых файлов: 36 добавлений и 32 удалений

Просмотреть файл

@ -161,7 +161,6 @@ skip-if = fission # cookies data is the correct length
[browser_storage_listings.js]
skip-if = fission
[browser_storage_updates.js]
skip-if = fission
[browser_storage_webext_storage_local.js]
[browser_style_utils_getFontPreviewData.js]
[browser_styles_getRuleText.js]

Просмотреть файл

@ -31,7 +31,7 @@ const TESTS = [
value: "foobar2",
},
],
localStorage: [
"local-storage": [
{
name: "l1",
value: "foobar1",
@ -57,7 +57,7 @@ const TESTS = [
value: "foobar2",
},
],
localStorage: [
"local-storage": [
{
name: "l1",
value: "foobar1",
@ -84,7 +84,7 @@ const TESTS = [
value: "new_foobar1",
},
],
localStorage: [
"local-storage": [
{
name: "l2",
value: "foobar2",
@ -114,13 +114,13 @@ const TESTS = [
value: "foobar3",
},
],
localStorage: [
"local-storage": [
{
name: "l3",
value: "new_foobar3",
},
],
sessionStorage: [
"session-storage": [
{
name: "s1",
value: "foobar1",
@ -145,13 +145,13 @@ const TESTS = [
value: "foobar3",
},
],
localStorage: [
"local-storage": [
{
name: "l3",
value: "new_foobar3",
},
],
sessionStorage: [
"session-storage": [
{
name: "s2",
value: "foobar2",
@ -167,13 +167,13 @@ const TESTS = [
},
snapshot: {
cookies: [],
localStorage: [
"local-storage": [
{
name: "l3",
value: "new_foobar3",
},
],
sessionStorage: [
"session-storage": [
{
name: "s2",
value: "foobar2",
@ -189,39 +189,47 @@ const TESTS = [
},
snapshot: {
cookies: [],
localStorage: [],
sessionStorage: [],
"local-storage": [],
"session-storage": [],
},
},
];
add_task(async function() {
const { target, front } = await openTabAndSetupStorage(
const { commands } = await openTabAndSetupStorage(
MAIN_DOMAIN + "storage-updates.html"
);
for (let i = 0; i < TESTS.length; i++) {
const test = TESTS[i];
await runTest(test, front, i);
await runTest(test, commands, i);
}
await finishTests(target);
await commands.destroy();
});
async function runTest({ action, snapshot }, front, index) {
async function runTest({ action, snapshot }, commands, index) {
info("Running test at index " + index);
await action();
await checkStores(front, snapshot);
await checkStores(commands, snapshot);
}
async function checkStores(front, snapshot) {
const host = TEST_DOMAIN;
const stores = await front.listStores();
const actual = {
cookies: await stores.cookies.getStoreObjects(host),
localStorage: await stores.localStorage.getStoreObjects(host),
sessionStorage: await stores.sessionStorage.getStoreObjects(host),
};
async function checkStores(commands, snapshot) {
const { resourceCommand } = commands;
const { TYPES } = resourceCommand;
const actual = {};
await resourceCommand.watchResources(
[TYPES.COOKIE, TYPES.LOCAL_STORAGE, TYPES.SESSION_STORAGE],
{
async onAvailable(resources) {
for (const resource of resources) {
actual[resource.resourceType] = await resource.getStoreObjects(
TEST_DOMAIN
);
}
},
}
);
for (const [type, entries] of Object.entries(snapshot)) {
const store = actual[type].data;
@ -252,11 +260,6 @@ function checkStoreValue(name, value, store) {
ok(false, `There is an entry for "${name}"`);
}
async function finishTests(target) {
await target.destroy();
DevToolsServer.destroy();
}
async function addCookie(name, value) {
info(`addCookie("${name}", "${value}")`);

Просмотреть файл

@ -37,9 +37,11 @@ async function openTabAndSetupStorage(url) {
}
// selected tab is set in addTab
const target = await createAndAttachTargetForTab(gBrowser.selectedTab);
const commands = await CommandsFactory.forTab(gBrowser.selectedTab);
await commands.targetCommand.startListening();
const target = commands.targetCommand.targetFront;
const front = await target.getFront("storage");
return { target, front };
return { commands, target, front };
}
async function clearStorage() {