New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 648393 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Extension SW not intercepting fetch/xhr from web page to WAR

Project Member Reported by lazyboy@chromium.org, Sep 19 2016

Issue description

(Filing bug from alchemist@)
It seems that some fetch calls to web_accessible_resources are still not working for Extension SW.

Steps:
1) from extension, register a SW to intercept fetch:
manifest.json:
..
"web_accessible_resources": ["war.html"],

background.js: 
navigator.serviceWorker.register('/sw.js');

sw.js:
self.addEventListener('fetch', event => {
  console.log('FETCH: ' + event.request.url);  // #XYZ
  if (event.request.url.endsWith('war.html')) {
    event.respondWith(new Response('sw content'));
  }
});

2) from page, fetch() a WAR, e.g.:
fetch('chrome-extension://abcd.../war.html').then(...);


Fetch handler in #XYZ above does not see war.html
Same goes with XHR.

However, if I load the resource through an iframe element in the page in step 2, fetch handler seems to see that. This was fixed in https://codereview.chromium.org/1532633003 & https://bugs.chromium.org/p/chromium/issues/detail?id=567382, but fetch/xhr still doesn't work.
 
Cc: alchemist@google.com
Hmmm, this doesn't work because the requester is the web page context[1], whereas for the iframe case mentioned above^^^, it is the extension context.

So this probably is working as intended.

[1] See m_document->fetcher()->isControlledByServiceWorker() check here:
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp?rcl=1474312969&l=240
Status: WontFix (was: Started)
Marking as working as intended. (Seem comment #1)

Sign in to add a comment