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

GM_xmlhttpRequest response.responseText is undefined in Nightly17.0a1 since landing of Bug553102 #1607

Closed
alice0775 opened this issue Aug 20, 2012 · 6 comments
Milestone

Comments

@alice0775
Copy link

In Greasemonkey 1.0b7 and Nightly17.0a1 .
response.responseText is undefined .
This problem happens since landing of Bug553102

GM_xmlhttpRequest({
method: "GET",
url: "http://www.google.com/",
onload: function(response) {
alert(response.responseText);
}
});

@arantius
Copy link
Collaborator

@arantius
Copy link
Collaborator

@alice0775
Copy link
Author

possible fix

--- a/content/xmlhttprequester.js   2012-08-09 12:45:42 +0900
+++ b/content/xmlhttprequester.js   2012-08-23 12:05:31 +0900
@@ -36,17 +36,27 @@
     case "ftp":
         var req = new this.chromeWindow.XMLHttpRequest();
         GM_util.hitch(this, "chromeStartRequest", url, details, req)();
       break;
     default:
       throw new Error("Disallowed scheme in URL: " + details.url);
   }
 
-  var rv = { abort: function () { return req.abort(); } };
+  var rv = { 
+    __exposedProps__: {
+        finalUrl: "r",
+        readyState: "r",
+        responseHeaders: "r",
+        responseText: "r",
+        status: "r",
+        statusText: "r"
+    },
+    abort: function () { return req.abort(); } 
+  };
   if (!!details.synchronous) {
     rv.finalUrl = req.finalUrl;
     rv.readyState = req.readyState;
     rv.responseHeaders = req.getAllResponseHeaders();
     rv.responseText = req.responseText;
     rv.status = req.status;
     rv.statusText = req.statusText;
   }
@@ -132,16 +142,24 @@
 // method by the same name which is a property of 'details' in the content
 // window's security context.
 GM_xmlhttpRequester.prototype.setupRequestEvent =
 function(wrappedContentWin, req, event, details) {
   if (!details["on" + event]) return;
 
   req.addEventListener(event, function(evt) {
     var responseState = {
+      __exposedProps__: {
+        finalUrl: "r",
+        readyState: "r",
+        responseHeaders: "r",
+        responseText: "r",
+        status: "r",
+        statusText: "r"
+      },
       // Can't support responseXML because security won't
       // let the browser call properties on it.
       responseText: req.responseText,
       readyState: req.readyState,
       responseHeaders: null,
       status: null,
       statusText: null,
       finalUrl: null

@piyushsoni
Copy link

Hi arantius,
I think the issue is fixed in the scripts, but somehow it seems I can't do the same in a Firefox extension created from the script using the script-compiler you had written (here: https://arantius.com/misc/greasemonkey/script-compiler.php). I'm not sure if it's a new error or it was never supposed to work that way. Could you please check? I can't keep it dependent on GreaseMonkey because of company limitations :( (It's an internal add-on)..

Thanks,
Piyush

@arantius
Copy link
Collaborator

https://github.com/arantius/greasemonkey-compiler

Pull requests accepted.

@piyushsoni
Copy link

Thanks. Actually, now when I compared the code, I see that you have fixed it on the web version but not here on github repository linked above. So the only reason mine was broken was that I had compiled it long back. But that smalll exposedprops change in the xmlhttprequester.js fixed it in my extension! Thanks again.

Martii pushed a commit to Martii/UserScripts that referenced this issue May 17, 2014
- Compatibility fix with Greasemonkey 1.1 and Firefox 15+. See also [greasemonkey#1595](http://github.com/greasemonkey/greasemonkey/issues/1595) and [greasemonkey#1607](greasemonkey/greasemonkey#1607). Reenables inline versions and diffs.
- Misc tweak

69307.503483

1930d046f0f8c6e9daded2e337128e83acdbf69b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants