Skip to content

Commit

Permalink
Support .responseXML in GM_xmlhttpRequest().
Browse files Browse the repository at this point in the history
  • Loading branch information
arantius committed Mar 21, 2014
1 parent ba9e9ea commit 59f0776
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions modules/xmlhttprequester.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ function(safeUrl, details, req) {
if (details.overrideMimeType) {
req.overrideMimeType(details.overrideMimeType);
}
if (details.responseType) {
req.responseType = details.responseType;
}

if (details.timeout) {
req.timeout = details.timeout;
}
Expand Down Expand Up @@ -179,17 +177,17 @@ function(wrappedContentWin, req, event, details) {
response: "r",
responseHeaders: "r",
responseText: "r",
responseXML: "r",
status: "r",
statusText: "r",
total: "r",
},
context: details.context || null,
// Can't support responseXML because security won't
// let the browser call properties on it.
readyState: req.readyState,
response: req.response,
responseHeaders: null,
responseText: null,
responseXML: null,
status: null,
statusText: null,
finalUrl: null
Expand All @@ -202,6 +200,13 @@ function(wrappedContentWin, req, event, details) {
// .response). Ignore.
}

if (req.responseXML) {
// Adopt the XML object into a content-window-scoped document.
var xmlDoc = wrappedContentWin.Document();
xmlDoc.appendChild(xmlDoc.adoptNode(req.responseXML.documentElement));
responseState.responseXML = xmlDoc;
}

switch (event) {
case "progress":
responseState.lengthComputable = evt.lengthComputable;
Expand Down

0 comments on commit 59f0776

Please sign in to comment.