Addon problem #4: Cannot obtain manifest object from browser

The following code in a popup window loaded by “browser.windows.create({url:url, type: “popup”/, height: 600, width: 600/});” fails to obtain the manifest object because “browser” is undefined. Why is browser undefined in this update popup and how do I define it? Is there a magic global .js file that I am supposed to include in the HTML file?

var manifest=browser.runtime.getManifest();

Note: with “browser” undefined in the update popup js file, many other useful operations also cannot be done, like sending messages.

What url do you load in this window? WebExtension APIs are only available for extension pages.

The/a browser global variable should be defined in every window context of your extension (i.e. the background page, all views (tabs, popups, panels, sidebars, iframes unless sandboxed) that have a HTML file loaded that was bundled in your extension) and in content scripts (but with fewer APIs available).
You do not need to load it from a script (in Firefox, in Chrome it has to be polyfilled).

Thank you. I’m not sure why “browser” is sometimes defined and sometimes not defined, but I will post the solution I found at Problem #5.