-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client can be mis-configured due to config and boot-script injection being non-atomic #1179
Comments
Chrome 106+ (Sep 2022) provides a general solution for this problem, which is to specify a document ID as the target rather than just a tab ID when executing a script via As well as not being available in older Chrome releases, document IDs are also not currently available in other browsers that support Web Extensions. |
See also w3c/webextensions#8 and this Chrome design doc. |
After some tests on the different suggestions, we have finally addressed this by making sure the client's boot script aborts when it detects it has been executed by the browser extension, but it does not find a config script generated by that extension (it would be the third suggested option). The first naive attempt was to make sure the boot script "exits" if there's no config at all and the extension executed it: hypothesis/client#5392 If the page has other "hardcoded" configs, this could result in a false positive, so we improved it by:
|
When testing changes to the integration between bouncer (hyp.is) and the extension locally, I encountered a situation where the development extension would sometimes be activated in the toolbar yet the client showed annotations from the production instance of h.
After adding some logging I realized the issue is that the extension injects the client's configuration (which tells it where to load resources from) in a separate step to starting the client, and that it is possible for the tab to navigate in-between these steps. When this happens the client can end up starting without the configuration being present on the page, causing it to load assets from the wrong location.
The sequence of events when this happens was:
SidebarInjector.injectIntoTab
)<script>
tag into the page (start ofinjectIntoRemoteDocument
function)injectIntoRemoteDocument
function)In this sequence, steps 4 and 6 are different steps of the same async function in
injectIntoRemoteDocument
, and are performed in the same browser tab, but they end up being executed in different documents since a navigation is happening. As a result when the client loads in step 6, it doesn't find its configuration and ends up loading with the default production configuration. Step 8 has no effect, since it happens after the client's boot script has already loaded. Step 9 has no effect, since the boot script will detect the presence of another Hypothesis client in the page and bail out.Although this situation involved some local changes to the bouncer, I believe the same outcome is possible in normal usage if the page triggers a navigation at the same time as the extension is activated.
Possible solutions
The text was updated successfully, but these errors were encountered: