test_redirectURI.js
Go to the documentation of this file.
1 
32 function reqObserver(uri, check) {
33  this.uri = uri;
34  this.checker = check;
35 }
36 
37 reqObserver.prototype = {
38  uri: null,
39  checker: null,
40  onStartRequest: function (req, con) {
41  log("*** starting uri is: " + this.uri.spec);
42  log("*** destination uri is: " + this.checker.baseChannel.URI.spec);
43  req.cancel(Components.results.NS_ERROR_FAILURE);
44  },
45  onStopRequest: function (req, con, stat) {
46  testFinished();
47  }
48 } // reqObserver.prototype
49 
50 function runTest() {
51 
52  // Services needed to do the checking
53  var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
54  var uriChecker = Components.classes["@mozilla.org/network/urichecker;1"].getService(Components.interfaces.nsIURIChecker);
55 
56  // URI to check
57  var uriStr = "http://www.podtrac.com/pts/redirect.mp3?http://aolradio.podcast.aol.com/twit/TWiT0076H.mp3";
58  var uri = ioService.newURI(uriStr, null, null);
59  //var channel = ioService.newChannelFromURI(uri);
60 
61  // setup the checker
62  uriChecker.init(uri);
63  var obs = new reqObserver(uri, uriChecker);
64 
65  // fire the async request
66  uriChecker.asyncCheck(obs, null);
67 
68  // This needs to be called after the async call
69  testPending();
70 
71 } // runTest
72 
function log(s)
function testFinished()
var ioService
return null
Definition: FeedWriter.js:1143
function check(ch, cx)
var uri
Definition: FeedWriter.js:1135
function reqObserver(uri, check)
Unit test for retrieving the final URL for a redirected URL.
function runTest()
function testPending()