Although ubuntu 16.04 is old, it is still supported until April 2021. However, opera 62 is old, so please update it to the latest version (65 on the stable branch, as of today).
Moreover, if you are using the snap version of opera, remove it, install the deb one and try your code there. Snap apps have limitations on what they can access, so maybe one of the things the snap version of opera can not access messes up your code.