зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1666533 - [devtools] Add cache storage resource r=ochameau
This adds support for cache storage under Fission, as a content process storage resource. Differential Revision: https://phabricator.services.mozilla.com/D106291
This commit is contained in:
Родитель
8cc760e83a
Коммит
38e790f113
|
@ -3,6 +3,8 @@ tags = devtools
|
|||
subsuite = devtools
|
||||
support-files =
|
||||
storage-blank.html
|
||||
storage-cache-basic-iframe.html
|
||||
storage-cache-basic.html
|
||||
storage-cache-error.html
|
||||
storage-complex-values.html
|
||||
storage-cookies.html
|
||||
|
@ -70,6 +72,7 @@ tags = usercontextid
|
|||
[browser_storage_dynamic_updates_sessionStorage.js]
|
||||
[browser_storage_empty_objectstores.js]
|
||||
[browser_storage_file_url.js]
|
||||
[browser_storage_fission_cache.js]
|
||||
[browser_storage_fission_hide_aboutblank.js]
|
||||
[browser_storage_fission_local_storage.js]
|
||||
[browser_storage_fission_session_storage.js]
|
||||
|
|
|
@ -64,6 +64,6 @@ function checkCacheData(url, status) {
|
|||
is(
|
||||
gUI.table.items.get(url)?.status,
|
||||
status,
|
||||
`Table row has an entry for: ${name} with status: ${status}`
|
||||
`Table row has an entry for: ${url} with status: ${status}`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* import-globals-from head.js */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function() {
|
||||
// open tab
|
||||
const URL = URL_ROOT_COM + "storage-cache-basic.html";
|
||||
await openTabAndSetupStorage(URL);
|
||||
const doc = gPanelWindow.document;
|
||||
|
||||
// check that host appears in the storage tree
|
||||
checkTree(doc, ["Cache", "http://example.com", "lorem"]);
|
||||
checkTree(doc, ["Cache", "http://example.net", "foo"]);
|
||||
// Check top level page
|
||||
await selectTreeItem(["Cache", "http://example.com", "lorem"]);
|
||||
checkCacheData(URL_ROOT_COM + "storage-blank.html", "OK");
|
||||
// Check iframe
|
||||
await selectTreeItem(["Cache", "http://example.net", "foo"]);
|
||||
checkCacheData(URL_ROOT_NET + "storage-blank.html", "OK");
|
||||
});
|
||||
|
||||
function checkCacheData(url, status) {
|
||||
is(
|
||||
gUI.table.items.get(url)?.status,
|
||||
status,
|
||||
`Table row has an entry for: ${url} with status: ${status}`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Storage inspector test for Cache</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Cache (iframe)</h1>
|
||||
<script>
|
||||
"use strict";
|
||||
async function setup() { // eslint-disable-line no-unused-vars
|
||||
caches.open("foo").then(cache => {
|
||||
cache.add("storage-blank.html");
|
||||
});
|
||||
}
|
||||
function clear() { // eslint-disable-line no-unused-vars
|
||||
caches.delete("foo");
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Storage inspector test for Cache</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Cache</h1>
|
||||
<script>
|
||||
"use strict";
|
||||
async function setup() { // eslint-disable-line no-unused-vars
|
||||
caches.open("lorem").then(cache => {
|
||||
cache.add("storage-blank.html");
|
||||
});
|
||||
}
|
||||
function clear() { // eslint-disable-line no-unused-vars
|
||||
caches.delete("lorem");
|
||||
}
|
||||
</script>
|
||||
|
||||
<iframe src="http://example.net/browser/devtools/client/storage/test/storage-cache-basic-iframe.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -12,14 +12,16 @@ const TYPES = {
|
|||
CSS_MESSAGE: "css-message",
|
||||
DOCUMENT_EVENT: "document-event",
|
||||
ERROR_MESSAGE: "error-message",
|
||||
LOCAL_STORAGE: "local-storage",
|
||||
PLATFORM_MESSAGE: "platform-message",
|
||||
NETWORK_EVENT: "network-event",
|
||||
SESSION_STORAGE: "session-storage",
|
||||
STYLESHEET: "stylesheet",
|
||||
NETWORK_EVENT_STACKTRACE: "network-event-stacktrace",
|
||||
SOURCE: "source",
|
||||
THREAD_STATE: "thread-state",
|
||||
// storage types
|
||||
CACHE_STORAGE: "Cache",
|
||||
LOCAL_STORAGE: "local-storage",
|
||||
SESSION_STORAGE: "session-storage",
|
||||
};
|
||||
exports.TYPES = TYPES;
|
||||
|
||||
|
@ -33,6 +35,9 @@ exports.TYPES = TYPES;
|
|||
// Each module exports a Resource Watcher class.
|
||||
// These lists are specific for the parent process and each target type.
|
||||
const FrameTargetResources = augmentResourceDictionary({
|
||||
[TYPES.CACHE_STORAGE]: {
|
||||
path: "devtools/server/actors/resources/storage-cache",
|
||||
},
|
||||
[TYPES.CONSOLE_MESSAGE]: {
|
||||
path: "devtools/server/actors/resources/console-messages",
|
||||
},
|
||||
|
|
|
@ -19,6 +19,7 @@ DevToolsModules(
|
|||
"network-events.js",
|
||||
"platform-messages.js",
|
||||
"sources.js",
|
||||
"storage-cache.js",
|
||||
"storage-local-storage.js",
|
||||
"storage-session-storage.js",
|
||||
"stylesheets.js",
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
TYPES: { CACHE_STORAGE },
|
||||
} = require("devtools/server/actors/resources/index");
|
||||
|
||||
const ContentProcessStorage = require("devtools/server/actors/resources/utils/content-process-storage");
|
||||
|
||||
class CacheWatcher extends ContentProcessStorage {
|
||||
constructor() {
|
||||
super("Cache", CACHE_STORAGE);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CacheWatcher;
|
|
@ -47,6 +47,11 @@ class ContentProcessStorage {
|
|||
this.storageActor = storageActor;
|
||||
this.actor = new ActorConstructor(storageActor);
|
||||
|
||||
// Some storage types require to prelist their stores
|
||||
if (typeof this.actor.preListStores === "function") {
|
||||
await this.actor.preListStores();
|
||||
}
|
||||
|
||||
// We have to manage the actor manually, because ResourceWatcher doesn't
|
||||
// use the protocol.js specification.
|
||||
// resource-available-form is typed as "json"
|
||||
|
|
|
@ -3429,6 +3429,7 @@ const StorageActor = protocol.ActorClassWithSpec(specs.storageSpec, {
|
|||
false
|
||||
);
|
||||
const resourcesInWatcher = {
|
||||
Cache: isWatcherEnabled,
|
||||
localStorage: isWatcherEnabled,
|
||||
sessionStorage: isWatcherEnabled,
|
||||
};
|
||||
|
|
|
@ -147,6 +147,7 @@ exports.WatcherActor = protocol.ActorClassWithSpec(watcherSpec, {
|
|||
[Resources.TYPES.CSS_CHANGE]: hasBrowserElement,
|
||||
[Resources.TYPES.CSS_MESSAGE]: hasBrowserElement,
|
||||
[Resources.TYPES.DOCUMENT_EVENT]: hasBrowserElement,
|
||||
[Resources.TYPES.CACHE_STORAGE]: hasBrowserElement,
|
||||
[Resources.TYPES.ERROR_MESSAGE]: hasBrowserElement,
|
||||
[Resources.TYPES.LOCAL_STORAGE]: hasBrowserElement,
|
||||
[Resources.TYPES.SESSION_STORAGE]: hasBrowserElement,
|
||||
|
|
|
@ -975,12 +975,12 @@ const LegacyListeners = {
|
|||
.WEBSOCKET]: require("devtools/shared/resources/legacy-listeners/websocket"),
|
||||
[ResourceWatcher.TYPES
|
||||
.COOKIE]: require("devtools/shared/resources/legacy-listeners/cookie"),
|
||||
[ResourceWatcher.TYPES
|
||||
.CACHE_STORAGE]: require("devtools/shared/resources/legacy-listeners/cache-storage"),
|
||||
[ResourceWatcher.TYPES
|
||||
.LOCAL_STORAGE]: require("devtools/shared/resources/legacy-listeners/local-storage"),
|
||||
[ResourceWatcher.TYPES
|
||||
.SESSION_STORAGE]: require("devtools/shared/resources/legacy-listeners/session-storage"),
|
||||
[ResourceWatcher.TYPES
|
||||
.CACHE_STORAGE]: require("devtools/shared/resources/legacy-listeners/cache-storage"),
|
||||
[ResourceWatcher.TYPES
|
||||
.EXTENSION_STORAGE]: require("devtools/shared/resources/legacy-listeners/extension-storage"),
|
||||
[ResourceWatcher.TYPES
|
||||
|
@ -1004,6 +1004,8 @@ const ResourceTransformers = {
|
|||
.CONSOLE_MESSAGE]: require("devtools/shared/resources/transformers/console-messages"),
|
||||
[ResourceWatcher.TYPES
|
||||
.ERROR_MESSAGE]: require("devtools/shared/resources/transformers/error-messages"),
|
||||
[ResourceWatcher.TYPES
|
||||
.CACHE_STORAGE]: require("devtools/shared/resources/transformers/storage-cache.js"),
|
||||
[ResourceWatcher.TYPES
|
||||
.LOCAL_STORAGE]: require("devtools/shared/resources/transformers/storage-local-storage.js"),
|
||||
[ResourceWatcher.TYPES
|
||||
|
|
|
@ -6,6 +6,7 @@ DevToolsModules(
|
|||
"console-messages.js",
|
||||
"error-messages.js",
|
||||
"network-events.js",
|
||||
"storage-cache.js",
|
||||
"storage-local-storage.js",
|
||||
"storage-session-storage.js",
|
||||
"thread-states.js",
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
TYPES: { CACHE_STORAGE },
|
||||
} = require("devtools/shared/resources/resource-watcher");
|
||||
|
||||
const { Front, types } = require("devtools/shared/protocol.js");
|
||||
|
||||
module.exports = function({ resource, watcherFront, targetFront }) {
|
||||
if (!(resource instanceof Front) && watcherFront) {
|
||||
// instantiate front for local storage
|
||||
resource = types.getType("Cache").read(resource, targetFront);
|
||||
resource.resourceType = CACHE_STORAGE;
|
||||
resource.resourceId = CACHE_STORAGE;
|
||||
resource.resourceKey = "Cache";
|
||||
}
|
||||
|
||||
return resource;
|
||||
};
|
Загрузка…
Ссылка в новой задаче