I have worked around this by using browserAction.setPopup
For pages with no content script it will use the default popup which does not attempt to send a message to the content script.
I changed all my content scripts to send a message to my background script which causes it to call chrome.browserAction.setPopup to switch to the popup menu which does send a message to the content script.
Post
Replies
Boosts
Views
Activity
After further investigation it appears that navigator.clipboard.writeText will work in some code called from an extensions popup menu item.
By a process of elimination it appears that what causes it to fail is if the function called by clicking the menu item calls any code that has been loaded from a module.
So if all the code is in .js files loaded by popup.html it works. But in my case I load some code from an .mjs file which generates the citation. I structure it this way so that I can use a node.js test suite for my unit tests. Since my extension code is very modular and consists of many .mjs files it would be a big job to restructure it so all of the code could be included in popup.html as .js files. Structuring it this way also improves the performance of bringing up the popup menu - it doesn't need to load all of the code that will be used by all of the menu items.
It is possible that it is not just the fact that I'm calling code from a module. It could be something specific that I am doing in that module. I haven't gone through the process of creating a dummy module that does very little to confirm.
So for the Safari version I have a fallback. If the call to navigator.clipboard.writeText throws an exception I then change my popup to display the generated text with a button "Save to clipboard". Then when the user presses that button navigator.clipboard.writeText works.
Doing "background": { "scripts": ["scripts/background.js"], "persistent": false }, as suggested above does work to some extent but unfortunately the background script keeps getting terminated and does not respond to sendMessage.