Skip to content
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

Incompatibility between Greasemonkey and Tampermonkey when using GM_xmlhttpRequest with FormData object #183

Closed
GoogleCodeExporter opened this issue Mar 16, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

1.) What Tampermonkey version do you use? (go to 'chrome://extensions/' for
that information)

Tampermonkey version 3.6.3737.80

2.) What browser version (go to 'chrome://chrome/') and operating system do
you use?

Google Chrome version 34.0.1847.131 on Mac OS X

3.) Does a Userscript cause the problem? If so, from where can it be
downloaded?

Not specifically, no. The issue is present in any script that uses a FormData 
object passed to GM_xmlhttpRequest()'s details object `data` property.

4.) Did this work before? Have you checked the script's bug
tracker/discussion page for that problem?

Yes, it used to work before.

5.) Are there other Userscripts installed and running?

Yes, but, again, this issue only affects scripts that use FormData in a 
cross-domain GM_xmlhttpRequest().

6.) Steps to reproduce the problem:

a. Install any script that uses GM_xmlhttpRequest() with a FormData object 
across domains.
b. Use it.
c. Observe error in console log: "No 'Access-Control-Allow-Origin' header is 
present on the requested resource."

7.) What is the expected behavior? What went wrong?

The expected behavior is a successful cross-domain GM_xmlhttpRequest() call, 
which the current Greasemonkey release completes without errors.

8.) Please provide any additional information below.

Third comment in related issue #77:
https://code.google.com/p/tampermonkey/issues/detail?id=77#c3

I notice that as of release version 3.6.3737, Tampermonkey no longer uses 
cross-domain xmlhttpRequest if FormData is used. However, this is different 
than how Greasemonkey behaves, and breaks compatibility with Greasemonkey 
scripts.

Greasemonkey will still allow cross-domain xmlhttpRequest to be used if the 
details object's `data` property is passed a FormData object.

I think this is an implementation bug, since it causes incompatibilities.

Original issue reported on code.google.com by meit...@gmail.com on 25 Apr 2014 at 11:06

@GoogleCodeExporter
Copy link
Author

This is caused by issue 222652, the isolated worlds (which are good in general) 
prevent TM from passing the FormData object to the background context with 
cross-domain capabilities - only plain string or numerical data can be passed.
Since there is no way to get data out of a FormData object TM can not decode 
and transfer it to its background context.

Original comment by derj...@googlemail.com on 29 Apr 2014 at 9:38

  • Changed state: WontFix

@GoogleCodeExporter
Copy link
Author

Oh, I understand now. Thanks for explaining what's going on here to me.

I will submit patches to the scripts that I use with an explanation of how they 
can manually create a multipart/form-data request as a string instead of 
relying on FormData objects.

For anyone who comes to this thread after-the-fact, see this patch for a simple 
example: 
https://github.com/meitar/pat-okcupid/commit/6dcf82e04e633520b77121da167a930be0f
1ca1c

Original comment by meit...@gmail.com on 30 Apr 2014 at 12:23

@GoogleCodeExporter
Copy link
Author

No problem. Actually it's more a "can't fix" than a "won't fix". :)

I set this to "Accepted" again, cause I play with the idea to emulate the 
FormData object to allow TM to get its data out.

Original comment by derj...@googlemail.com on 30 Apr 2014 at 6:46

  • Changed state: Accepted

@Tyf0x
Copy link

Tyf0x commented Oct 23, 2015

Any news on this side?

I'm typically trying to POST a pdf (as a Blob) and receive the CORS error. As stated above, Greasemonkey works fine.

@derjanb derjanb added this to the 4.1 milestone May 18, 2016
@derjanb
Copy link
Member

derjanb commented May 19, 2016

Should be fixed at the latest TM beta version: http://tampermonkey.net/changelog.php?version=4.1.5240&ext=gcal

@derjanb derjanb closed this as completed Aug 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants