Opening PDF with "Content-Disposition: attachment" Header Breaks AJAX in Page

Originator:timtrinidad
Number:rdar://10676317 Date Originated:11-Jan-2012 11:43 AM
Status:open Resolved:
Product:iOS Product Version:5.0.1
Classification:Serious Bug Reproducible:Always
 
Summary: 
When a PDF with the header "Content-Disposition: attachment" is downloaded from within Mobile Safari, the Safari Page loses its securityOrigin and all subsequent AJAX requests on that domain fail with the following error message:
"XMLHTTPRequest cannot load http://example.com/path/ajax.php. Cannot make any requests from null".
It seems to be failing at line 105 of http://opensource.apple.com/source/WebCore/WebCore-1298/loader/CrossOriginAccessControl.cpp 
Opening the PDF in a New Page or closing the original page and making requests from a new one fixes the issue. 

Steps to Reproduce:
1) On iOS 5.0 or 5.0.1, go to http://timtrinidad.com/ajaxtest. Click on file.pdf under "Content-disposition: attachment" to open PDF in the browser.
2) Click Back
3) Reload the original page

Expected Results:
After the reload, the page loads the AJAX response.

Actual Results:
No AJAX response is loaded; the following error is thrown in the console:
JavaScript: Error on Line 1
XMLHttpRequest cannot load http://timtrinidad.com/ajaxtest/ajax.php. Cannot make any requests from null.

Regression:

Notes:
The test source code is in the attached zip files. All other files on the page work without issue.

Comments

Same issue with JPEGs using

I have the same issue using JPEGs, new session will work fine until downloading an image as attachment. ios5.1 (9B176)

By mahatmanich at June 7, 2012, 7:44 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!