Closed Bug 1402289 Opened 8 years ago Closed 8 years ago

Requests to relative URL from content script do not work as in chrome

Categories

(WebExtensions :: Compatibility, defect)

58 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: geku94, Unassigned)

Details

(Keywords: dev-doc-complete)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36 Steps to reproduce: Sent a request: fetch('/ajax.php', { method: 'get', credentials: 'include' }) .then((res) => res.text()) .then((resp) => { console.log(resp) }); Same result with jQuery.ajax() equivalent. Actual results: Nothing happens on page where content script is injected (no errors in console and nothing on network tab). There is an error on background page: TypeError: /ajax.php is not a valid URL. Changing '/ajax.php' to 'https://example.com/ajax.php' works. Expected results: Text should appear in console. That is how it works in Chrome. Also in Chrome all requests sent from content script appears on network tab of a page where content script is injected. In Firefox they appear on network tab of a background page. Not sure if this is intended. And this may be the cause of a bug (requests being sent from background page instead of a page where content script is injected). As a workaround changing all 'ajax.php' to location.origin + '/ajax.php' works.
Content script requests happen in the context of your extension, not of the content page. This is intentional.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
Perhaps
Keywords: dev-doc-needed
> Should it be listed here https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities ? Looks like you added this already, geku94. Thanks!
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.