Prevent native integration & bext conflict
Created by: lguychard
Fixes #4900 (release bocker for 3.6)
The execution order of the callback passed to AJS.toInit()
by the Bitbucket Server plugin and the browser extension content script can be racy, leading to conflicts between the browser extension and the Bitbucket Server native integration.
This fixes these conflicts by introducing a custom event sent by the native integration upon activation, signaling that browser extension resources should be cleaned up.
Test plan: I verified that there were no conflicts when:
- The native integration is activated before the browser extension.
- The native integration is activated later during the lifetime of the content script.