file_moving_xhr.html (1003B)
1 <html> 2 <head> 3 <script> 4 function createXHR() { 5 var xhr = new XMLHttpRequest(); 6 xhr.expando = "foo"; 7 return xhr; 8 } 9 10 function tryToUseXHR(xhr, ok) { 11 function expectException(op, reason) { 12 try { 13 var result = op(); 14 ok(false, "should have thrown an exception, got: " + result); 15 } catch (e) { 16 ok(/Permission denied/.test(e.toString()), reason); 17 } 18 } 19 20 expectException(function() { xhr.open(); }, "should not have access to any functions"); 21 expectException(function() { xhr.foo = "foo"; }, "should not be able to add expandos"); 22 expectException(function() { xhr.withCredentials = true; }, "should not be able to set attributes"); 23 } 24 </script> 25 </head> 26 <body> 27 </body> 28 </html>