test_355473.js
Go to the documentation of this file.
1 const NS_ERROR_MALFORMED_URI = 0x804B000A;
2 
3 function run_test() {
4  var feedFeedURI = ios.newURI("feed://example.com/feed.xml", null, null);
5  var httpFeedURI = ios.newURI("feed:http://example.com/feed.xml", null, null);
6  var httpURI = ios.newURI("http://example.com/feed.xml", null, null);
7 
8  var httpsFeedURI =
9  ios.newURI("feed:https://example.com/feed.xml", null, null);
10  var httpsURI = ios.newURI("https://example.com/feed.xml", null, null);
11 
12  var feedChannel = ios.newChannelFromURI(feedFeedURI, null);
13  var httpChannel = ios.newChannelFromURI(httpFeedURI, null);
14  var httpsChannel = ios.newChannelFromURI(httpsFeedURI, null);
15 
16  // not setting .originalURI to the original URI is naughty
17  do_check_true(feedFeedURI.equals(feedChannel.originalURI));
18  do_check_true(httpFeedURI.equals(httpChannel.originalURI));
19  do_check_true(httpsFeedURI.equals(httpsChannel.originalURI));
20 
21  // actually using the horrible mess that's a feed: URI is suicidal
22  do_check_true(httpURI.equals(feedChannel.URI));
23  do_check_true(httpURI.equals(httpChannel.URI));
24  do_check_true(httpsURI.equals(httpsChannel.URI));
25 
26  // trying to create a feed URI with something non-http(s) as the inner URL
27  // should fail, until someone fixes bug 408599
28  try {
29  var dataFeedURI = ios.newURI("feed:data:text/xml,<rss/>", null, null);
30  do_throw("Not reached");
31  } catch (e if (e instanceof Ci.nsIException &&
32  e.result == NS_ERROR_MALFORMED_URI)) {
33  // do nothing
34  }
35  try {
36  var ftpFeedURI = ios.newURI("feed:ftp://example.com/feed.xml", null, null);
37  do_throw("Not reached");
38  } catch (e if (e instanceof Ci.nsIException &&
39  e.result == NS_ERROR_MALFORMED_URI)) {
40  // do nothing
41  }
42  try {
43  var fileFeedURI = ios.newURI("feed:file:///var/feed.xml", null, null);
44  do_throw("Not reached");
45  } catch (e if (e instanceof Ci.nsIException &&
46  e.result == NS_ERROR_MALFORMED_URI)) {
47  // do nothing
48  }
49 }
const NS_ERROR_MALFORMED_URI
Definition: test_355473.js:1
return null
Definition: FeedWriter.js:1143
function run_test()
Definition: test_355473.js:3
const Ci
var ios
Definition: head_feeds.js:5