Closed
Bug 1003860
Opened 10 years ago
Closed 8 years ago
Support DOM Cache with storage inspector
Categories
(DevTools :: Storage Inspector, defect)
DevTools
Storage Inspector
Tracking
(firefox47 fixed)
RESOLVED
FIXED
Firefox 47
Tracking | Status | |
---|---|---|
firefox47 | --- | fixed |
People
(Reporter: overholt, Assigned: ochameau)
References
(Blocks 1 open bug, )
Details
(Keywords: dev-doc-needed)
Attachments
(3 files, 5 obsolete files)
4.14 KB,
patch
|
miker
:
review+
|
Details | Diff | Splinter Review |
10.12 KB,
patch
|
ochameau
:
review+
|
Details | Diff | Splinter Review |
13.76 KB,
patch
|
ochameau
:
review+
|
Details | Diff | Splinter Review |
Much like winter, Service Workers are coming and with them, their Cache API: https://github.com/slightlyoff/ServiceWorker/blob/master/caching.md Alongside IDB and other storage inspection, we should support the Service Worker Cache.
Comment 1•10 years ago
|
||
(In reply to Andrew Overholt [:overholt] from comment #0) > Much like winter, Service Workers are coming and with them, their Cache API: "Much like winter" ^.^ XD
Comment 2•10 years ago
|
||
mass component move . filter on #MassComponentMoveStorageInspector
Component: Developer Tools → Developer Tools: Storage Inspector
Comment 3•10 years ago
|
||
I'm hopeful this can be implemented using the existing C++ API in CacheStorage.h and Cache.h. The main thing you need is an nsIPrincipal for the page whose Cache you want to inspect. Optimizer, does this sound like something you have available in devtools?
Flags: needinfo?(scrapmachines)
(In reply to Ben Kelly [:bkelly] from comment #3) > I'm hopeful this can be implemented using the existing C++ API in > CacheStorage.h and Cache.h. The main thing you need is an nsIPrincipal for > the page whose Cache you want to inspect. > > Optimizer, does this sound like something you have available in devtools? Not at the moment but I am sure we can bake it in. Also see bug 1133601.
Flags: needinfo?(scrapmachines)
Assignee: nobody → mratcliffe
Assignee | ||
Comment 5•9 years ago
|
||
(In reply to Ben Kelly [:bkelly] from comment #3) > I'm hopeful this can be implemented using the existing C++ API in > CacheStorage.h and Cache.h. The main thing you need is an nsIPrincipal for > the page whose Cache you want to inspect. Yes we can. Vivien crafted me this hacky patch in order to retrieve the `caches` object for a given principal. That would be great if you could provide a less hacky patch, actually landable or/and sync-up with vivien: https://github.com/ochameau/mozilla-central/commit/f4e9665ae456f2771b1080224f30ae853a3e9bb1 Here is a small snippet to use it: Cu.import("resource://gre/modules/Services.jsm"); var url = 'http://gaiamobile.org/fm/app/views/main/index.html'; var uri = Services.io.newURI(url, null, null); var principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri); var win = Services.appShell.hiddenDOMWindow; // XXX Don't use |caches| as a name of the variable if the code runs into a window, // as it is a read-only property of window and the next read will return the caches // object of the current window. // The second argument is a boolean indicating if you want to get |content| cache // or |chrome| cache. // The |content| cache is the cache explicitely named in the service worker, and // controlled by the app. // The |chrome| cache is the cache implicitely cached by the platform, hosting the // source file of the service worker. var c = win.getMozCaches(principal, true); // XXX Seems like there is a bug if we don't put that on the next tick. // The promise just return |false|. This is weird. setTimeout(function() { c.keys().then(function(names) { alert(names); }); }); On top of that, to prove that we can actually use such approach I crafted this prototype within the storage actor: https://github.com/ochameau/mozilla-central/commit/59aac75743d3d2c31be203bc990bfb90c0d9ecd4
Comment 6•9 years ago
|
||
Its not that hacky. I think the main thing I would do differently is just make it a [ChromeOnly] Constructor on CacheStorage. Also, a webidl enumeration for the content-vs-chrome namespace. So your example would change to: Cu.import("resource://gre/modules/Services.jsm"); var url = 'http://gaiamobile.org/fm/app/views/main/index.html'; var uri = Services.io.newURI(url, null, null); var principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri); var c = new CacheStorage(principal, 'content'); This following does seem like a bug. It may be something we are seeing in another test as well. I'm not sure whats going on there yet, though. // XXX Seems like there is a bug if we don't put that on the next tick. // The promise just return |false|. This is weird. setTimeout(function() { c.keys().then(function(names) { alert(names); });
Comment 7•9 years ago
|
||
> // XXX Seems like there is a bug if we don't put that on the next tick.
> // The promise just return |false|. This is weird.
Does it resolve false or does it reject with an error?
Assignee | ||
Comment 9•9 years ago
|
||
I don't know, that's something vivien reported. I just did what he suggested ;) But I got his confirmation, yes, the promise resolves to false... I didn't knew about Chrome Constructor feature, that sounds like a great option!
Flags: needinfo?(poirot.alex)
Comment 10•9 years ago
|
||
A way to explore the offline caches per domain was something discussed as desirable during the Service Workers work week in Madrid, adding the corresponding dependency. Thanks!
Blocks: ServiceWorkers-B2G
Updated•9 years ago
|
Status: NEW → ASSIGNED
Unassigning myself from this until I have more time.
Assignee: mratcliffe → nobody
Status: ASSIGNED → NEW
Reporter | ||
Updated•9 years ago
|
Reporter | ||
Comment 12•9 years ago
|
||
Cache is on Window, too.
Summary: Support Service Worker cache with storage inspector → Support DOM Cache with storage inspector
Assignee | ||
Comment 13•9 years ago
|
||
This patch now uses the chrome constructor, so no more hack involved. Seems to work fine in e10s/non-e10s. But there is an issue with cross domain requests. As for the web content, we get access to an "opaque" Response object, which doesn't let us know anything about the response. So it doesn't allow us to tell what is the final status of the request. We would need some platform magic for that. Also, the actor doesn't tell us when there is new cache entry, so you would have to reload the toolbox to see the changes. I'm not sure Storage inspector already supports that? Otherwise, storage inspector has a size limit which is quite painful for Cache storage as you can easily have more than 50 entries. I imagine we could have a first iteration with just the request URL, and keep the response status for a next iteration, associated with a platform patch? So that, we would mostly just need a test for this current patch.
Comment 14•9 years ago
|
||
We can add a way to get the inner response from chrome script. That way all hidden values could be inspected regardless of response type. Would that help?
Assignee | ||
Comment 15•9 years ago
|
||
(In reply to Ben Kelly [:bkelly] from comment #14) > We can add a way to get the inner response from chrome script. That way all > hidden values could be inspected regardless of response type. Would that > help? Yes. Exactly that.
Assignee | ||
Comment 16•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=d9b0af12f618
Assignee | ||
Comment 17•8 years ago
|
||
Using :bkelly platform improvement to get response value. With a mochitest. If tree is green, this patch is ready for review.
Assignee | ||
Updated•8 years ago
|
Attachment #8705202 -
Attachment is obsolete: true
Comment 18•8 years ago
|
||
Comment on attachment 8707962 [details] [diff] [review] patch v2 Review of attachment 8707962 [details] [diff] [review]: ----------------------------------------------------------------- ::: devtools/server/actors/storage.js @@ +997,5 @@ > + let response = yield cache.match(request); > + // Unwrap the response to get access to all its properties if the > + // response happen to be 'opaque', when it is a Cross Origin Request. > + response = response.cloneUnfiltered(); > + results.push(yield this.processEntry(request, response)); Note, the result of cloneUnfiltered() will always have Response.type === 'default'. You probably want to track the original response type separately so it can be shown.
Assignee | ||
Comment 19•8 years ago
|
||
(In reply to Ben Kelly [:bkelly] from comment #18) > Comment on attachment 8707962 [details] [diff] [review] > patch v2 > > Review of attachment 8707962 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: devtools/server/actors/storage.js > @@ +997,5 @@ > > + let response = yield cache.match(request); > > + // Unwrap the response to get access to all its properties if the > > + // response happen to be 'opaque', when it is a Cross Origin Request. > > + response = response.cloneUnfiltered(); > > + results.push(yield this.processEntry(request, response)); > > Note, the result of cloneUnfiltered() will always have Response.type === > 'default'. You probably want to track the original response type separately > so it can be shown. For now, I just display what Chrome displays: Request URL and Response Status-text. We can surely show more information as we have it. But it sounds like a good followup. Storage panel doesn't have a very flexible UI. So it may be more chanllenging to put more data on screen. Also I would need some help in what is good to be displayed as I'm not dogfooding much service workers/cache storage and don't really know what is really useful.
Assignee: nobody → poirot.alex
Assignee | ||
Comment 20•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=90544ed48909
Assignee | ||
Comment 21•8 years ago
|
||
Same patch with multiple splits to help the review. I don't know how this used to actually work, but that setup code was really cryptic and it is hard to say it guarantees the indexedDB conditions. createObjectStore *has* to be called within onupgradeended callback. This patch makes it clear that we apply indexedDB conditions and also stop doing these weirds `yield undefined;` to instead do very basic Task.jsm code... This helps me introducing new setup code for Cache storage in next patch!
Attachment #8709017 -
Flags: review?(mratcliffe)
Assignee | ||
Updated•8 years ago
|
Attachment #8707962 -
Attachment is obsolete: true
Assignee | ||
Comment 22•8 years ago
|
||
Main part of the patch. Introduces the actor bits. I copied most logic from indexed db and then used the various tricks :bkelly exposed (new CacheStorage() and cloneUnfiltered()) to fetch the Cache storage data. This patch also introduces a test for this new feature. The data displayed for Cache storage is very basic. It matches what Chromium already displays. Just the request URL and the response status text. We can followup to display more! Also, in tests, I toggle 'dom.caches.testing.enabled' pref to make it work as tests are loading html pages on http:// whereas Cache API is only available on https://.
Attachment #8709021 -
Flags: review?(mratcliffe)
Assignee | ||
Comment 23•8 years ago
|
||
Random modifications that helped me working on this patch... I'll comment them in individually.
Attachment #8709022 -
Flags: review?(mratcliffe)
Assignee | ||
Comment 24•8 years ago
|
||
Comment on attachment 8709022 [details] [diff] [review] Various tweaks - v1 Review of attachment 8709022 [details] [diff] [review]: ----------------------------------------------------------------- ::: devtools/client/storage/panel.js @@ +59,5 @@ > return this; > + }).catch(e => { > + console.log("error while opening storage panel", e); > + this.destroy(); > + }); Today, if any exception happens in this code, it is completely ignored, not printed anywhere and the storage panel is destroyed and some other random stuff ends up breaking. Or, in my case, I was lucky that destroy was throwing and having a stack trace going back to this line! With this patch, we immediately print the exception with the right stack trace about the original issue. ::: devtools/client/storage/test/head.js @@ +482,5 @@ > gUI.tree.expandAll(); > > let selector = "[data-id='" + JSON.stringify(ids) + "'] > .tree-widget-item"; > let target = gPanelWindow.document.querySelector(selector); > + ok(target, "tree item found with ids " + JSON.stringify(ids)); It may happen that the selector doesn't match anything and then we end up with random exception in click() method called some lines after. Now, we can immediately know what is missing/wrong. ::: devtools/client/storage/ui.js @@ +338,5 @@ > + try { > + typeLabel = L10N.getStr("tree.labels." + type); > + } catch(e) { > + console.error("Unable to localize tree label type:" + type); > + } These two try catch allow to start working on a new actor without providing a localization. Otherwise, if you miss any string in l10n files, it throws and prevent displaying anything.
Attachment #8709017 -
Flags: review?(mratcliffe) → review+
Attachment #8709021 -
Flags: review?(mratcliffe) → review+
Comment on attachment 8709022 [details] [diff] [review] Various tweaks - v1 Review of attachment 8709022 [details] [diff] [review]: ----------------------------------------------------------------- These little tweaks add some stability, especially when contributing to the codebase. I really like this patch series because it shows how simple it is to add new storage types, thanks for working on this!
Attachment #8709022 -
Flags: review?(mratcliffe) → review+
Comment 26•8 years ago
|
||
(In reply to Michael Ratcliffe [:miker] [:mratcliffe] from comment #25) > I really like this patch series because it shows how simple it is to add new > storage types, thanks for working on this! Stole the words out of my mouth!
Assignee | ||
Comment 27•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=90d258eb8850
Assignee | ||
Comment 28•8 years ago
|
||
One last push to try, I'm unlucky these days with my checkins...
Assignee | ||
Comment 29•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=693c3d335d15
Assignee | ||
Comment 30•8 years ago
|
||
Fixed typo that broke dt7-browser_storage_values.js.
Attachment #8709519 -
Flags: review+
Assignee | ||
Updated•8 years ago
|
Attachment #8709017 -
Attachment is obsolete: true
Assignee | ||
Comment 31•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=81d2337b4359
Assignee | ||
Comment 32•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=390f96f6b1cb
Assignee | ||
Comment 33•8 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/22d80ccb4626eaf220e7d00abe713893f88fe26c Bug 1003860 - Simplify storage setup tasks in storage inspector tests. r=mratcliffe https://hg.mozilla.org/integration/fx-team/rev/8d93e84979b502359d728845813f13224378a201 Bug 1003860 - Service worker cache for storage actor. r=mratcliffe https://hg.mozilla.org/integration/fx-team/rev/8737105685f1b5feeb592791aa4ea498f491da96 Bug 1003860 - Various tweaks to the storage inspector. r=mratcliffe
Comment 34•8 years ago
|
||
sorry had to back this out for test failures like https://treeherder.mozilla.org/logviewer.html#?job_id=6741607&repo=fx-team
Flags: needinfo?(poirot.alex)
Comment 35•8 years ago
|
||
Backout: https://hg.mozilla.org/integration/fx-team/rev/c0a8a74faf03 https://hg.mozilla.org/integration/fx-team/rev/2b9d095eccfd https://hg.mozilla.org/integration/fx-team/rev/31648a75b668
Assignee | ||
Comment 36•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=f4caa5cdff65
Assignee | ||
Comment 37•8 years ago
|
||
PGO failure, how fun is that! I get this exception, in populateStoresForHost: TypeError: this.hostVsStores is null This is weird as I copied indexedDB code for that, so it should also happen there, but it looks like it isn't. But I see that it may somehow happen if we get a window-ready event while the actor is still initializing.
Flags: needinfo?(poirot.alex)
Assignee | ||
Comment 38•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=0f076977bd8f
Assignee | ||
Comment 39•8 years ago
|
||
Ok, so that was it. We just need to set `hostVsStores` earlier. PGO try without the fix: https://treeherder.mozilla.org/#/jobs?repo=try&revision=798480345d52&selectedJob=15863139 PGO try with the fix: https://treeherder.mozilla.org/#/jobs?repo=try&revision=f4caa5cdff65&selectedJob=15817395
Attachment #8711623 -
Flags: review+
Assignee | ||
Updated•8 years ago
|
Attachment #8709021 -
Attachment is obsolete: true
Assignee | ||
Comment 40•8 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/a4fe93d921adf9b2a5bd230cfe718d1ba64bccfa Bug 1003860 - Simplify storage setup tasks in storage inspector tests. r=mratcliffe https://hg.mozilla.org/integration/fx-team/rev/d1d1dbec672559f1545fc81213d4ba923044663e Bug 1003860 - Service worker cache for storage actor. r=mratcliffe https://hg.mozilla.org/integration/fx-team/rev/824ccce70bcf430c30c5556a13f5fb0ff3b5c4cb Bug 1003860 - Various tweaks to the storage inspector. r=mratcliffe
Assignee | ||
Comment 41•8 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/2ecd643f6c78d5a6af7c7e9b5dcb38b45ae02cbe Backed out 3 changesets (bug 1003860) for dt6//browser_storage_basic.js failure on win7-debug
Assignee | ||
Comment 42•8 years ago
|
||
New failure, this time on window-debug, dt6 e10s - browser_storage_basic.js https://treeherder.mozilla.org/#/jobs?repo=fx-team&revision=fd5530566259 https://treeherder.mozilla.org/#/jobs?repo=fx-team&revision=41046a32d9ff devtools/client/storage/test/browser_storage_basic.js | Uncaught exception - at :0 - Error: operation not possible on dead CPOW
Comment 43•8 years ago
|
||
Backout: https://hg.mozilla.org/mozilla-central/rev/aa90f482e16d
Assignee | ||
Comment 44•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=dbddf51b9298
Assignee | ||
Comment 45•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=6c30c1383c19
Assignee | ||
Comment 46•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=2d87ecb033b3
Assignee | ||
Comment 47•8 years ago
|
||
While rebasing, I got some merge conflict on some CPOW related fixes. With some luck, it may have fixed these exceptions...
Assignee | ||
Comment 48•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=c8a0da3a9e1a
Assignee | ||
Comment 49•8 years ago
|
||
Some more test cleanup. I don't think it makes the tests turned green, but I had some commented code in my previous patch. Try looks green, I think a fix has been landed against head.js recently.
Attachment #8714704 -
Flags: review+
Assignee | ||
Updated•8 years ago
|
Attachment #8709519 -
Attachment is obsolete: true
Assignee | ||
Comment 50•8 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/a630c0b3ff2379bd4b053ac9e6a00554615b3c96 Bug 1003860 - Simplify storage setup tasks in storage inspector tests. r=mratcliffe https://hg.mozilla.org/integration/fx-team/rev/38e69b4e7ac8548b2a97cb67672985b13d87cc55 Bug 1003860 - Service worker cache for storage actor. r=mratcliffe https://hg.mozilla.org/integration/fx-team/rev/4b128ca2602b3feb22ab0b9028d96793719a8072 Bug 1003860 - Various tweaks to the storage inspector. r=mratcliffe
Comment 51•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/a630c0b3ff23 https://hg.mozilla.org/mozilla-central/rev/38e69b4e7ac8 https://hg.mozilla.org/mozilla-central/rev/4b128ca2602b
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox47:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 47
Blocks: 1245615
Updated•8 years ago
|
Keywords: dev-doc-needed
Comment 52•8 years ago
|
||
docs -> https://developer.mozilla.org/en-US/docs/Tools/Storage_Inspector#Cache_Storage Please let me know if this covers it.
Flags: needinfo?(poirot.alex)
Reporter | ||
Comment 53•8 years ago
|
||
It says "any caches created by Service Workers" but DOM Caches can be created by non-{Service,} Workers.
Comment 54•8 years ago
|
||
Thanks for catching this, Andrew. I've replaced that with "DOM caches created using the Cache API". Does that sound OK? I've also filed bug 1257671 :).
Reporter | ||
Comment 55•8 years ago
|
||
(In reply to Will Bamberg [:wbamberg] from comment #54) > Thanks for catching this, Andrew. I've replaced that with "DOM caches > created using the Cache API". Does that sound OK? Yep!
Assignee | ||
Comment 56•8 years ago
|
||
(In reply to Will Bamberg [:wbamberg] from comment #52) > docs -> > https://developer.mozilla.org/en-US/docs/Tools/ > Storage_Inspector#Cache_Storage > > Please let me know if this covers it. Yes. Thanks!
Flags: needinfo?(poirot.alex)
Updated•6 years ago
|
Product: Firefox → DevTools
Updated•5 years ago
|
Blocks: dt-service-worker
You need to log in
before you can comment on or make changes to this bug.
Description
•