title: How to get the title of the current tab in firefox web extension?
body: <p>I am trying to code a simple firefox extension that displays the title of the current tab the user is viewing when the extension's button is pressed.</p>
  <p>Here is my manifest.json file:</p>
  <pre><code>{
  
      &quot;manifest_version&quot;: 2,
      &quot;name&quot;: &quot;Perspective&quot;,
      &quot;version&quot;: &quot;1.0&quot;,
  
      &quot;description&quot;: &quot;Displays current tab title when clicked&quot;,
  
      &quot;permissions&quot;: [
          &quot;tabs&quot;
      ],
  
      &quot;icons&quot;: {
          &quot;48&quot;: &quot;icons/border-48.png&quot;
      },
  
      &quot;browser_action&quot;: {
          &quot;browser_style&quot;: true,
          &quot;default_popup&quot;: &quot;popup/choose_page.html&quot;,
          &quot;default_icon&quot;: {
              &quot;16&quot;: &quot;icons/news-icon-16.png&quot;,
              &quot;32&quot;: &quot;icons/news-icon-32.png&quot;
          }
      }
  }
  </code></pre>
  <p>And, here is my choose_page.js file</p>
  <pre><code>//Fetch the title of the active tab
  console.log(&quot;-----------Button Clicked------------&quot;);
  var activeTab = browser.tabs.query({active: true, currentWindow: true});
  console.log(&quot;---------Printing type of variable \&quot;activeTab\&quot;&quot;);
  if (typeof activeTab == &quot;undefined&quot;)
      console.log(&quot;The object is undefined&quot;)
  else 
      console.log(&quot;The type of activeTab is:&quot; + typeof activeTab)
  
  console.log(&quot;The title of activeTab is:&quot;)
  console.log(activeTab.title);
  </code></pre>
  <p>Whenever I click my extension's button, I get the following output in the console:</p>
  <blockquote>
  <p>-----------Button Clicked------------</p>
  <p>---------Printing type of variable &quot;activeTab&quot;</p>
  <p>The type of activeTab is:object</p>
  <p>The title of activeTab is:</p>
  <p>undefined</p>
  </blockquote>
  <p>Why is the title of &quot;activeTab&quot; undefined, and how do I actually get the title of the current tab the user is viewing?</p>
  <p>Here is the link to all of the files in the extension: <a href="https://drive.google.com/file/d/1L7vho9iSL9nX2LKBmCveJvODmKQBlqX9/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1L7vho9iSL9nX2LKBmCveJvODmKQBlqX9/view?usp=sharing</a></p>