title: Chrome extension: identify web requests of background-page iframe?
body: <p>I'm writing a Chrome extension that periodically checks a web-page on the user's behalf. To be unobtrusive, the page is loaded into an iframe on the extension's hidden background page. <strong>Is it possible to identify just the web requests made by this iframe?</strong></p>
  
  <p>My initial experiments (see below) seem to indicate that this is tricky. Getting all web requests for a particular tab is easy: you have the tabId, and can filter web requests (via the WebRequest API) with that tabId. But for a background-page iframe, it's unclear what the "tabId equivalent" identifier is, or how to use it to filter web requests.</p>
  
  <p>Any thoughts? </p>
  
  <p>My initial experiment details are below.
  The frameId value looked promising, but I don't believe it's unique across extensions.</p>
  
  <p>This question has already been asked for Firefox: <a href="https://stackoverflow.com/questions/19076691/identify-requests-originating-in-the-hiddendomwindow-or-one-of-its-iframes?lq=1">Identify requests originating in the hiddenDOMWindow (or one of its iframes)</a></p>
  
  <p><em>== Experiment ==</em></p>
  
  <p>As an experiment, I:</p>
  
  <ul>
  <li>Listened for all web requests with the WebRequest API</li>
  <li>Created an iframe on the extension's background page, and opened a url.</li>
  </ul>
  
  <p>Here's a captured iframe web request:</p>
  
  <pre><code>{
    "frameId": 2,
    "method": "GET",
    "parentFrameId": 0,
    "requestId": "11988",
    "tabId": -1,
    "timeStamp": 1395423892612.272,
    "type": "sub_frame",
    "url": "http://en.wikipedia.org/wiki/Frog"
  }
  </code></pre>
  
  <p>The tabId and parentFrameId values look suspect.</p>
  
  <p>The frameId value looks promising. If we knew the frameId of the frame, could we use that to filter requests?</p>
  
  <p>Possibly, but the frameId value isn't unique across browser extensions.
  I created another identical extension, and got its background iframe to load the same url. It generated an identical looking request, with identical frameId (for its own - but different - iframe).
  Also, this Chromium issue refers to "frame id collisions": <a href="https://code.google.com/p/chromium/issues/detail?id=173325" rel="nofollow noreferrer">https://code.google.com/p/chromium/issues/detail?id=173325</a></p>