test_aboutblank.js (864B)
1 "use strict"; 2 3 function run_test() { 4 var base = NetUtil.newURI("http://www.example.com"); 5 var about1 = NetUtil.newURI("about:blank"); 6 var about2 = NetUtil.newURI("about:blank", null, base); 7 8 var chan1 = NetUtil.newChannel({ 9 uri: about1, 10 loadUsingSystemPrincipal: true, 11 }).QueryInterface(Ci.nsIPropertyBag2); 12 13 var chan2 = NetUtil.newChannel({ 14 uri: about2, 15 loadUsingSystemPrincipal: true, 16 }).QueryInterface(Ci.nsIPropertyBag2); 17 18 var haveProp = false; 19 var propVal = null; 20 try { 21 propVal = chan1.getPropertyAsInterface("baseURI", Ci.nsIURI); 22 haveProp = true; 23 } catch (e) { 24 if (e.result != Cr.NS_ERROR_NOT_AVAILABLE) { 25 throw e; 26 } 27 // Property shouldn't be there. 28 } 29 Assert.equal(propVal, null); 30 Assert.equal(haveProp, false); 31 Assert.equal(chan2.getPropertyAsInterface("baseURI", Ci.nsIURI), base); 32 }