worker-make-xhr.sub.js (600B)
1 var xhr = new XMLHttpRequest; 2 xhr.onerror = function () { 3 postMessage("xhr blocked"); 4 postMessage("TEST COMPLETE"); 5 }; 6 xhr.onload = function () { 7 //cons/**/ole.log(xhr.responseText); 8 if (xhr.responseText == "FAIL") { 9 postMessage("xhr allowed"); 10 } else { 11 postMessage("xhr blocked"); 12 } 13 postMessage("TEST COMPLETE"); 14 }; 15 try { 16 xhr.open("GET", "/common/redirect.py?location=http://{{host}}:{{ports[http][0]}}/content-security-policy/support/fail.asis", true); 17 xhr.send(); 18 } catch (e) { 19 postMessage("xhr blocked"); 20 postMessage("TEST COMPLETE"); 21 }