Opening a file doesn't work unless the current tab is the editor with a file already open.
It doesn't work in an empty workspace, or if the current tab is a Settings page, Extension page, etc.
The error is: Cannot read properties of undefined (reading 'document')