Do not read document in getSiteName when there is none - #1592
Open
arpitjain099 wants to merge 1 commit into
Open
arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
getSiteName reads document.location.search so the popup can pass a title and url. background.ts also calls it from the MV3 service worker, which has no document, so the autofill command threw ReferenceError after the content script and css had already been injected and no code was ever sent to the tab. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getSiteNamereadsdocument.location.searchso the popup can pass a title and url through its own query string.background.tsalso calls it, from thechrome.commands.onCommand("autofill")handler, and on Chrome and Edge that is an MV3 service worker with nodocument.Driving the transpiled function with a stubbed
getCurrentTab:By the time it throws,
scripting.executeScriptandinsertCSShave already run, so the content script and its css are injected into the page and then nothing is sent to it. The shortcut looks like it does nothing. The Firefox manifest uses a background script rather than a worker, which is why that build is unaffected.The query string is only ever populated for the popup, so the fix reads it when a document exists and falls back to the tab otherwise, which is the branch already there for when the query is empty. After the change both contexts return the same triple.
webpackcompiles clean.