title: Firefox WebExtension API "downloads" not working
body: <p>I want to create my own extension, which automatically downloads files from certain websites and saves it in the default downloads folder. I started with the <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Your_first_WebExtension" rel="nofollow noreferrer">"your first extension"</a> example that creates a red border around the page. This worked!</p>
  
  <p>Then I tried to use <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/downloads/download" rel="nofollow noreferrer">this example</a>, which explains the download function, to download an image from google server and it just won't work. I also added a permission for "downloads" API in the manifest.json, but it does not help. The code breaks and everything after <code>browser.downloads.download</code> is not executed.</p>
  
  <p>I also tried <code>console.log(browser);</code> and <code>console.log(browser.downloads);</code>. The <code>browser</code> object is defined, but <code>browser.downloads</code> is undefined.</p>
  
  <p>Here is the code:</p>
  
  <p>manifest.json:</p>
  
  <pre><code>{
  
  "manifest_version": 2,
  "name": "Permission Test",
  "version": "1.0",
  
  "description": "Downloads an image",
  
  "applications": {
      "gecko": {
          "id": "permission@example.com"
      }
  },
  
  "icons": {
      "48": "icons/border-48.png"
  },
  
  "permissions": [
      "activeTab",
      "downloads"
  ],
  
  "content_scripts": [
      {
      "matches": ["*://www.google.de/logos/doodles/2018/*"],
      "js": ["script.js"]
      }
  ]
  
  }
  </code></pre>
  
  <p>script.js:</p>
  
  <pre><code>document.body.style.border = "10px solid red";
  console.log('Extension started.');
  
  
  function onStartedDownload(id) {
      console.log('Started downloading: ${id}');
  }
  
  function onFailed(error) {
      console.log('Download failed: ${error}');
  }
  
  var downloadUrl = "https://www.google.de/logos/doodles/2018/virginia-woolfs-136th-birthday-5857012284915712.6-l.png";
  
  console.log(browser.downloads);
  
  var downloading = browser.downloads.download({
      url: downloadUrl
      //filename: 'my-image-again.gif',
      conflictAction: 'uniquify'
  });
  
  downloading.then(onStartedDownload, onFailed);
  
  console.log('Extension execution finished.');
  </code></pre>
  
  <p>I am using Firefox 58 and Windows 7.</p>