Re: Mutation events replacement

On Thu, Jul 7, 2011 at 6:21 PM, John J Barton
<> wrote:
> 1. Graphical breakpoints. The user marks some DOM element or attribute to
> trigger break. The debugger inserts mutation listeners to watch for the
> event that causes that element/attribute to be created/modified. Then the
> debugger re-executes some code sequence and halts when the appropriate
> listener is entered. Placing the listeners high in the tree and analyzing
> all of the events is easier than trying to precisely add a listener since
> the tree will be modified during re-execution.
> 2. Graphical tracing. Recording all or part of the DOM creation. For
> visualization or analysis tools.  See for example Firebug's HTML panel with
> options Highlight Changes, Expand Changes, or Scroll Changes into View.
> 3. Client side dynamic translation. Intercept mutations and replace or
> extend them. This could be for user tools like scriptish or stylish, dev
> tools to inject marks or code, or for re-engineering complex sites for newer
> browser features.

Most if not all of your use cases can be done by hooking the functions
you're worried about at the engine level.

You can do any of the following:
1. replace functions on object prototypes
2. instrument the js code before it executes
3. single step the js code and then instrument it as it executes

You could also just wait for this to be implemented and arrange for a
*private* non DOM API which would allow you to get hooks which do
things like any of the above.

Note that JSD historically has had a "before method call" callback.
And iirc someone was supposed to provide it again for the cases where
the JIT broke this. A before method call callback easily enables you
to check its name against a table and decide that you need to store
values, there's also a paired "after" callback, during which you can
do the rest of your work. If these don't work, you can file a bug
against the API and hopefully someone will work on it.

-- sadly, that won't be me.

Received on Friday, 8 July 2011 13:52:12 UTC