Open Bug 564744 Opened 11 years ago Updated 2 years ago

XMLHttpRequest request cancelled (with status of 0 and no response text) if file downloading window pops up meanwhile

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows 7
defect
Not set
normal

Tracking

()

UNCONFIRMED

People

(Reporter: wanghongbing, Unassigned)

References

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15 (.NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15 (.NET CLR 3.5.30729)

In a page which is ajax enabled and with a link to download a file, if right after sending out a XMLHttpRequest request, click a link which triggers a downloading of file popup, the response of the request has status of 0 and no response text. If click the downloading link first, then trigger the ajax call, it works fine.

Reproducible: Always

Steps to Reproduce:
1. send ajax through XMLHttpRequest and let the response delay 5 secs
2. click a download link in the same page to make a download window pop up
3. check the XMLHttpRequest status and response text
Actual Results:  
status is 0 and response text is empty

Expected Results:  
status is 200 and response text should be what is sent from server

Here is reproducible page
1. myTest.html

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Ajax - PHP example</title>
      </head>

      <body>
      <script language="javascript" type="text/javascript">
      // Get the HTTP Object
      function getHTTPObject(){
        if (window.ActiveXObject)
          return new ActiveXObject("Microsoft.XMLHTTP");
        else if (window.XMLHttpRequest)
          return new XMLHttpRequest();
        else {
          alert("Your browser does not support AJAX.");
          return null;
        }
      }

      // Change the value of the outputText field
      function setOutput(){
        if(httpObject.readyState == 4){
          document.getElementById('outputText').value = "Response Status: " + httpObject.status +
          " Response text: " + httpObject.responseText;
        }
      }

      // Implement business logic
      function doWork(){
        httpObject = getHTTPObject();
        if (httpObject != null) {
          httpObject.open("GET", "myTest.php?inputText="
          + document.getElementById('inputText').value, true);
          httpObject.send(null);
          httpObject.onreadystatechange = setOutput;
        }
      }

      var httpObject = null;

      </script>

      <form name="testForm">
      Input text: <input type="text" onkeyup="doWork();" name="inputText" id="inputText" />
      <p/>
      Output text: <input type="text" name="outputText" id="outputText" />
      </form>
      <p/>
      <a href="myTest.zip">Download myTest.zip</a>

      </body>
      </html>

2. myTest.php, it delays 5 secs to simulate the real case

      <?php
      sleep(5);
      if (isset($_GET['inputText']))
        echo strtoupper($_GET['inputText']);
      ?>

3. create a zip file, myTest.zip

To reproduce it, launch myTest.html page, enter "test" in Input Text field, and then click "Download myTest.zip" link, wait 5 secs, check Output Text field, you'll "Response status is 200 and Response text"
Thanks for the report. Firefox 3.0 is very old though, so could you re-test with the latest development build (using a new, clean profile) first? http://nightly.mozilla.org/

Sorry you didn't get a reply sooner.
Component: General → DOM: Mozilla Extensions
Product: Firefox → Core
QA Contact: general → general
Summary: XMLHttpRequest returns status of 0 and no response text if file downloading window pops up meanwhile → XMLHttpRequest request cancelled (with status of 0 and no response text) if file downloading window pops up meanwhile
Duplicate of this bug: 715446
Component: DOM: Mozilla Extensions → DOM
I am facing the same issue on 49.0.2
Is there any chance for a fix?
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.