# Browser crashes when modifying browser action popup with javascript

**URL:** <https://discourse.mozilla.org/t/browser-crashes-when-modifying-browser-action-popup-with-javascript/102040>\
**Category:** Development\
**Created:** [August 4, 2022, 5:30pm UTC](https://discourse.mozilla.org/t/browser-crashes-when-modifying-browser-action-popup-with-javascript/102040 "2022-08-04T17:30:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunox9](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@sunox9](https://discourse.mozilla.org/u/sunox9)\
**Post date:** [August 4, 2022, 5:30pm UTC](https://discourse.mozilla.org/t/browser-crashes-when-modifying-browser-action-popup-with-javascript/102040/1 "2022-08-04T17:30:13Z")

</div>

Hello,

I am working on my first extension and I’m running into this strange problem.

The crash seems to be somewhat reliably triggered by me 1. clicking the toolbar icon, bringing the popup up, and then 2. hovering over the toolbar icon to bring up the little tooltip. The entire browser locks up and I have to ctrl-c web-ext and then start it again. It doesn’t happen every time I do this.

The popup dom consists of just a few lines of text and a button. I don’t have any action listeners yet.

In addition to the popup I have a content-script that adds a sort of pop-up div to the main website area dom, and makes some changes to the CSS. I don’t have any stability issues with this aspect of the extension.

When the freeze happens there is no extra output in the browser console nor the regular console.

I am completely stumped and any help would be greatly appreciated.

Edit: I should specify that the browser I am writing the extension for is Firefox, and also that I have not been able to trigger the crash after commenting out all javascript code that makes changes to the dom.

---

<div class="post-metadata">

**Author:** ![hans\_squared](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/hans_squared/32/67424_2.png) [@hans\_squared](https://discourse.mozilla.org/u/hans_squared)\
**Post date:** [August 4, 2022, 5:41pm UTC](https://discourse.mozilla.org/t/browser-crashes-when-modifying-browser-action-popup-with-javascript/102040/2 "2022-08-04T17:41:30Z")

</div>

Please upload your extension somewhere, so that we can take a look at it.

---

<div class="post-metadata">

**Author:** ![sunox9](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@sunox9](https://discourse.mozilla.org/u/sunox9)\
**Post date:** [August 4, 2022, 6:39pm UTC](https://discourse.mozilla.org/t/browser-crashes-when-modifying-browser-action-popup-with-javascript/102040/3 "2022-08-04T18:39:08Z")

</div>

Thanks for the prompt reply. Here is a link to the extension, hosted by a Nextcloud instance at my university:

> **[extension-test](https://hotsoft.carleton.ca/hotsoftcloud/index.php/s/yQxdgzZE8dpaDri)**
>
> Nextcloud - a safe home for all your data

---

<div class="post-metadata">

**Author:** ![hans\_squared](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/hans_squared/32/67424_2.png) [@hans\_squared](https://discourse.mozilla.org/u/hans_squared)\
**Post date:** [August 5, 2022, 1:40pm UTC](https://discourse.mozilla.org/t/browser-crashes-when-modifying-browser-action-popup-with-javascript/102040/4 "2022-08-05T13:40:33Z")

</div>

I can’t reproduce the problem with:

- Manjaro Linux
- Firefox 103.0 (64-Bit)
- running your extension with either “web-ext run” or “about:debugging \> This Firefox \> Load temporary add-on”

FWIW, I had a similar problem until a few days ago.  
FF kept freezing randomly, so I disabled most extensions, and now it’s stable.

---

<div class="post-metadata">

**Author:** ![sunox9](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@sunox9](https://discourse.mozilla.org/u/sunox9)\
**Post date:** [August 5, 2022, 4:04pm UTC](https://discourse.mozilla.org/t/browser-crashes-when-modifying-browser-action-popup-with-javascript/102040/5 "2022-08-05T16:04:19Z")

</div>

Oh, I really should have tested it on another Firefox install on another machine. I just tested on my laptop and it doesn’t seem to freeze there.

My understanding was that web-ext ran a ‘clean’ version of Firefox (no add-ons), and since I saw the freezing issue with and without add-ons that the problem was something bigger.

On the machine where I see the problem I run gentoo and a locally-compiled version of Firefox with some use flags enabled and some not. I suspect this might be the problem.

Anyway I really appreciate your help, and sorry for the bother.

---

<div class="post-metadata">

**Author:** ![juraj.masiar](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/juraj.masiar/32/30587_2.png) [@juraj.masiar](https://discourse.mozilla.org/u/juraj.masiar)\
**Post date:** [August 5, 2022, 4:48pm UTC](https://discourse.mozilla.org/t/browser-crashes-when-modifying-browser-action-popup-with-javascript/102040/6 "2022-08-05T16:48:35Z")

</div>

Just a friendly reminder after seeing your code, the `innerHTML` is forbidden API in the addons:  
[https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML#security\_considerations](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML#security_considerations)

Also, since popups are incredibly difficult to debug / work with, in Firefox, it’s better to open the popup HTML in a new tab during the development. It makes things much easier and less buggy.

You can place this to the background script for automatic opening after reload:

```auto
browser.tabs.create({url: 'popup/popup.html'});

```

---

<div class="post-metadata">

**Author:** ![sunox9](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@sunox9](https://discourse.mozilla.org/u/sunox9)\
**Post date:** [August 5, 2022, 7:07pm UTC](https://discourse.mozilla.org/t/browser-crashes-when-modifying-browser-action-popup-with-javascript/102040/7 "2022-08-05T19:07:48Z")

</div>

Thank you, noted and much appreciated!

---

<div class="post-metadata">

**Author:** ![sunox9](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@sunox9](https://discourse.mozilla.org/u/sunox9)\
**Post date:** [August 5, 2022, 7:14pm UTC](https://discourse.mozilla.org/t/browser-crashes-when-modifying-browser-action-popup-with-javascript/102040/8 "2022-08-05T19:14:28Z")

</div>

I also wanted to add that I too was not able to reproduce the problem on my laptop. However I do get the same issue on my desktop running the binary version of Firefox (I normally use a locally compiled version), so this means its not my use flags or anything.

I tried refreshing Firefox as well which had no effect.

I tried enabling safe mode and I no longer seem to experience the issue. According to --help safe mode “Disables extensions and themes”. My understanding is that web-ext does not run with extensions enabled anyway, so I am a little confused as to how it sidesteps the issue.

Anyway, just wanted to share on the off chance it is useful to someone.

Thanks again.
