Bug 195777 - Web Inspector: provide a debug setting button to reset all settings for easier testing/presentation
Summary: Web Inspector: provide a debug setting button to reset all settings for easie...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-03-14 16:02 PDT by Devin Rousso
Modified: 2019-05-22 16:12 PDT (History)
6 users (show)

See Also:


Attachments
Patch (15.94 KB, patch)
2019-03-14 18:02 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
[Image] After Patch is applied (Dark) (535.83 KB, image/png)
2019-03-14 18:02 PDT, Devin Rousso
no flags Details
[Image] After Patch is applied (Light) (525.59 KB, image/png)
2019-03-14 18:02 PDT, Devin Rousso
no flags Details
Patch (16.21 KB, patch)
2019-03-14 19:13 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (16.33 KB, patch)
2019-03-15 17:12 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (3.07 KB, patch)
2019-05-22 00:53 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (3.04 KB, patch)
2019-05-22 15:32 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2019-03-14 16:02:33 PDT
If I've set a ton of breakpoints, it can be really annoying to have to try to visit all the sites (or open inspector2) that have breakpoints and delete them.
Comment 1 Devin Rousso 2019-03-14 18:02:15 PDT
Created attachment 364740 [details]
Patch
Comment 2 Devin Rousso 2019-03-14 18:02:32 PDT
Created attachment 364741 [details]
[Image] After Patch is applied (Dark)
Comment 3 Devin Rousso 2019-03-14 18:02:43 PDT
Created attachment 364742 [details]
[Image] After Patch is applied (Light)
Comment 4 Devin Rousso 2019-03-14 19:13:47 PDT
Created attachment 364754 [details]
Patch
Comment 5 Radar WebKit Bug Importer 2019-03-14 23:45:54 PDT
<rdar://problem/48917070>
Comment 6 Joseph Pecoraro 2019-03-15 11:54:09 PDT
Comment on attachment 364754 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=364754&action=review

> Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js:281
> +                        for (let i = 0; i < window.localStorage.length; ++i) {
> +                            let key = window.localStorage.key(i);
> +                            if (key.startsWith(prefix))
> +                                window.localStorage.removeItem(key);
> +                        }

Doesn't this miss every other item?

    localStorage.clear()
    localStorage.a = 1;
    localStorage.b = 2;
    localStorage.c = 3;

    for (let i = 0; i < window.localStorage.length; ++i) {
        let key = window.localStorage.key(i);
        window.localStorage.removeItem(key);
    }

    console.log(localStorage.length); // => 1

You are mutating the thing that you are iterating over.

A safer way would be to get a list of keys to remove and then remove them:

    localStorage.clear()
    localStorage.a = 1;
    localStorage.b = 2;
    localStorage.c = 3;

    let keysToRemove = [];
    for (let i = 0; i < window.localStorage.length; ++i) {
        let key = window.localStorage.key(i);
        keysToRemove.push(key)
    }

    for (let key of keysToRemove)
        window.localStorage.removeItem(key);

    console.log(localStorage.length); // => 0
Comment 7 Joseph Pecoraro 2019-03-15 11:55:36 PDT
The modal looks pretty good but does seem a bit out of place for macOS.
Comment 8 Devin Rousso 2019-03-15 12:02:59 PDT
Comment on attachment 364754 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=364754&action=review

>> Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js:281
>> +                        }
> 
> Doesn't this miss every other item?
> 
>     localStorage.clear()
>     localStorage.a = 1;
>     localStorage.b = 2;
>     localStorage.c = 3;
> 
>     for (let i = 0; i < window.localStorage.length; ++i) {
>         let key = window.localStorage.key(i);
>         window.localStorage.removeItem(key);
>     }
> 
>     console.log(localStorage.length); // => 1
> 
> You are mutating the thing that you are iterating over.
> 
> A safer way would be to get a list of keys to remove and then remove them:
> 
>     localStorage.clear()
>     localStorage.a = 1;
>     localStorage.b = 2;
>     localStorage.c = 3;
> 
>     let keysToRemove = [];
>     for (let i = 0; i < window.localStorage.length; ++i) {
>         let key = window.localStorage.key(i);
>         keysToRemove.push(key)
>     }
> 
>     for (let key of keysToRemove)
>         window.localStorage.removeItem(key);
> 
>     console.log(localStorage.length); // => 0

Crap!  Good catch!
Comment 9 Devin Rousso 2019-03-15 17:12:26 PDT
Created attachment 364885 [details]
Patch
Comment 10 Timothy Hatcher 2019-03-20 09:16:18 PDT
Comment on attachment 364885 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=364885&action=review

I think we need a dialog UI for Web Inspector — maybe WI.Modal is that but as WI.ModalDialog. Blurring the entire window is not ideal and not something found in other apps. This would be a dialog with Reset and Cancel buttons. Having one button makes it hard to reason how to exit without resetting.

> Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js:261
> +            resetModalButton.addEventListener("click", (event) => {

This handler is big for being inline. I would expect this to be moved to a member function. It also is more Manager like than View like code. Main.js would be a better place for this logic to be maintained.
Comment 11 Devin Rousso 2019-05-22 00:53:53 PDT
Created attachment 370385 [details]
Patch
Comment 12 Devin Rousso 2019-05-22 00:55:16 PDT
Comment on attachment 370385 [details]
Patch

Moved the reset button to be inside the Debug panel, as that's we don't want users to ever hit this (especially not accidentally).  It's mainly for engineers to use for testing/presenting :P
Comment 13 Joseph Pecoraro 2019-05-22 10:35:51 PDT
Comment on attachment 370385 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=370385&action=review

r=me

> Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js:364
> +            WI.ObjectStore.reset();
> +            InspectorFrontendHost.reopen();

ObjectStore.reset() is async and we should probably wait for it. Should this instead be:

    resetInspectorButton.addEventListener("click", async (event) => {
        WI.Setting.reset();
        await WI.ObjectStore.reset();
        InspectorFrontendHost.reopen();
    });
Comment 14 Devin Rousso 2019-05-22 15:32:59 PDT
Created attachment 370454 [details]
Patch
Comment 15 WebKit Commit Bot 2019-05-22 16:12:13 PDT
Comment on attachment 370454 [details]
Patch

Clearing flags on attachment: 370454

Committed r245657: <https://trac.webkit.org/changeset/245657>
Comment 16 WebKit Commit Bot 2019-05-22 16:12:15 PDT
All reviewed patches have been landed.  Closing bug.