2 var exampleUri =
makeURI(
"http://example.com/");
3 var
secman =
Cc[
"@mozilla.org/scriptsecuritymanager;1"].getService(
Ci.nsIScriptSecurityManager);
4 var principal = secman.getCodebasePrincipal(exampleUri);
6 function testIsFeed(aTitle, aHref, aType, aKnown) {
7 var link = { title: aTitle,
href: aHref, type: aType };
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";
23 ok(testIsFeed(noRss, href, atomType,
false) == atomType,
25 ok(testIsFeed(noRss, href, funkyAtomType,
false) == atomType,
26 "clean up and detect Atom feed");
27 ok(testIsFeed(noRss, href, rssType,
false) == rssType,
29 ok(testIsFeed(noRss, href, funkyRssType,
false) == rssType,
30 "clean up and detect RSS feed");
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");
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");
function makeURI(aURLSpec, aCharset)
function isValidFeed(aLink, aPrincipal, aIsFeed)