js-shield
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New wrappers


From: Giorgio Maone
Subject: Re: New wrappers
Date: Fri, 10 Sep 2021 17:19:36 +0200
User-agent: None of Your Business 1.0

On 10/09/21 14:25, Libor Polčák wrote:

Giorgio finished the development of the improved wrapping code dealing with the bugs realted to early injection and reliable injection in Firefox when wisiting pages with CSP. See https://pagure.io/JS-Shield/JS-Shield/blob/nscl3/f/docs/new_wrapper.md.

Giorgio, I am little confused about wrapped_name and callable_name. Is the following true?

"Generally speaking, use wrapped_name whenever you need to access the original objects only inside
the wrapper and you do not need to pass the object to other code, such as `Promise` objects or
callbacks. Compared to `callable_name`, `wrapped_name` has less overhead and is the preferred way."
That's correct.

Am I right that it does not make sense to define both callable_name and wrapped_name?

It usually doesn't, but IMHO keeping the ability to define both is good  for flexibility sake: even though in current wrappers (at least those which I've worked on) you needed either one or the other, you can actually define both in order to keep around 2 references for possibly different purposes:

  1. wrapped_name points to the actual original object, unadulterated: you might need it for identity comparisons or other instance-specific use cases
  2. callable_name points to a proxy to the original object, intercepting calls and automatically marshaling parameters and return values, but with this alone you can't take any handle of the actual original native object

As things are currently set up, depending on what you want to do, you can have one, the other or both.

Do you think we can make the documentation less confusing about this point?

Thanks!

-- G




Thanks

Libor


-- 
Giorgio Maone
https://maone.net

reply via email to

[Prev in Thread] Current Thread [Next in Thread]