|
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> |
|
8 |
|
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" /> |
|
13 |
|
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" /> |
|
20 |
|
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" /> |
|
24 |
|
25 <!-- type can have leading and trailing whitespace --> |
|
26 <link rel="alternate" type=" application/atom+xml " title="11" href="/11.atom" /> |
|
27 |
|
28 <!-- type is case-insensitive --> |
|
29 <link rel="alternate" type="aPPliCAtion/ATom+xML" title="12" href="/12.atom" /> |
|
30 |
|
31 <!-- "feed stylesheet" is a feed, though "alternate stylesheet" isn't --> |
|
32 <link rel="feed stylesheet" title="13" href="/13.atom" /> |
|
33 |
|
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" /> |
|
38 |
|
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" /> |
|
41 |
|
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" /> |
|
44 |
|
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" /> |
|
47 |
|
48 <!-- don't tolerate random types --> |
|
49 <link rel="alternate" type="text/plain" title="Bogus7 rss" href="/Bogus7" /> |
|
50 |
|
51 <!-- don't find Atom by title --> |
|
52 <link rel="foopy" type="application/atom+xml" title="Bogus8 Atom and RSS" href="/Bogus8" /> |
|
53 |
|
54 <!-- don't find application/rss+xml by title --> |
|
55 <link rel="goats" type="application/rss+xml" title="Bogus9 RSS and Atom" href="/Bogus9" /> |
|
56 |
|
57 <!-- don't find application/rdf+xml by title --> |
|
58 <link rel="alternate" type="application/rdf+xml" title="Bogus10 RSS and Atom" href="/Bogus10" /> |
|
59 |
|
60 <!-- don't find application/xml by title --> |
|
61 <link rel="alternate" type="application/xml" title="Bogus11 RSS and Atom" href="/Bogus11" /> |
|
62 |
|
63 <!-- don't find text/xml by title --> |
|
64 <link rel="alternate" type="text/xml" title="Bogus12 RSS and Atom" href="/Bogus12" /> |
|
65 |
|
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 |
|
73 var tests = new Array(); |
|
74 |
|
75 var currentWindow = |
|
76 SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) |
|
77 .getInterface(SpecialPowers.Ci.nsIWebNavigation) |
|
78 .QueryInterface(SpecialPowers.Ci.nsIDocShellTreeItem) |
|
79 .rootTreeItem |
|
80 .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) |
|
81 .getInterface(SpecialPowers.Ci.nsIDOMWindow); |
|
82 var browser = currentWindow.gBrowser.selectedBrowser; |
|
83 |
|
84 var discovered = browser.feeds; |
|
85 tests.push({ check: discovered.length > 0, |
|
86 message: "some feeds should be discovered" }); |
|
87 |
|
88 var feeds = []; |
|
89 |
|
90 for (var aFeed of discovered) { |
|
91 feeds[aFeed.href] = true; |
|
92 } |
|
93 |
|
94 for (var aLink of document.getElementsByTagName("link")) { |
|
95 // ignore real stylesheets, and anything without an href property |
|
96 if (aLink.type != "text/css" && aLink.href) { |
|
97 if (/bogus/i.test(aLink.title)) { |
|
98 tests.push({ check: !feeds[aLink.href], |
|
99 message: "don't discover " + aLink.href }); |
|
100 } else { |
|
101 tests.push({ check: feeds[aLink.href], |
|
102 message: "should discover " + aLink.href }); |
|
103 } |
|
104 } |
|
105 } |
|
106 window.arguments[0].tests = tests; |
|
107 window.close(); |
|
108 } |
|
109 </script> |
|
110 </body> |
|
111 </html> |
|
112 |