title: chrome.downloads.download not working from background service worker
body: <p>I'm trying to create a Chrome Extension that will do some analysis of the page content when the toolbar button is clicked, and then save (i.e. download) the results onto the user's machine. I can get the analysis to work when the button is clicked, but I can't get it to trigger the download.</p>
  <p>This is the first time I've written a Chrome Extension, so any help working out why it's not working would be appreciated!</p>
  <p><strong>manifest.json</strong></p>
  <pre><code>{
    ...
    &quot;permissions&quot;: [
      &quot;activeTab&quot;,
      &quot;downloads&quot;,
      &quot;scripting&quot;
    ],
    &quot;background&quot;: {
      &quot;service_worker&quot;: &quot;background.js&quot;
    }
  }
  </code></pre>
  <p><strong>background.js</strong></p>
  <pre><code>chrome.action.onClicked.addListener((tab) =&gt; {
    chrome.scripting.executeScript({
      target: {tabId: tab.id},
      files: ['analysis.js']
    });
  });
  
  chrome.runtime.onMessage.addListener((arg, sender, reply) =&gt; {
    chrome.downloads.download({
      url: 'data:text/plain,' + arg.text,
      filename: arg.name,
      saveAs: true
    })
  });
  </code></pre>
  <p><strong>analysis.js</strong></p>
  <pre><code>// Do some analysis here
  chrome.runtime.sendMessage({name: &quot;results.txt&quot;, text: &quot;ANALYSIS RESULTS HERE&quot;});
  </code></pre>
  <p>When I click the toolbar button, the analysis runs but I don't get a Save dialog nor do any files appear on the disk. What am I doing wrong?</p>