Skip to content
  • Mike Conley's avatar
    Bug 1570406 - Ensure that we properly detach window root event listeners in... · 681b8ccd
    Mike Conley authored
    Bug 1570406 - Ensure that we properly detach window root event listeners in PictureInPictureToggleChild. r=JSON_voorhees
    
    We were using the pagehide event before incorrectly: the pagehide event target
    was being inspected to see if it was the top-level frame, and only then, would
    we remove the mouse event handlers on the window root.
    
    The problem is that event.target.top on a pagehide event is undefined, since the
    event target is a Document.
    
    Further, we probably want to remove any window root event listeners that were
    registered for subframes as well. I'm not sure why I decided to try to filter
    out subframes, but that definitely can keep windows alive.
    
    So instead, I'm using the "cleanup" method that ActorManagerChild calls if
    defined on an ActorChild, which runs when the associated frame unloads. This
    way, if a subframe happened to have registered a window root event listener,
    it'll get unregistered.
    
    Differential Revision: https://phabricator.services.mozilla.com/D40090
    
    --HG--
    extra : moz-landing-system : lando
    681b8ccd