Infocatcher / Private_Tab

Adds private tabs, restartless extension for Firefox (20.0+) and SeaMonkey (2.17+)
https://addons.mozilla.org/addon/private-tab/
Other
86 stars 20 forks source link

patcher and third-party wrapper #159

Open onemen opened 10 years ago

onemen commented 10 years ago

I would like to implement in Tabmix some variation of patcher.jsm.

the thing that concern me the most is how to detect if third-party restartless extension override my code when it run its unload function, when user disable the extension during session.

can this happen ?

  1. extension A run its patcher to wrap function foo.
  2. my extension run its patcher to wrap function foo.
  3. user disabled extension A.
  4. extension A run its patcher to unwrap function foo, and set foo to be as it was before step 1.

in this scenario my wrap function foo no longer work. my question is there a way to test if my function is still alive? remember that i can't tell if my extension was the first wrapper or the last wrapper of foo.

Infocatcher commented 10 years ago

In my implementation extension A doesn't unwrap function, if current function isn't equal to previously created wrapper (and leave wrapper, but with disabled changes). So, this creates memory leak, but not breaks user experience. https://github.com/Infocatcher/Private_Tab/blob/0.1.7.3/patcher.jsm#L114

Anyway, it's looks impossible to track, what happens with somehow changed wrapper: another extension may restore some intermediate state, if there is more than two wrappers.

onemen commented 10 years ago

I know that your code doesn't unwrap the function is it wasn't the last wrapper. what's worries me is all the other restart-less extensions, as many extensions get restart-less users can enable/disable extensions during the session.

As a workaround i can add listener to extensions disabled/uninstalled with AddonManager and after each such event disabled the previous patch and apply the patcher again on all functions

Infocatcher commented 10 years ago

As a workaround i can add listener to extensions disabled/uninstalled with AddonManager and after each such event disabled the previous patch and apply the patcher again on all functions

Oh, may be. But this increases memory usage (because we can ignore only if our wrapper wasn't changed) and probably logically wrong to try fix another extensions.