# Get url of activetab from popup on Android

**URL:** https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230
**Category:** Add-ons
**Created:** [October 17, 2020, 2:26pm UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230 "2020-10-17T14:26:08Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Offerel](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@Offerel](https://discourse.mozilla.org/u/Offerel)
#### Post date: [October 17, 2020, 2:26pm UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230/1 "2020-10-17T14:26:08Z")

</div>

In a Webextension created for Firefox desktop i can get the url of the activetab by using this code:

```auto
chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
    console.log(tabs[0].url);
})

```

However, if I use this in latest Firefox Nightly on Android, I get only ‘undefined’.

How can I retrieve the url of the activetab?

And yes, in permissions, I have set activetab.

---

<div class="post-metadata">

### Author: ![freaktechnik](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/freaktechnik/32/37766_2.png) [@freaktechnik](https://discourse.mozilla.org/u/freaktechnik)
#### Post date: [October 17, 2020, 6:16pm UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230/2 "2020-10-17T18:16:28Z")

</div>

I assume undefined is tze value of the first tab that the promise resolves to i.e. it resolves to an empty array?

Where/when are you querying?

Also, does removing the currentWindow filter change anything? I could see that producing incorrect results if it’s not impmemented on android.

---

<div class="post-metadata">

### Author: ![evilpie](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/evilpie/32/30580_2.png) [@evilpie](https://discourse.mozilla.org/u/evilpie)
#### Post date: [October 17, 2020, 6:35pm UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230/3 "2020-10-17T18:35:53Z")

</div>

Yeah I ran into the same issue. Removing `currentWindow: true` worked for me. I guess the new Firefox for Android doesn’t implement windows at all.

---

<div class="post-metadata">

### Author: ![Offerel](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@Offerel](https://discourse.mozilla.org/u/Offerel)
#### Post date: [October 17, 2020, 6:37pm UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230/4 "2020-10-17T18:37:34Z")

</div>

It does not change, when I suppress currentWindow. As you can see in the attached screenshot, i get some information about the tab. But i miss the url info, which is what i need.

 ![screenshot_06](https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/a/7/a713f2607e87b1e70e49a9059d244d845b07685f.jpeg)

As permission, i have **not** set tabs, but i have enabled activeTab. It works as expected on the desktop, but not on Android. The screenshot is from the Dev console, with USB Debugging enabled.

---

<div class="post-metadata">

### Author: ![Offerel](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@Offerel](https://discourse.mozilla.org/u/Offerel)
#### Post date: [October 17, 2020, 6:40pm UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230/5 "2020-10-17T18:40:09Z")

</div>

This is without currentWindow:

 ![grafik](https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/f/3/f32d551598bfd17eb5efc5d7c119183fdb18eb12.png)

---

<div class="post-metadata">

### Author: ![Offerel](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@Offerel](https://discourse.mozilla.org/u/Offerel)
#### Post date: [October 17, 2020, 6:43pm UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230/6 "2020-10-17T18:43:29Z")

</div>

BTW: Currently I install an AddOn in Firefox Android by releasing a new version on AMO and installing it in Nightly with a custom collection. I have not found a way, to install a extension without AMO, so that i can test it before releasing a new version. If someone knows a way, please let me know.

---

<div class="post-metadata">

### Author: ![evilpie](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/evilpie/32/30580_2.png) [@evilpie](https://discourse.mozilla.org/u/evilpie)
#### Post date: [October 17, 2020, 9:20pm UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230/7 "2020-10-17T21:20:47Z")

</div>

Sure you can follow the instructions at [https://extensionworkshop.com/documentation/develop/developing-extensions-for-firefox-for-android/](https://extensionworkshop.com/documentation/develop/developing-extensions-for-firefox-for-android/) using web-ext.

---

<div class="post-metadata">

### Author: ![freaktechnik](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/freaktechnik/32/37766_2.png) [@freaktechnik](https://discourse.mozilla.org/u/freaktechnik)
#### Post date: [October 17, 2020, 10:54pm UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230/8 "2020-10-17T22:54:19Z")

</div>

Thanks. It seems to me like you’re querying tab info from somewhere that isn’t considered a user interaction for some reason. So I repeat the question: when/where are you running this?

---

<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: [October 18, 2020, 8:10am UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230/9 "2020-10-18T08:10:02Z")

</div>

There should be a forum rule that you have to upload a test extension that demonstrates your problem or what you’re trying to do.

---

<div class="post-metadata">

### Author: ![Offerel](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@Offerel](https://discourse.mozilla.org/u/Offerel)
#### Post date: [October 18, 2020, 9:23am UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230/10 "2020-10-18T09:23:54Z")

</div>

I have a popup which is displayed when I click the browserAction icon. I have not found a other way to add custom menus. That’s why, i use the popup. In this popup i have placed a dynamic menu structure. When I click one of this menu entrys, the above code should be executed. This works at least on the desktop but not on Android.

---

<div class="post-metadata">

### Author: ![freaktechnik](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/freaktechnik/32/37766_2.png) [@freaktechnik](https://discourse.mozilla.org/u/freaktechnik)
#### Post date: [October 18, 2020, 11:50am UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230/11 "2020-10-18T11:50:17Z")

</div>

> <https://github.com/mozilla-mobile/fenix/issues/14093>
>
> \## Steps to reproduce
> 1) Create extension with \`activeTab\` permission but not \`t…abs\` permission.
> 2) In the popup script execute:
> \`\`\`
> console.log((await browser.tabs.query({active: true, lastFocusedWindow: true}))\[0\].url)
> \`\`\`
> 
> \### Expected behavior
> It should log current tab URL.
> 
> \### Actual behavior
> It will log \`undefined\`.
> 
> This works in Fennec or if you add \`tabs\` permission.
> 
> \### Device information
> 
> \* Android device: android emulator
> \* Fenix version: 80.0.1-beta.2 (Build #2015758613)
> 
> ┆Issue is synchronized with this \[Jira Task\](https://mozilla-hub.atlassian.net/browse/FNXV2-5366)

---

<div class="post-metadata">

### Author: ![Offerel](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@Offerel](https://discourse.mozilla.org/u/Offerel)
#### Post date: [October 18, 2020, 6:52pm UTC](https://discourse.mozilla.org/t/get-url-of-activetab-from-popup-on-android/69230/12 "2020-10-18T18:52:21Z")

</div>

Many thx for that link. This helped a lot. I have tried it now with “tabs” permission and it worked as a workaround and i get the correct url in my callback. I hope this bug will be fixed soon, since i only need “activeTab” as permission in reality.

Many thx for helping also with installing temporary on Android. I never used npm or nodejs before. But now i can pre-test before releasing a new version.
