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

Categories

(WebExtensions :: Frontend, defect, P3)

55 Branch
defect

Tracking

(firefox75 verified)

VERIFIED FIXED
mozilla75
Tracking Status
firefox75 --- verified

People

(Reporter: robwu, Assigned: robwu)

References

Details

Attachments

(3 files, 1 obsolete file)

Attached file synchronously.zip
STR
1. Load attached extension (extract synchronously.zip 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).

Expected:
- No errors

Actual:
- TypeError: this.browser is null
  at the Promise callback in unblockParser in https://searchfox.org/mozilla-central/rev/5696c3e525fc8222674eed6a562f5fcbe804c4c7/browser/components/extensions/ExtensionPopups.jsm#320

Easy fix:
- Test whether this.browser is null before using this.browser.
Attached file domcontentloaded.zip
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 https://searchfox.org/mozilla-central/rev/c52d5f8025b5c9b2b4487159419ac9012762c40c/toolkit/actors/BrowserElementParent.jsm#81

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 https://searchfox.org/mozilla-central/rev/c52d5f8025b5c9b2b4487159419ac9012762c40c/toolkit/components/extensions/ext-browser-content.js#161 , 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
Status: NEW → ASSIGNED

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 rob@robwu.nl:
https://hg.mozilla.org/integration/autoland/rev/c7d802a739c6
Handle DOMWindowClose of extension popup in parent r=zombie
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla75
Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/251268cf2381
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.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.