title: Unable to use getBackgroundPage() api from a devtools extension
body: <p>I am trying to write an extension that adds functionality to the Chrome devtools.</p>
  
  <p>According to the devtools documentation, it says that the pages in devtools support very limited apis. Any API that is not supported can be access by accessing it through the background page, just as what contentscripts does.</p>
  
  <p>Here is the relevant documentation snippet:</p>
  
  <blockquote>
    <p>The tabId property provides the tab identifier that you can use with the chrome.tabs.* API calls. However, please note that chrome.tabs.* API is not exposed to the Developer Tools extension pages due to security considerations — you will need to pass the tab ID to the background page and invoke the chrome.tabs.* API functions from there.</p>
  </blockquote>
  
  <p>Here is the source url: <a href="http://developer.chrome.com/extensions/devtools.inspectedWindow.html" rel="nofollow">http://developer.chrome.com/extensions/devtools.inspectedWindow.html</a></p>
  
  <p>However, when I try to do that, I get the following error in the console:</p>
  
  <pre><code>uncaught Error: "getBackgroundPage" can only be used in extension processes. See the content scripts documentation for more details. 
  </code></pre>
  
  <p>Here is my code in my devtools.js script:</p>
  
  <pre><code>chrome.extension.getBackgroundPage().getLocation();
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I should describe my scenario first, and show how I am implementing it.</p>
  
  <p>What I want to do is to display extra data in a devtools panel related to a webpage. In order to get that data, I will need to send a HTTP request in the same session as the page being debugged, because it requires authentication.</p>
  
  <p>Use Case:</p>
  
  <p>User browses to a particular URL. He is authenticated to the site. He then invokes devtools. The devtools panel opens up and a new panel shows up that has extra data related to the page.</p>
  
  <p>Implementation:</p>
  
  <p>1) DevTools script finds out the url of the page being inspected. If the url matches the site base hostname, then it opens a panel. In the callback of the panel creation, it sends a message to a background page, asking it to download a JSON payload from a debug endpoint on the same site, and then sends it to the devtools extension, wh ich then displays it.</p>
  
  <p>Problems:</p>
  
  <p>1) The background page gets the request, and downloads the URL. However the download is not using the same session as the user, so the download request fails.</p>
  
  <p>2) From devtools window, I got the tabId of the inspected window. I send this tabId to the background page so that it can parse some stuff out of the url. However, chrome.tabs.get(tabId) does not return the tab.</p>
  
  <p>To summarize, I need to</p>
  
  <p>1) Get the background page to download data in the same session as the user's tab that is being debugged.
  2) I need to have the background page be able to get access to the user's tab.</p>