Chromium Code Reviews
Description[Android] Fix method invocation and wrappers cleanup handling in Java Bridge
While investigating flakiness of JavaBridgeBasicsTest#testRemovalNotReflectedUntilReload
I realized that we don't handle invocation of injected objects' methods
properly -- InvokeMethod was bound to a GinJavaBridgeObject instance and was
making two wrong assumptions:
- that the method can only be called for the wrapper where the method has been
obtained from -- not true, as it is possible to use `call()` method of
`Function` to pass a different `this` object;
- that it is safe to store an unretained pointer to GinJavaBridgeObject --
it's not, as it is possible to retain a function representing method
separately from the injected object, which can be collected (if it's not a
named object).
The issue that was causing the test flakiness originated from the fact that
DidClearWindowObject can be called several times during the page lifecycle.
GinJavaBridgeDispatcher injects new wrappers each time, this isn't a problem
on its own, but leads to premature issuing of wrapper deletion notificiations
when the wrappers of the old generation got cleaned up.
BUG=468679
Committed: https://crrev.com/9e4422ed1a5babde895ab2c101298e69338fdfc2
Cr-Commit-Position: refs/heads/master@{#321567}
Patch Set 1 #Patch Set 2 : Added a dedicated test for attempting to call a non-existing method via `call` #Messages
Total messages: 12 (4 generated)
|