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

Issue 816562 link

Starred by 4 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

FetchAPI WebExtension content.js mode="same-origin" error

Reported by eijs...@gmail.com, Feb 26 2018

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36

Steps to reproduce the problem:
1. Create a WebExtension with a content script that fetches a resource on the same domain (same origin) as the active page (perhaps a favicon.ico)
2. In the fetch parameters, use mode="same-origin"
3. Load the WebExtension, visit a random website (like https://google.com/)
4. If the content script requires some action before the fetch is executed, perform the action (like a body click)

What is the expected behavior?
Since the content script is executed in the context of the active webpage, i would expect the fetch to succeed (assuming the resource actually exists)

What went wrong?
The fetch fails with the following error:
Fetch API cannot load https://domain.tld/monkey. Request mode is "same-origin" but the URL's origin is not same as the request origin chrome-extension://ockkingkanakmaledpahojpbjigobckg.

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 64.0.3282.186  Channel: stable
OS Version: OS X 10.13.3
Flash Version:
 
Labels: Needs-Triage-M64
Cc: vamshi.kommuri@chromium.org
Components: Platform>Extensions
Labels: Triaged-ET Needs-Feedback
Thanks for filing the issue!

@Reporter: Could you please share a sample extension to test, as it is out of scope for ET team to create an extension. Any further inputs from your end may help us.

Comment 3 by eijs...@gmail.com, Feb 28 2018

Attachment fetch.xpi is a WebExtension that works on both Chrome and Firefox.
On Chrome when you load the WebExtension and then open a page (say https://google.com/) and click anywhere in the body, an errormessage will be displayed in the console stating:
	content.js:7 Fetch API cannot load https://www.google.com/robots.txt.
	Request mode is "same-origin" but the URL's origin is not same as the request origin chrome-extension://lfgfogfmnjfhenmoeblhncbcamallfmj.
fetch.xpi
896 bytes Download
Project Member

Comment 4 by sheriffbot@chromium.org, Feb 28 2018

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding the requester to the cc list.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: krajshree@chromium.org
Labels: Needs-Feedback
The extension file provided at comment #3 is not compatible to chrome i.e it cannot be added to chrome extensions. It seems to compatible with firefox. Hence, could you please provide a sample extension file having manifest.json file which is compatible to chrome.

Thanks...!!

Comment 6 by woxxom@gmail.com, Mar 7 2018

krajshree@, it's a zip archive, simply unpack it and install from that directory, open https://www.google.com, click in an empty space on the page, observe the console.

Reporter, the observed behavior is correct and matches the documentation:
https://developer.chrome.com/extensions/xhr

  > Each running extension exists within its own separate security origin.

Content scripts use the extension's origin which is why "same-origin" doesn't apply to the web page.
As for Firefox, its implementation of WebExtensions API still has many bugs/quirks even in its core parts.

Comment 7 by eijs...@gmail.com, Mar 12 2018

@woxxom, i assumed the text at https://developer.chrome.com/extensions/xhr applied to background and popup scripts and not content scripts (although it doesn't mention that at all).

Also, if you do not explicitly set mode="same-origin" but omit the mode, the fetch does not fail.

Also, if you set mode="no-cors" (which is the default according to https://fetch.spec.whatwg.org/ ), the fetch appears to succeed but there is no responseText.
Project Member

Comment 8 by sheriffbot@chromium.org, Mar 12 2018

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding the requester to the cc list.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: sindhu.chelamcherla@chromium.org
Labels: M-67 Target-67 FoundIn-67 OS-Linux OS-Windows
Status: Untriaged (was: Unconfirmed)
Able to reproduce this issue on reported version 64.0.3282.186, on latest stable 65.0.3325.181, on latest beta 66.0.3359.81 and on latest canary 67.0.3394.0 using Windows 10, Mac 10.13.3 and Ubuntu 14.04.

This issue is seen from M-60. Hence considering this issue as Non-Regression and marking as Untriaged.

Thanks!
Components: Blink>Network>XHR Blink>Network>FetchAPI
[Extensions Triage] Can someone who works on fetch-api/xhr see what's the expected behavior here?
Owner: toyoshim@chromium.org
Status: Assigned (was: Untriaged)
+toyoshim, I know you've been looking at extensions and CORS recently, can you take a look?
Seeing something similar with jifpbeccnghkjeaalbbjmodiffmgedin as well -- permission exists (confirmed by chrome.permissions) but CORS preflight is being issued.
Labels: -Hotlist-Interop

Sign in to add a comment