Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 383281

Summary: DOMException thrown for JSON.stringify XMLHttpRequest in Chrome 21+
Product: [ECD] Orion Reporter: Simon Kaegi <simon_kaegi>
Component: ClientAssignee: Simon Kaegi <simon_kaegi>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: john.arthorne, ken_walker, mamacdon, pwebster
Version: 0.5Flags: ken_walker: review+
Target Milestone: 0.5 RC3   
Hardware: PC   
OS: Windows Server 2008   
Whiteboard:

Description Simon Kaegi CLA 2012-06-21 22:27:05 EDT
In Chrome 21+ the following code will throw a DOMException..
JSON.stringify(new XMLHttpRequest());

The problem here is that in plugin.js we inadvertently can try to stringify an XHR 
when returning a response. I'll log a bug against Chrome and possibly webkit but we probably should do a better job of protecting ourselves.
Comment 1 Simon Kaegi CLA 2012-06-21 22:39:11 EDT
Also see https://code.google.com/p/chromium/issues/detail?id=134082
Comment 2 Simon Kaegi CLA 2012-06-21 22:57:29 EDT
I'm hopeful we will get a quick response from the Chrome team however...

A vaguely unsettling fix to cover the immediate problem for this might be to put something like..

if (error && error.xhr) {
    delete error.xhr;
}

in the two spots in plugin.js (~line 100 and 110) to ensure an xhr is not stringified.
Comment 3 Ken Walker CLA 2012-06-22 11:39:55 EDT
Looks good - running a build with this change
Comment 4 Simon Kaegi CLA 2012-06-22 11:46:25 EDT
For 0.5 we're using the following JSON stringify replacer to specifically target the XHR case...

function jsonXMLHttpRequestReplacer(name, value) {
	if (value && value instanceof XMLHttpRequest) {
		return {
			status: value.status, 
			statusText: value.statusText
		};
	}
	return value;
}

Will come back and close after we've done further verification.
Comment 5 John Arthorne CLA 2012-06-26 08:44:39 EDT
Can this be marked fixed now? I also noticed the bug has been fixed upstream in Chrome already.
Comment 6 Simon Kaegi CLA 2012-06-26 10:06:33 EDT
.