I’m now porting one of my add-ons for Android and I have a problem with one of the features - taking screenshot of current page using a button in the Popup.
Since Popups in Android are opened as normal pages, when I click the button in the Popup, it will take screenshot of the Popup
Is there some nice way to wait for the Popup to be closed?
This is my button click:
e => {browser.runtime.sendMessage({type: 'add_current'}); window.close()};
Then background will handle the screenshot capture - and here I would like to wait for the pop-up to be closed and the previous page to be rendered.
NOTE that caputreTab API should solve this issue (because you can specify target tab id) but it seems to be broken in Android: https://bugzilla.mozilla.org/show_bug.cgi?id=1536384
EDIT:
One bug here - seems like Popup in Android cannot be closed with window.close()
and one have to use browser.tabs.getCurrent().then(tab => browser.tabs.remove(tab.id))
to close it - this however won’t work in desktop version so you need to detect Android first with something like this browser.runtime.getPlatformInfo().then(({os}) => os === 'android')
.
EDIT 2:
browser.tabs.captureTab
actually doesn’t exists on Android
Still the original problem remains.