Bug 144124 - Web Inspector: run a customizable bootstrap function after the UI has fully loaded
Summary: Web Inspector: run a customizable bootstrap function after the UI has fully l...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Brian Burg
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-04-23 15:03 PDT by Brian Burg
Modified: 2015-07-15 18:06 PDT (History)
7 users (show)

See Also:


Attachments
Patch (4.47 KB, patch)
2015-04-23 15:52 PDT, Brian Burg
joepeck: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Burg 2015-04-23 15:03:29 PDT
The point of a "bootstrap script" is to reduce amount of time clicking on the UI to get the inspector to a useful state for debugging.
Instead, you write commands in a function that runs after the inspector has loaded. These commands automate reproduction steps, and can be shared as part of a bug report (if obvious).

Some things you might want to do include opening different sidebars, browsing between web pages, evaluating text in the console.
Comment 1 Radar WebKit Bug Importer 2015-04-23 15:04:13 PDT
<rdar://problem/20674800>
Comment 2 Brian Burg 2015-04-23 15:52:00 PDT
Created attachment 251503 [details]
Patch
Comment 3 Timothy Hatcher 2015-04-23 16:03:24 PDT
Comment on attachment 251503 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Main.html:539
> +    <script src="Base/Bootstrap.js"></script>

Should this file be skipped when combining for Release/Production?
Comment 4 Brian Burg 2015-04-23 16:46:34 PDT
(In reply to comment #3)
> Comment on attachment 251503 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=251503&action=review
> 
> > Source/WebInspectorUI/UserInterface/Main.html:539
> > +    <script src="Base/Bootstrap.js"></script>
> 
> Should this file be skipped when combining for Release/Production?

I suppose that's possible, though I don't think we do that anywhere else? It would require blacklisting in inline-and-minify-stylesheets-and-scripts.py, and maybe other parts to avoid copying the resource.

I wasn't planning to have anything in the function body on trunk; developers can revert or exclude their little scripts from patches. Reusable snippets can live in comments in Bootstrap.js (to be stripped out) or on the wiki.
Comment 5 Joseph Pecoraro 2015-04-23 17:06:37 PDT
Comment on attachment 251503 [details]
Patch

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

Seems fine to me. Do you have an example of a bootstrap you might use?

> Source/WebInspectorUI/UserInterface/Base/Main.js:361
> +    if (this.runBootstrapOperations && typeof this.runBootstrapOperations === "function")
> +        this.runBootstrapOperations();

No need to if-check? It is guaranteed right now.

>>> Source/WebInspectorUI/UserInterface/Main.html:539
>>> +    <script src="Base/Bootstrap.js"></script>
>> 
>> Should this file be skipped when combining for Release/Production?
> 
> I suppose that's possible, though I don't think we do that anywhere else? It would require blacklisting in inline-and-minify-stylesheets-and-scripts.py, and maybe other parts to avoid copying the resource.
> 
> I wasn't planning to have anything in the function body on trunk; developers can revert or exclude their little scripts from patches. Reusable snippets can live in comments in Bootstrap.js (to be stripped out) or on the wiki.

This should minify down to:
WebInspector.runBootstrapOperations=function(){};

So it may be fine to leave in.
Comment 6 Brian Burg 2015-04-23 20:09:39 PDT
Committed r183238: <http://trac.webkit.org/changeset/183238>
Comment 7 Brian Burg 2015-04-23 21:20:05 PDT
(In reply to comment #5)
> Comment on attachment 251503 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=251503&action=review
> 
> Seems fine to me. Do you have an example of a bootstrap you might use?

Something I did over and over when doing element tracking feature is to load a page, select the same element in the DOM, and invoke "Start Tracking". This could have been automated by doing querySelector to get the node, then passing it to DOMTracingManager.startTracking(). Further work on specific screens could have been automated by programmatically changing the content browser's represented object.

I'll update the wiki page (https://trac.webkit.org/wiki/WebInspectorDebugging) as I make use of this feature to help share some useful snippets.
Comment 8 Timothy Hatcher 2015-04-23 23:33:34 PDT
Comment on attachment 251503 [details]
Patch

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

>>>> Source/WebInspectorUI/UserInterface/Main.html:539
>>>> +    <script src="Base/Bootstrap.js"></script>
>>> 
>>> Should this file be skipped when combining for Release/Production?
>> 
>> I suppose that's possible, though I don't think we do that anywhere else? It would require blacklisting in inline-and-minify-stylesheets-and-scripts.py, and maybe other parts to avoid copying the resource.
>> 
>> I wasn't planning to have anything in the function body on trunk; developers can revert or exclude their little scripts from patches. Reusable snippets can live in comments in Bootstrap.js (to be stripped out) or on the wiki.
> 
> This should minify down to:
> WebInspector.runBootstrapOperations=function(){};
> 
> So it may be fine to leave in.

We skip combining (or combine separately) files in External/*.