browser_bug413915.js
Go to the documentation of this file.
1 function test() {
2  var exampleUri = makeURI("http://example.com/");
3  var secman = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
4  var principal = secman.getCodebasePrincipal(exampleUri);
5 
6  function testIsFeed(aTitle, aHref, aType, aKnown) {
7  var link = { title: aTitle, href: aHref, type: aType };
8  return isValidFeed(link, principal, aKnown);
9  }
10 
11  var href = "http://example.com/feed/";
12  var atomType = "application/atom+xml";
13  var funkyAtomType = " aPPLICAtion/Atom+XML ";
14  var rssType = "application/rss+xml";
15  var funkyRssType = " Application/RSS+XML ";
16  var rdfType = "application/rdf+xml";
17  var texmlType = "text/xml";
18  var appxmlType = "application/xml";
19  var noRss = "Foo";
20  var rss = "RSS";
21 
22  // things that should be valid
23  ok(testIsFeed(noRss, href, atomType, false) == atomType,
24  "detect Atom feed");
25  ok(testIsFeed(noRss, href, funkyAtomType, false) == atomType,
26  "clean up and detect Atom feed");
27  ok(testIsFeed(noRss, href, rssType, false) == rssType,
28  "detect RSS feed");
29  ok(testIsFeed(noRss, href, funkyRssType, false) == rssType,
30  "clean up and detect RSS feed");
31 
32  // things that should not be feeds
33  ok(testIsFeed(noRss, href, rdfType, false) == null,
34  "should not detect RDF non-feed");
35  ok(testIsFeed(rss, href, rdfType, false) == null,
36  "should not detect RDF feed from type and title");
37  ok(testIsFeed(noRss, href, texmlType, false) == null,
38  "should not detect text/xml non-feed");
39  ok(testIsFeed(rss, href, texmlType, false) == null,
40  "should not detect text/xml feed from type and title");
41  ok(testIsFeed(noRss, href, appxmlType, false) == null,
42  "should not detect application/xml non-feed");
43  ok(testIsFeed(rss, href, appxmlType, false) == null,
44  "should not detect application/xml feed from type and title");
45 
46  // security check only, returns cleaned up type or "application/rss+xml"
47  ok(testIsFeed(noRss, href, atomType, true) == atomType,
48  "feed security check should return Atom type");
49  ok(testIsFeed(noRss, href, funkyAtomType, true) == atomType,
50  "feed security check should return cleaned up Atom type");
51  ok(testIsFeed(noRss, href, rssType, true) == rssType,
52  "feed security check should return RSS type");
53  ok(testIsFeed(noRss, href, funkyRssType, true) == rssType,
54  "feed security check should return cleaned up RSS type");
55  ok(testIsFeed(noRss, href, "", true) == rssType,
56  "feed security check without type should return RSS type");
57  ok(testIsFeed(noRss, href, "garbage", true) == "garbage",
58  "feed security check with garbage type should return garbage");
59 }
const Cc
function makeURI(aURLSpec, aCharset)
Definition: FeedWriter.js:71
Element Properties href
function test()
function isValidFeed(aLink, aPrincipal, aIsFeed)
return null
Definition: FeedWriter.js:1143
const Ci
var secman
Definition: FeedWriter.js:1161