New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xmlHttpRequest.open no longer accepts path without protocol and host #2771

Closed
jesus2099 opened this Issue Dec 14, 2017 · 9 comments

Comments

Projects
None yet
5 participants
@jesus2099
Copy link

jesus2099 commented Dec 14, 2017

II have noticed in jesus2099/konami-command#372 that Firefox v57 + Greasemonkey v4 would only work with full URL https?://host.tld/pathname and no longer works with just /pathname.
Firefox v57 + another GM engine is not affected by this regression, this is why I open a ticket here.

@jesus2099

This comment has been minimized.

Copy link

jesus2099 commented Dec 14, 2017

In my work‐around, I had to append self.location.protocol + "//" + self.location.host + in front of my URL.

@Sxderp

This comment has been minimized.

Copy link
Contributor

Sxderp commented Dec 14, 2017

Running requests from a content script context (which userscripts are run in) must use full urls.

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities#Content_script_requests_happen_in_the_context_of_extension_not_content_page

If you don't want to use full urls then you can use the methods on window.wrappedJSObject and export any functions that are needed to run (onreadystatechange, etc) using exportFunction(). My suggestion is just to use full urls.

@jesus2099

This comment has been minimized.

Copy link

jesus2099 commented Dec 14, 2017

Thanks very much for your help.
OK so you mean it’s per specifications of the WebExtensions system, right?
I don’t know this WebExtensions stuff, but it seems to be a standard…?
I don’t remember reading anything about this particular regression in the GM v4 for authors blog posts.
It’s sure this regression is permanent?

@Sxderp

This comment has been minimized.

Copy link
Contributor

Sxderp commented Dec 14, 2017

It’s sure this regression is permanent?

Maybe. I don't really know. Perhaps down the line @grant none will not have these issues, if a proper sandbox can be created. But if some privileged APIs are required then these steps may be necessary. The ball's really in Mozilla's court.

@jesus2099

This comment has been minimized.

Copy link

jesus2099 commented Dec 14, 2017

FTR my script is a @grant none script.
I let the project leaders close or not close this ticket.
I’ll adapt.

@arantius

This comment has been minimized.

Copy link
Collaborator

arantius commented Dec 14, 2017

This is not intended, so it shouldn't be expected to be permanent. We could totally resolve non-absolute paths based on the document as a root.

@arantius arantius added this to the 4.2 milestone Dec 14, 2017

Martii referenced this issue in Martii/UserScripts Dec 14, 2017

oujs - Meta View 4.3.0
* Fix for Fx 57 not recognizing relative urls in xhr... seriously?
* Give some scroll bars if GM4 is detected. Ace is going to be an issue since Page Scripts and Content Scripts don't see each other.
@iology

This comment has been minimized.

Copy link
Contributor

iology commented Dec 16, 2017

Please note that the correct base url is: document.baseURI (related to <base href="...">)

@dogancelik

This comment has been minimized.

Copy link

dogancelik commented Dec 17, 2017

I can confirm, jQuery AJAX doesn't work with only path URL.
Firefox 57, latest Greasemonkey.

$.ajax({
  url: '/some/path',
  success: () => {}
});

My AJAX works with old Firefox (pre-WebExtensions)

@jesus2099 jesus2099 changed the title xmlHttpRequest.open no longer accept path without protocol and host xmlHttpRequest.open no longer accepts path without protocol and host Dec 19, 2017

@arantius arantius closed this in 867565c Jan 5, 2018

@arantius

This comment has been minimized.

Copy link
Collaborator

arantius commented Jan 5, 2018

The above fix has been packaged in a new beta version:
https://addons.mozilla.org/firefox/downloads/file/830369/greasemonkey-4.2beta1-an+fx.xpi?src=devhub

Testing and confirmation would be appreciated!

arantius added a commit that referenced this issue Jan 8, 2018

Merge pull request #2792 from ToadKing/fix-xhr
fix XMLHttpRequests that don't have the "async" parameter

Refs #2771
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment