Closed Bug 755072 Opened 13 years ago Closed 13 years ago

Cross-origin XHR to CORS-compliant server fails if instantiated from Offline Cache

Categories

(Core :: Networking: Cache, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 687758

People

(Reporter: markus.neubrand, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0 Build ID: 20120423122843 Steps to reproduce: A simple XHR to a CORS-compliant server (Access-Control-Allow-Origin: *) fails from within a B2G app. The same request succeeds on a FF 15.0a1 nightly build. var httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function () { if (httpRequest.readyState === 4) { if (httpRequest.status === 200) { console.log('Success'); } else { console.log('Error'); } } }; httpRequest.open('GET', 'http://192.168.1.104:8080/?http://www.google.com'); httpRequest.send(null); In the example above http://www.html5rocks.com/en/ returns a site with correctly set CORS HTTP headers to allow cross-origin resources (Access-Control-Allow-Origin: *). Actual results: The XHR stops after readyState changed to HEADERS_RECEIVED Expected results: The XHR should complete and contain the correct responseText
If you are getting a readyState change to HEADERS_RECEIVED you are most likely not running into a CORS problem. CORS stops the request before the HEADERS_RECEIVED readystatechange happens.
Could be not related to CORS. Is there any way for me to further debug this or provide information on this? http://192.168.1.104:8080/?http://www.google.com should be http://www.html5rocks.com/en/ in the example above.
If you have access to a debug build you could try to set a breakpoint in XMLHttpRequest::OnStopRequest and see what 'status' argument you are receiving, and what the call-stack looks like.
Sounds like a platform issue related to Offline Cache and XHR/CORS. I can reproduce the issue if I load the page from Offline Cache in Firefox. I didn't get the time to debug but in the JS console there is a: Timestamp: 16/05/2012 20:04:40 Error: NS_ERROR_FAILURE: Failure Source File: http://system.gaiamobile.org/ Line: 25
Status: UNCONFIRMED → NEW
Component: General → Networking: Cache
Ever confirmed: true
Product: Boot2Gecko → Core
QA Contact: general → networking.cache
Version: unspecified → Trunk
Summary: Cross-origin XHR to CORS-compliant server fails in B2G app → Cross-origin XHR to CORS-compliant server fails if instantiated from Offline Cache
WARNING: NS_ENSURE_SUCCESS(status, status) failed with result 0x804B0046: file c:/Mozilla/src/mozilla-central/content/base/src/nsCrossSiteListenerProxy.cpp, line 546 0x804B0046 = NS_ERROR_DOCUMENT_NOT_CACHE. You have to add NETWORK: http://www.html5rocks.com/en/ to your manifest. However, that is not enough, see bug 687758 comment 11. The same applies to NETWORK: entries.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.