# WebExtensions - javascript support in browser\_action/default\_popup page

**URL:** <https://discourse.mozilla.org/t/webextensions-javascript-support-in-browser-action-default-popup-page/3946>\
**Category:** Development\
**Created:** [September 9, 2015, 3:31pm UTC](https://discourse.mozilla.org/t/webextensions-javascript-support-in-browser-action-default-popup-page/3946 "2015-09-09T15:31:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![henri](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/henri/32/21168_2.png) [@henri](https://discourse.mozilla.org/u/henri)\
**Post date:** [September 9, 2015, 3:31pm UTC](https://discourse.mozilla.org/t/webextensions-javascript-support-in-browser-action-default-popup-page/3946/1 "2015-09-09T15:31:37Z")

</div>

On Chrome, clicking on a link in the default\_popup window closes it.

This is not the case in the current Firefox Nightly, so I wanted to do it with a call to window.close() on the onclick event handler but it seems that the popup window doesn’t behave as the other html pages regarding javascript support : _alert()_ works but neither _window.close()_ nor _console.log()_.  
There is no error message in the console.

**manifest.json:**

```
{
  "manifest_version": 2,
  "name": "webextensions tests",
  "version": "1.0",

  "applications": {
    "gecko": {
      "id": "webextensions@bourcereau.fr"
    }
  },

  "browser_action": {
        "default_title": "Tests",
        "default_popup": "popup.html"
    }
}

```

**popup.html:**

```
<!doctype html>
<html>
<body>
  <a href="#" onclick="alert('something')">alert : ok</a><br>
  <a href="#" onclick="console.log('something')">console.log : not ok</a><br>
  <a href="#" onclick="window.close()">window.close : not ok</a><br>
</body>
</html>

```

Complete extension source here : [https://github.com/mmai/firefox\_webextensions\_tests](https://github.com/mmai/firefox_webextensions_tests)

---

<div class="post-metadata">

**Author:** ![Anton](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/anton/32/21177_2.png) [@Anton](https://discourse.mozilla.org/u/Anton)\
**Post date:** [September 14, 2015, 9:22pm UTC](https://discourse.mozilla.org/t/webextensions-javascript-support-in-browser-action-default-popup-page/3946/2 "2015-09-14T21:22:01Z")

</div>

I found that you can see the console.log() output using Ctrl-Shift-J. It helps with some debugging, though still it looks very limited.

---

<div class="post-metadata">

**Author:** ![henri](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/henri/32/21168_2.png) [@henri](https://discourse.mozilla.org/u/henri)\
**Post date:** [September 15, 2015, 3:24pm UTC](https://discourse.mozilla.org/t/webextensions-javascript-support-in-browser-action-default-popup-page/3946/3 "2015-09-15T15:24:50Z")

</div>

Thank you. At least now I can see the error message : “Scripts may not close windows that were not opened by script”. Now I wonder how we are supposed to close this popup window…

---

<div class="post-metadata">

**Author:** ![noitidart](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@noitidart](https://discourse.mozilla.org/u/noitidart)\
**Post date:** [September 15, 2015, 8:26pm UTC](https://discourse.mozilla.org/t/webextensions-javascript-support-in-browser-action-default-popup-page/3946/4 "2015-09-15T20:26:25Z")

</div>

You can see all info in this ctrl-shift-j log, you just have to enable the pereferences to see it all: [https://developer.mozilla.org/en-US/Add-ons/Setting\_up\_extension\_development\_environment?redirectlocale=en-US&redirectslug=Setting\_up\_extension\_development\_environment#Development\_preferences](https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment?redirectlocale=en-US&redirectslug=Setting_up_extension_development_environment#Development_preferences)

---

<div class="post-metadata">

**Author:** ![noitidart](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@noitidart](https://discourse.mozilla.org/u/noitidart)\
**Post date:** [September 17, 2015, 12:51am UTC](https://discourse.mozilla.org/t/webextensions-javascript-support-in-browser-action-default-popup-page/3946/5 "2015-09-17T00:51:34Z")

</div>

These developer perfences should be the first (and only really) thing you need to do before starting to dev. It shouldn’t be hard to find. I linked to it from the main addons landing page “debugging” section: [https://developer.mozilla.org/en-US/Add-ons](https://developer.mozilla.org/en-US/Add-ons)
