bug 841350 - register pageshow handler earlier in browser.js r=ttaubert
[gecko.git] / browser / base / content / test / feed_discovery.html
blobf7a30091c854e2eb0a0c8ff83b2be84be4b13ab0
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=377611
5 -->
6 <head>
7 <title>Test for feed discovery</title>
9 <!-- Straight up standard -->
10 <link rel="alternate" type="application/atom+xml" title="1" href="/1.atom" />
11 <link rel="alternate" type="application/rss+xml" title="2" href="/2.rss" />
12 <link rel="feed" title="3" href="/3.xml" />
14 <!-- rel is a space-separated list -->
15 <link rel=" alternate " type="application/atom+xml" title="4" href="/4.atom" />
16 <link rel="foo alternate" type="application/atom+xml" title="5" href="/5.atom" />
17 <link rel="alternate foo" type="application/atom+xml" title="6" href="/6.atom" />
18 <link rel="foo alternate foo" type="application/atom+xml" title="7" href="/7.atom" />
19 <link rel="meat feed cake" title="8" href="/8.atom" />
21 <!-- rel is case-insensitive -->
22 <link rel="ALTERNate" type="application/atom+xml" title="9" href="/9.atom" />
23 <link rel="fEEd" title="10" href="/10.atom" />
25 <!-- type can have leading and trailing whitespace -->
26 <link rel="alternate" type=" application/atom+xml " title="11" href="/11.atom" />
28 <!-- type is case-insensitive -->
29 <link rel="alternate" type="aPPliCAtion/ATom+xML" title="12" href="/12.atom" />
31 <!-- "feed stylesheet" is a feed, though "alternate stylesheet" isn't -->
32 <link rel="feed stylesheet" title="13" href="/13.atom" />
34 <!-- hyphens or letters around rel not allowed -->
35 <link rel="disabled-alternate" type="application/atom+xml" title="Bogus1" href="/Bogus1" />
36 <link rel="alternates" type="application/atom+xml" title="Bogus2" href="/Bogus2" />
37 <link rel=" alternate-like" type="application/atom+xml" title="Bogus3" href="/Bogus3" />
39 <!-- don't tolerate text/xml if title includes 'rss' not as a word -->
40 <link rel="alternate" type="text/xml" title="Bogus4 scissorsshaped" href="/Bogus4" />
42 <!-- don't tolerate application/xml if title includes 'rss' not as a word -->
43 <link rel="alternate" type="application/xml" title="Bogus5 scissorsshaped" href="/Bogus5" />
45 <!-- don't tolerate application/rdf+xml if title includes 'rss' not as a word -->
46 <link rel="alternate" type="application/rdf+xml" title="Bogus6 scissorsshaped" href="/Bogus6" />
48 <!-- don't tolerate random types -->
49 <link rel="alternate" type="text/plain" title="Bogus7 rss" href="/Bogus7" />
51 <!-- don't find Atom by title -->
52 <link rel="foopy" type="application/atom+xml" title="Bogus8 Atom and RSS" href="/Bogus8" />
54 <!-- don't find application/rss+xml by title -->
55 <link rel="goats" type="application/rss+xml" title="Bogus9 RSS and Atom" href="/Bogus9" />
57 <!-- don't find application/rdf+xml by title -->
58 <link rel="alternate" type="application/rdf+xml" title="Bogus10 RSS and Atom" href="/Bogus10" />
60 <!-- don't find application/xml by title -->
61 <link rel="alternate" type="application/xml" title="Bogus11 RSS and Atom" href="/Bogus11" />
63 <!-- don't find text/xml by title -->
64 <link rel="alternate" type="text/xml" title="Bogus12 RSS and Atom" href="/Bogus12" />
66 <!-- alternate and stylesheet isn't a feed -->
67 <link rel="alternate stylesheet" type="application/rss+xml" title="Bogus13 RSS" href="/Bogus13" />
68 </head>
69 <body>
70 <script type="text/javascript">
71 window.onload = function() {
72 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
74 var tests = new Array();
76 var currentWindow =
77 window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
78 .getInterface(Components.interfaces.nsIWebNavigation)
79 .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
80 .rootTreeItem
81 .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
82 .getInterface(Components.interfaces.nsIDOMWindow);
83 var browser = currentWindow.gBrowser.selectedBrowser;
85 var discovered = browser.feeds;
86 tests.push({ check: discovered.length > 0,
87 message: "some feeds should be discovered" });
89 var feeds = [];
91 for (var aFeed of discovered) {
92 feeds[aFeed.href] = true;
95 for (var aLink of document.getElementsByTagName("link")) {
96 // ignore real stylesheets, and anything without an href property
97 if (aLink.type != "text/css" && aLink.href) {
98 if (/bogus/i.test(aLink.title)) {
99 tests.push({ check: !feeds[aLink.href],
100 message: "don't discover " + aLink.href });
101 } else {
102 tests.push({ check: feeds[aLink.href],
103 message: "should discover " + aLink.href });
107 window.arguments[0].tests = tests;
108 window.close();
110 </script>
111 </body>
112 </html>