Closed Bug 1394019 Opened 4 years ago Closed 1 year ago

TypeError: this.browser is null in ExtensionPopups.jsm when extension popup is closed on load


(WebExtensions :: Frontend, defect, P3)

55 Branch


(firefox75 verified)

Tracking Status
firefox75 --- verified


(Reporter: robwu, Assigned: robwu)




(3 files, 1 obsolete file)

Attached file
1. Load attached extension (extract to a directory and load the extension at about:debugging).
2. Click on the extension button (it has tooltip "Close synchronously during script execution").
3. Look at the global JS console (Ctrl-Shift-J).

- No errors

- TypeError: this.browser is null
  at the Promise callback in unblockParser in

Easy fix:
- Test whether this.browser is null before using this.browser.
Attached file
Same extension, except it calls window.close() at the DOMContentLoaded event instead of while the script is initializing.

Same expectation, same actual result.

This concludes the test cases for closing the extension popup during load, there is also error spam when an extension popup mutates the DOM during unload - see bug 1394010.
See Also: → 1394010
Priority: -- → P3
Product: Toolkit → WebExtensions

Test case -
install Cliqz extension from AMO, open browser action and click close button in the popup
Following error is observed in console:
TypeError: can't access property "ownerGlobal", browser is null in BrowserElementParent.jsm:81:21

This happens whenever window.close() is called from script within browser action popup.

I can reproduce the error from comment 2 in Firefox 69 - 74. The error points to

In Firefox 68, the test case from the initial report does not trigger any errors. The new error is probably due to the change in bug 1533949 . If I add event.stopPropagation() at , then the error message isn't printed any more.

There is also another error message when the popup is closed (or when the mouse pointer hovers above the extension button and then away):

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIControllers.removeController]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://global/content/elements/browser-custom-element.js :: destroy :: line 1374" data: no]

There doesn't seem to be any bad side effects besides these errors.

Hi Rob, so what do you suggest,
shall we go ahead and subside the error with event.stopPropagation() ?
I also can not find anything breaking

TypeError: this.browser is null

Assignee: nobody → trishul.goel

Hi Rob, may be this would be enough to subside the error.

Starting from bug 1394019, the DOMWindowClose event is forwarded to the
<browser> element, so there is no need for a custom
"Extension:DOMWindowClose" message any more.

Assignee: trishul.goel → rob
Attachment #9121831 - Attachment is obsolete: true
Pushed by
Handle DOMWindowClose of extension popup in parent r=zombie
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla75
Pushed by
Port bug 1394019 - Handle DOMWindowClose of extension popup in parent. rs=bustage-fix

Verified fixed on Windows pro 10 64-bit and MacOS Catalina 10.15 on FF Nightly 75.0a1 (20200213035745) using extensions from description, comment 1 and comment 2. TypeError: browser is null error is no longer received in browser console.

You need to log in before you can comment on or make changes to this bug.