1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/feed_discovery.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,112 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=377611 1.8 +--> 1.9 + <head> 1.10 + <title>Test for feed discovery</title> 1.11 + 1.12 + <!-- Straight up standard --> 1.13 + <link rel="alternate" type="application/atom+xml" title="1" href="/1.atom" /> 1.14 + <link rel="alternate" type="application/rss+xml" title="2" href="/2.rss" /> 1.15 + <link rel="feed" title="3" href="/3.xml" /> 1.16 + 1.17 + <!-- rel is a space-separated list --> 1.18 + <link rel=" alternate " type="application/atom+xml" title="4" href="/4.atom" /> 1.19 + <link rel="foo alternate" type="application/atom+xml" title="5" href="/5.atom" /> 1.20 + <link rel="alternate foo" type="application/atom+xml" title="6" href="/6.atom" /> 1.21 + <link rel="foo alternate foo" type="application/atom+xml" title="7" href="/7.atom" /> 1.22 + <link rel="meat feed cake" title="8" href="/8.atom" /> 1.23 + 1.24 + <!-- rel is case-insensitive --> 1.25 + <link rel="ALTERNate" type="application/atom+xml" title="9" href="/9.atom" /> 1.26 + <link rel="fEEd" title="10" href="/10.atom" /> 1.27 + 1.28 + <!-- type can have leading and trailing whitespace --> 1.29 + <link rel="alternate" type=" application/atom+xml " title="11" href="/11.atom" /> 1.30 + 1.31 + <!-- type is case-insensitive --> 1.32 + <link rel="alternate" type="aPPliCAtion/ATom+xML" title="12" href="/12.atom" /> 1.33 + 1.34 + <!-- "feed stylesheet" is a feed, though "alternate stylesheet" isn't --> 1.35 + <link rel="feed stylesheet" title="13" href="/13.atom" /> 1.36 + 1.37 + <!-- hyphens or letters around rel not allowed --> 1.38 + <link rel="disabled-alternate" type="application/atom+xml" title="Bogus1" href="/Bogus1" /> 1.39 + <link rel="alternates" type="application/atom+xml" title="Bogus2" href="/Bogus2" /> 1.40 + <link rel=" alternate-like" type="application/atom+xml" title="Bogus3" href="/Bogus3" /> 1.41 + 1.42 + <!-- don't tolerate text/xml if title includes 'rss' not as a word --> 1.43 + <link rel="alternate" type="text/xml" title="Bogus4 scissorsshaped" href="/Bogus4" /> 1.44 + 1.45 + <!-- don't tolerate application/xml if title includes 'rss' not as a word --> 1.46 + <link rel="alternate" type="application/xml" title="Bogus5 scissorsshaped" href="/Bogus5" /> 1.47 + 1.48 + <!-- don't tolerate application/rdf+xml if title includes 'rss' not as a word --> 1.49 + <link rel="alternate" type="application/rdf+xml" title="Bogus6 scissorsshaped" href="/Bogus6" /> 1.50 + 1.51 + <!-- don't tolerate random types --> 1.52 + <link rel="alternate" type="text/plain" title="Bogus7 rss" href="/Bogus7" /> 1.53 + 1.54 + <!-- don't find Atom by title --> 1.55 + <link rel="foopy" type="application/atom+xml" title="Bogus8 Atom and RSS" href="/Bogus8" /> 1.56 + 1.57 + <!-- don't find application/rss+xml by title --> 1.58 + <link rel="goats" type="application/rss+xml" title="Bogus9 RSS and Atom" href="/Bogus9" /> 1.59 + 1.60 + <!-- don't find application/rdf+xml by title --> 1.61 + <link rel="alternate" type="application/rdf+xml" title="Bogus10 RSS and Atom" href="/Bogus10" /> 1.62 + 1.63 + <!-- don't find application/xml by title --> 1.64 + <link rel="alternate" type="application/xml" title="Bogus11 RSS and Atom" href="/Bogus11" /> 1.65 + 1.66 + <!-- don't find text/xml by title --> 1.67 + <link rel="alternate" type="text/xml" title="Bogus12 RSS and Atom" href="/Bogus12" /> 1.68 + 1.69 + <!-- alternate and stylesheet isn't a feed --> 1.70 + <link rel="alternate stylesheet" type="application/rss+xml" title="Bogus13 RSS" href="/Bogus13" /> 1.71 + </head> 1.72 + <body> 1.73 + <script type="text/javascript"> 1.74 + window.onload = function() { 1.75 + 1.76 + var tests = new Array(); 1.77 + 1.78 + var currentWindow = 1.79 + SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) 1.80 + .getInterface(SpecialPowers.Ci.nsIWebNavigation) 1.81 + .QueryInterface(SpecialPowers.Ci.nsIDocShellTreeItem) 1.82 + .rootTreeItem 1.83 + .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) 1.84 + .getInterface(SpecialPowers.Ci.nsIDOMWindow); 1.85 + var browser = currentWindow.gBrowser.selectedBrowser; 1.86 + 1.87 + var discovered = browser.feeds; 1.88 + tests.push({ check: discovered.length > 0, 1.89 + message: "some feeds should be discovered" }); 1.90 + 1.91 + var feeds = []; 1.92 + 1.93 + for (var aFeed of discovered) { 1.94 + feeds[aFeed.href] = true; 1.95 + } 1.96 + 1.97 + for (var aLink of document.getElementsByTagName("link")) { 1.98 + // ignore real stylesheets, and anything without an href property 1.99 + if (aLink.type != "text/css" && aLink.href) { 1.100 + if (/bogus/i.test(aLink.title)) { 1.101 + tests.push({ check: !feeds[aLink.href], 1.102 + message: "don't discover " + aLink.href }); 1.103 + } else { 1.104 + tests.push({ check: feeds[aLink.href], 1.105 + message: "should discover " + aLink.href }); 1.106 + } 1.107 + } 1.108 + } 1.109 + window.arguments[0].tests = tests; 1.110 + window.close(); 1.111 + } 1.112 + </script> 1.113 + </body> 1.114 +</html> 1.115 +