Closed Bug 1433604 Opened 8 years ago Closed 5 years ago

WebExtension's popup didn't close when I tap close button

Categories

(WebExtensions :: Android, defect, P3)

All
Android
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1612363

People

(Reporter: u608644, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0 Build ID: 20100101 Steps to reproduce: 1. Install WebExtensions add-on. This addon have a popup menu: e.g. "options_ui": {page:"popup.html"} 2. In firefox android, open "..." > "(addon name)". This opened a popup menu in a new tab. 3. I pressed "Close" button. Actual results: The extension's popup tab didn't close. Expected results: The tab should close. In the desktop Firefox, when I click "Close" button the popup close itself. popup's javascript: document.queryS....addEventListener('click',function(){window.close();}...
HTML: <html><form> <input type="button" id="xxxxxx" value="close this popup"> <script src="sample.js" /> </form></html> JS: document.querySelector("#xxxxxx").addEventListener("click",function(){window.close();});
window.close() only works if the window was opened via window.open() in the first place, so Fennec apparently doesn't use that to open extension popups.
Component: General → WebExtensions: Android
OS: Unspecified → Android
Product: Firefox for Android → Toolkit
Hardware: Unspecified → All
Version: Firefox 58 → unspecified
> window.close() only works if the window was opened via window.open() In PC, the popup window which appear when I click toolbar button close itself. In Android, when I click menu(...) > "(addon name)" it open a new tab. How can I close this Android extensions tab?
Flags: needinfo?(amckay)
Flags: needinfo?(amckay)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(lgreco)
This seems to do as a work-around: browser.tabs.update({active: true}); This is a no-op on desktop (making an already active tab active), yet on Android it will move the focus away from the pop-up which will implicitly close it.
The options_ui property mentioned in Comment 0 is not the ones that set a popup url to open, nevertheless on desktop we allow the popup to close itself using window.close() and it would be definitely better if we could keep the same behavior on Firefox for Android. The extension popup on Firefox for Android is represented as a tab (which should be auto closed as soon as the user switch to another tab, and it is supposed to also auto close itself the user press the back button) and it is opened by the following code: - https://searchfox.org/mozilla-central/source/mobile/android/components/extensions/ext-utils.js#318-321 On Firefox Desktop we are explicitly allowing some pages to close itself using window.close by ensuring that nsIDOMWindowUtils.allowScriptsToClose() has been called for that window, and so we should apply similar changes to the `tabTracker.openExtensionPopupTab` helper defined in the Firefox for Android WebExtensions internals. Follows some additional details related to how this behavior is currently implemented on Firefox for Desktop. The following code is where we are ensuring that a browserAction popup window can close itself using window.close: - https://searchfox.org/mozilla-central/rev/a539f8f7fe288d0b4d8d6a32510be20f52bb7a0f/browser/components/extensions/ExtensionPopups.jsm#298 -https://searchfox.org/mozilla-central/rev/a539f8f7fe288d0b4d8d6a32510be20f52bb7a0f/toolkit/components/extensions/ext-browser-content.js#76-78 While the following is how we allow a window opened using browser.window.create to close itself (if the allowScriptsToClose parameter has been specified and it is allowed with the rest of the parameters, as described in the related MDN docs: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/windows/create) - https://searchfox.org/mozilla-central/source/browser/components/extensions/ext-windows.js#19,165-168,192,194
Flags: needinfo?(lgreco)
Priority: -- → P3
(In reply to Wladimir Palant (for Adblock Plus info Cc bugzilla@adblockplus.org) from comment #5) > This seems to do as a work-around: > > browser.tabs.update({active: true}); > > This is a no-op on desktop (making an already active tab active), yet on > Android it will move the focus away from the pop-up which will implicitly > close it. You're awesome. It definitely worked.
Product: Toolkit → WebExtensions
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.