browser_bug1011748.js (960B)
1 const gHttpTestRoot = "http://example.com/browser/dom/base/test/"; 2 3 add_task(async function () { 4 var statusTexts = []; 5 var xhr = new XMLHttpRequest(); 6 var observer = { 7 observe(aSubject, aTopic, aData) { 8 try { 9 var channel = aSubject.QueryInterface(Ci.nsIHttpChannel); 10 channel.getResponseHeader("Location"); 11 } catch (e) { 12 return; 13 } 14 statusTexts.push(xhr.statusText); 15 }, 16 }; 17 18 Services.obs.addObserver(observer, "http-on-examine-response"); 19 await new Promise(resolve => { 20 xhr.addEventListener("load", function () { 21 statusTexts.push(this.statusText); 22 is(statusTexts[0], "", "Empty statusText value for HTTP 302"); 23 is(statusTexts[1], "OK", "OK statusText value for the redirect."); 24 resolve(); 25 }); 26 xhr.open("GET", gHttpTestRoot + "file_bug1011748_redirect.sjs", true); 27 xhr.send(); 28 }); 29 30 Services.obs.removeObserver(observer, "http-on-examine-response"); 31 });