• mnaganov's avatar
    [Android] Fix method invocation and wrappers cleanup handling in Java Bridge · 9e4422ed
    mnaganov authored
    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
    
    Review URL: https://codereview.chromium.org/1018413002
    
    Cr-Commit-Position: refs/heads/master@{#321567}
    9e4422ed
content_renderer.gypi 40.7 KB