Bug 27400

Summary: Inspector: Automatically Refresh DOM Storage Grids on "storage" event
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web Inspector (Deprecated)Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Enhancement CC: rik, timothy
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: OS X 10.5   
Attachments:
Description Flags
Live Update both DOM Storage Grids
timothy: review-
Fixed Based on Review timothy: review+

Description Joseph Pecoraro 2009-07-17 17:57:44 PDT
It is too much work to click that small Refresh button to view changes in the dataGrid.  The inspected window fires a storage event that can be hooked into to automatically update the data grid.

NOTE: I could totally see this as being a "setting".  If lots of storage events are firing and the table keeps updating it might not be good for a developer to work with.  It may be a good idea to add a permanent setting, and toolbar item, that will allow the user to activate "live updates" or not!
Comment 1 Joseph Pecoraro 2009-07-17 18:02:44 PDT
Created attachment 32993 [details]
Live Update both DOM Storage Grids

NOTES:

- Assumes only 2 storages exist (like the current code does with the "isLocalStorage" property.
- Tested on localStorage and sessionStorage and it worked great.
- register/unregister functions would be great to use for a toolbar item in case this moves into a setting.
Comment 2 Timothy Hatcher 2009-07-23 11:52:34 PDT
Comment on attachment 32993 [details]
Live Update both DOM Storage Grids


> - * Copyright (C) 2007, 2008 Apple Inc.  All rights reserved.
> + * Copyright (C) 2007, 2008, 2009 Apple Inc.  All rights reserved.

You should add your name and copyright on a new line instead.

> +        inspectedWindow.addEventListener('storage', this._storageEventListener, true);

You should use double quotes for strings.

> +        var flag = (event.storageArea == InspectorController.inspectedWindow().localStorage);
> +        if (this._domStorage) {

An early return would be better here.

> +            var domStorageLength = this._domStorage.length;
> +            for (var i = 0; i < domStorageLength; ++i) {
> +                var domStorage = this._domStorage[i];
> +                if (flag == domStorage.isLocalStorage) {

Triple equals.

> +                    var view = domStorage._domStorageView;
> +                    if (this.visibleView && view == this.visibleView)

Ditto.
Comment 3 Joseph Pecoraro 2009-07-23 14:36:04 PDT
Created attachment 33378 [details]
Fixed Based on Review
Comment 4 Joseph Pecoraro 2009-07-23 14:38:38 PDT
(In reply to comment #2)
> You should add your name and copyright on a new line instead.

Done.

> You should use double quotes for strings.

Done. All.
 
> An early return would be better here.

Done.


> > +            var domStorageLength = this._domStorage.length;
> > +            for (var i = 0; i < domStorageLength; ++i) {
> > +                var domStorage = this._domStorage[i];
> > +                if (flag == domStorage.isLocalStorage) {
> 
> Triple equals.

Done. Renamed flag to "isLocalStorage" like the inspect() patch coming for Keishi.

> > +                    var view = domStorage._domStorageView;
> > +                    if (this.visibleView && view == this.visibleView)
> 
> Ditto.

Done.
Comment 5 Timothy Hatcher 2009-07-28 21:55:27 PDT
http://trac.webkit.org/changeset/46518
Comment 6 Anthony Ricaud 2009-07-29 03:45:16 PDT
Instead of a setting, another option is to add a timer before doing the update. Both options are valid.