diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/components/feeds/test | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/components/feeds/test')
25 files changed, 826 insertions, 0 deletions
diff --git a/browser/components/feeds/test/.eslintrc.js b/browser/components/feeds/test/.eslintrc.js new file mode 100644 index 000000000..3c788d6d6 --- /dev/null +++ b/browser/components/feeds/test/.eslintrc.js @@ -0,0 +1,7 @@ +"use strict"; + +module.exports = { + "extends": [ + "../../../../testing/mochitest/mochitest.eslintrc.js" + ] +}; diff --git a/browser/components/feeds/test/bug368464-data.xml b/browser/components/feeds/test/bug368464-data.xml new file mode 100644 index 000000000..2745b061d --- /dev/null +++ b/browser/components/feeds/test/bug368464-data.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> + <rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns="http://my.netscape.com/rdf/simple/0.9/"> + <channel> + <title>Tinderbox - Firefox</title> + <description>Build bustages for Firefox</description> + <link>http://tinderbox.mozilla.org/showbuilds.cgi?tree=Firefox</link> + </channel> + <image> + <title>Bad</title> + <url>http://tinderbox.mozilla.org/channelflames.gif</url> + <link>http://tinderbox.mozilla.org/showbuilds.cgi?tree=Firefox</link> + </image> + <item><title>The tree is currently closed</title><link>http://tinderbox.mozilla.org/showbuilds.cgi?tree=Firefox</link></item> + +<item><title>MacOSX Darwin 8.8.4 qm-xserve01 dep unit test is in flames</title><link>http://tinderbox.mozilla.org/showbuilds.cgi?tree=Firefox</link></item> +</rdf:RDF> diff --git a/browser/components/feeds/test/bug408328-data.xml b/browser/components/feeds/test/bug408328-data.xml new file mode 100644 index 000000000..e9385e5ab --- /dev/null +++ b/browser/components/feeds/test/bug408328-data.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + + <title>Example Feed</title> + <link href="http://example.org/"/> + <updated>2003-12-13T18:30:02Z</updated> + + <author> + <name>John Doe</name> + </author> + <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id> + + <entry> + + <title>Good item</title> + <link href="http://example.org/first"/> + <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> + <updated>2003-12-13T18:30:02Z</updated> + + <summary>Some text.</summary> + </entry> + + <entry> + + <title>data: link</title> + <link href="data:text/plain,Hi"/> + <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6b</id> + <updated>2003-12-13T18:30:03Z</updated> + + <summary>Some text.</summary> + </entry> + + <entry> + + <title>javascript: link</title> + <link href="javascript:alert('Hi')"/> + <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6c</id> + <updated>2003-12-13T18:30:04Z</updated> + + <summary>Some text.</summary> + </entry> + + <entry> + + <title>file: link</title> + <link href="file:///var/"/> + <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6d</id> + <updated>2003-12-13T18:30:05Z</updated> + + <summary>Some text.</summary> + </entry> + + <entry> + + <title>chrome: link</title> + <link href="chrome://browser/content/browser.js"/> + <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6e</id> + <updated>2003-12-13T18:30:06Z</updated> + + <summary>Some text.</summary> + </entry> + +</feed> diff --git a/browser/components/feeds/test/bug436801-data.xml b/browser/components/feeds/test/bug436801-data.xml new file mode 100644 index 000000000..0e45c7ed8 --- /dev/null +++ b/browser/components/feeds/test/bug436801-data.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom" xml:base="http://www.example.com/"> + + <title type="xhtml" xml:base="/foo/bar/"> + <div xmlns="http://www.w3.org/1999/xhtml">Example of a <em>special</em> feed (<img height="20px" src="baz.png" alt="base test sprite"/>)</div> + </title> + + <subtitle type="html" xml:base="/foo/bar/"> + <![CDATA[ + With a <em>special</em> subtitle (<img height="20px" src="baz.png" alt="base test sprite"/>) + ]]> + </subtitle> + + <link href="http://example.org/"/> + + <updated>2010-09-02T18:30:02Z</updated> + + <author> + <name>John Doe</name> + </author> + + <id>urn:uuid:22906062-ecbd-46e2-b6a7-3039506a398f</id> + + <entry> + <title type="xhtml" xml:base="/foo/bar/"> + <div xmlns="http://www.w3.org/1999/xhtml">Some <abbr title="Extensible Hyper-text Mark-up Language">XHTML</abbr> examples (<img height="20px" src="baz.png" alt="base test sprite"/>)</div> + </title> + <id>urn:uuid:b48083a7-71a7-4c9c-8515-b7c0d22955e7</id> + <updated>2010-09-02T18:30:02Z</updated> + <summary>Some text.</summary> + </entry> + + <entry> + <title type="html" xml:base="/foo/bar/"> + <![CDATA[ + Some <abbr title="Hyper-text Mark-up Language">HTML</abbr> examples (<img height="20px" src="baz.png" alt="base test sprite"/>) + ]]> + </title> + <id>urn:uuid:1424967a-280a-414d-b0ab-8b11c4ac1bb7</id> + <updated>2010-09-02T18:30:02Z</updated> + <summary>Some text.</summary> + </entry> + +</feed> diff --git a/browser/components/feeds/test/bug494328-data.xml b/browser/components/feeds/test/bug494328-data.xml new file mode 100644 index 000000000..58342bafc --- /dev/null +++ b/browser/components/feeds/test/bug494328-data.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0">
+ <channel>
+ <title>Channel title</title>
+ <description>Channel description</description>
+ <link>Channel link</link>
+ <item>
+ <title>Episode 1</title>
+ <enclosure url="http://www.example.com/podcasts/Episode%201" length="0" type="audio/x-m4a" />
+ </item>
+ <item>
+ <title>Episode 2</title>
+ <enclosure url="http://www.example.com/podcasts/Episode%20%232" length="0" type="audio/x-m4a" />
+ </item>
+ <item>
+ <title>Episode 3</title>
+ <enclosure url="http://www.example.com/podcasts/Episode%20%233/" length="0" type="audio/x-m4a" />
+ </item>
+ <item>
+ <title>Episode 4</title>
+ <enclosure url="http://www.example.com/podcasts/Is%20This%20Episode%20%234%3F" length="0" type="audio/x-m4a" />
+ </item>
+ </channel>
+</rss>
diff --git a/browser/components/feeds/test/bug589543-data.xml b/browser/components/feeds/test/bug589543-data.xml new file mode 100644 index 000000000..0e700b6d8 --- /dev/null +++ b/browser/components/feeds/test/bug589543-data.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + + <title>Example Feed</title> + <link href="http://example.org/"/> + <updated>2010-08-22T18:30:02Z</updated> + + <author> + <name>John Doe</name> + </author> + <id>urn:uuid:e2df8375-99be-4848-b05e-b9d407555267</id> + + <entry> + + <title>Item</title> + <link href="http://example.org/first"/> + <id>urn:uuid:9e0f4bed-33d3-4a9d-97ab-ecaa31b3f14a</id> + <updated>2010-08-22T18:30:02Z</updated> + + <summary>Some text.</summary> + </entry> + +</feed> diff --git a/browser/components/feeds/test/chrome/.eslintrc.js b/browser/components/feeds/test/chrome/.eslintrc.js new file mode 100644 index 000000000..8c0f4f574 --- /dev/null +++ b/browser/components/feeds/test/chrome/.eslintrc.js @@ -0,0 +1,7 @@ +"use strict"; + +module.exports = { + "extends": [ + "../../../../../testing/mochitest/chrome.eslintrc.js" + ] +}; diff --git a/browser/components/feeds/test/chrome/chrome.ini b/browser/components/feeds/test/chrome/chrome.ini new file mode 100644 index 000000000..7bad142ab --- /dev/null +++ b/browser/components/feeds/test/chrome/chrome.ini @@ -0,0 +1,10 @@ +[DEFAULT] +support-files = sample_feed.atom + !/browser/components/feeds/test/bug408328-data.xml + !/browser/components/feeds/test/valid-feed.xml + !/browser/components/feeds/test/valid-unsniffable-feed.xml + +[test_423060.xul] +[test_bug368464.html] +[test_bug408328.html] +[test_maxSniffing.html] diff --git a/browser/components/feeds/test/chrome/sample_feed.atom b/browser/components/feeds/test/chrome/sample_feed.atom new file mode 100644 index 000000000..add75efb4 --- /dev/null +++ b/browser/components/feeds/test/chrome/sample_feed.atom @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + + <title>Example Feed</title> + <link href="http://example.org/"/> + <updated>2003-12-13T18:30:02Z</updated> + + <author> + <name>John Doe</name> + </author> + <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id> + + <entry> + + <title>Atom-Powered Robots Run Amok</title> + <link href="http://example.org/2003/12/13/atom03"/> + <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> + <updated>2003-12-13T18:30:02Z</updated> + + <summary>Some text.</summary> + </entry> + +</feed> diff --git a/browser/components/feeds/test/chrome/test_423060.xul b/browser/components/feeds/test/chrome/test_423060.xul new file mode 100644 index 000000000..465cf2dd2 --- /dev/null +++ b/browser/components/feeds/test/chrome/test_423060.xul @@ -0,0 +1,56 @@ +<?xml version="1.0"?> +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> +<?xml-stylesheet + href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> +<window title="Make sure feed preview works when a default reader is selected" + xmlns:html="http://www.w3.org/1999/xhtml" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + <script type="application/javascript" + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + + <body xmlns="http://www.w3.org/1999/xhtml" /> + + <script type="application/javascript"> + SimpleTest.waitForExplicitFinish(); + + const Cc = Components.classes; + const Ci = Components.interfaces; + + var wccrID = "@mozilla.org/embeddor.implemented/web-content-handler-registrar;1"; + /* abort the test if web feed handlers are not available */ + if (!Cc[wccrID]) + SimpleTest.finish() + + /* Turn off the first run UI */ + var prefBranch = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); + prefBranch.setBoolPref("browser.feeds.showFirstRunUI", false); + + /* register a handler for the feed type */ + const MAYBE_FEED = "application/vnd.mozilla.maybe.feed"; + var handlerPage = "http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/demohandler.html?feedurl=%s"; + var wccr = Cc[wccrID].getService(Ci.nsIWebContentConverterService); + wccr.registerContentHandler(MAYBE_FEED, handlerPage, "Demo handler", null); + var demoHandler = wccr.getWebContentHandlerByURI(MAYBE_FEED, handlerPage); + wccr.setAutoHandler(MAYBE_FEED, demoHandler); + + /* Don't show the preview page */ + prefBranch.setCharPref("browser.feeds.handler", "reader"); + + function finishUp() { + var theframe = document.getElementById('theframe'); + var previewURL = "http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/demohandler.html?feedurl=http%3A%2F%2Fmochi.test%3A8888%2Ftests%2Ftoolkit%2Fcomponents%2Fplaces%2Ftests%2Fchrome%2Fsample_feed.atom"; + is(theframe.contentDocument.URL, previewURL); + + /* remove our demoHandler */ + wccr.setAutoHandler(MAYBE_FEED, null); + wccr.removeContentHandler(MAYBE_FEED, handlerPage); + prefBranch.setCharPref("browser.feeds.handler", "ask"); + prefBranch.setBoolPref("browser.feeds.showFirstRunUI", true); + + SimpleTest.finish(); + } + </script> + <html:iframe src="http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/sample_feed.atom" height="400px" + id="theframe" onload="finishUp();"> + </html:iframe> +</window> diff --git a/browser/components/feeds/test/chrome/test_bug368464.html b/browser/components/feeds/test/chrome/test_bug368464.html new file mode 100644 index 000000000..dd7486f66 --- /dev/null +++ b/browser/components/feeds/test/chrome/test_bug368464.html @@ -0,0 +1,32 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=368464 +--> +<head> + <title>Test that RSS 0.90 isn't sniffed</title> + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=368464">Mozilla Bug 368464</a> +<p id="display"><iframe id="testFrame" src="http://mochi.test:8888/tests/browser/components/feeds/test/bug368464-data.xml"></iframe></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +/** Test for Bug 368464 **/ +SimpleTest.waitForExplicitFinish(); + +addLoadEvent(function() { + ok($("testFrame").contentDocument.documentElement.id != "feedHandler", + "RSS 0.90 shouldn't be sniffed as a feed"); +}); +addLoadEvent(SimpleTest.finish); + +</script> +</pre> +</body> +</html> diff --git a/browser/components/feeds/test/chrome/test_bug408328.html b/browser/components/feeds/test/chrome/test_bug408328.html new file mode 100644 index 000000000..e4901320a --- /dev/null +++ b/browser/components/feeds/test/chrome/test_bug408328.html @@ -0,0 +1,37 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=408328 +--> +<head> + <title>Test feed preview safe-linkification</title> + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408328">Mozilla Bug 408328</a> +<p id="display"><iframe id="testFrame" src="http://mochi.test:8888/tests/browser/components/feeds/test/bug408328-data.xml"></iframe></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +/** Test for Bug 408328 **/ +SimpleTest.waitForExplicitFinish(); + +addLoadEvent(function() { + var links = $("testFrame").contentDocument.getElementById("feedContent").getElementsByTagName("a"); + is(links.length, 5, "wrong number of linked items in feed preview"); + for (var i = 0; i < links.length; i++) { + if (links[i].href) + is(links[i].href, "http://example.org/first", "bad linkified item"); + } +}); +addLoadEvent(SimpleTest.finish); + +</script> +</pre> +</body> +</html> + diff --git a/browser/components/feeds/test/chrome/test_maxSniffing.html b/browser/components/feeds/test/chrome/test_maxSniffing.html new file mode 100644 index 000000000..7a2044687 --- /dev/null +++ b/browser/components/feeds/test/chrome/test_maxSniffing.html @@ -0,0 +1,37 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=739040 +--> +<head> + <title>Test that we only sniff 512 bytes</title> + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=739040">Mozilla Bug 739040</a> +<p id="display"> + <iframe id="validTestFrame" src="http://mochi.test:8888/tests/browser/components/feeds/test/valid-feed.xml"></iframe> + <iframe id="unsniffableTestFrame" src="http://mochi.test:8888/tests/browser/components/feeds/test/valid-unsniffable-feed.xml"></iframe> +</p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +/** Test for Bug 739040 **/ +SimpleTest.waitForExplicitFinish(); + +addLoadEvent(function() { + is($("validTestFrame").contentDocument.documentElement.id, "feedHandler", + "valid feed should be sniffed"); + isnot($("unsniffableTestFrame").contentDocument.documentElement.id, "feedHandler", + "unsniffable feed should not be sniffed"); +}); +addLoadEvent(SimpleTest.finish); + +</script> +</pre> +</body> +</html> diff --git a/browser/components/feeds/test/mochitest.ini b/browser/components/feeds/test/mochitest.ini new file mode 100644 index 000000000..fc1e6a1a9 --- /dev/null +++ b/browser/components/feeds/test/mochitest.ini @@ -0,0 +1,14 @@ +[DEFAULT] +support-files = + bug368464-data.xml + bug408328-data.xml + bug436801-data.xml + bug494328-data.xml + bug589543-data.xml + valid-feed.xml + valid-unsniffable-feed.xml + +[test_bug436801.html] +[test_bug494328.html] +[test_bug589543.html] +[test_registerHandler.html] diff --git a/browser/components/feeds/test/test_bug436801.html b/browser/components/feeds/test/test_bug436801.html new file mode 100644 index 000000000..29fb5acf0 --- /dev/null +++ b/browser/components/feeds/test/test_bug436801.html @@ -0,0 +1,118 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=436801 +--> +<head> + <title>Test feed preview subscribe UI</title> + <script type="text/javascript" src="/MochiKit/packed.js"></script> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=436801">Mozilla Bug 436801</a> +<p id="display"><iframe id="testFrame" src="bug436801-data.xml"></iframe></p> +<div id="content" style="display: none"> +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +SimpleTest.waitForExplicitFinish(); + +addLoadEvent(function () { + var doc = SpecialPowers.wrap($("testFrame")).contentDocument; + + checkNode(doc.getElementById("feedTitleText"), [ + "ELEMENT", "h1", { "xml:base": "http://www.example.com/foo/bar/" }, [ + ["TEXT", "Example of a "], + ["ELEMENT", "em", [ + ["TEXT", "special"], + ]], + ["TEXT", " feed ("], + ["ELEMENT", "img", { "src": "baz.png" }], + ["TEXT", ")"], + ] + ]); + + checkNode(doc.getElementById("feedSubtitleText"), [ + "ELEMENT", "h2", { "xml:base": "http://www.example.com/foo/bar/" }, [ + ["TEXT", "With a "], + ["ELEMENT", "em", [ + ["TEXT", "special"], + ]], + ["TEXT", " subtitle ("], + ["ELEMENT", "img", { "src": "baz.png" }], + ["TEXT", ")"], + ] + ]); + + checkNode(doc.querySelector(".entry").firstChild.firstChild.firstChild, [ + "ELEMENT", "span", { "xml:base": "http://www.example.com/foo/bar/" }, [ + ["TEXT", "Some "], + ["ELEMENT", "abbr", { title: "Extensible Hyper-text Mark-up Language" }, [ + ["TEXT", "XHTML"], + ]], + ["TEXT", " examples ("], + ["ELEMENT", "img", { "src": "baz.png" }], + ["TEXT", ")"], + ] + ]); + + checkNode(doc.querySelectorAll(".entry")[1].firstChild.firstChild.firstChild, [ + "ELEMENT", "span", { "xml:base": "http://www.example.com/foo/bar/" }, [ + ["TEXT", "Some "], + ["ELEMENT", "abbr", { title: "Hyper-text Mark-up Language" }, [ + ["TEXT", "HTML"], + ]], + ["TEXT", " examples ("], + ["ELEMENT", "img", { "src": "baz.png" }], + ["TEXT", ")"], + ] + ]); +}); + +addLoadEvent(SimpleTest.finish); + +function checkNode(node, schema) { + var typeName = schema.shift() + "_NODE"; + var type = Node[typeName]; + is(node.nodeType, type, "Node should be expected type " + typeName); + if (type == Node.TEXT_NODE) { + var text = schema.shift(); + is(node.data, text, "Text should match"); + return; + } + // type == Node.ELEMENT_NODE + var tag = schema.shift(); + is(node.localName, tag, "Element should have expected tag"); + while (schema.length) { + let val = schema.shift(); + if (Array.isArray(val)) + var childSchema = val; + else + var attrSchema = val; + } + if (attrSchema) { + var nsTable = { + xml: "http://www.w3.org/XML/1998/namespace", + }; + for (var name in attrSchema) { + var [ns, nsName] = name.split(":"); + let val = nsName ? node.getAttributeNS(nsTable[ns], nsName) : + node.getAttribute(name); + is(val, attrSchema[name], "Attribute " + name + " should match"); + } + } + if (childSchema) { + var numChildren = node.childNodes.length; + is(childSchema.length, numChildren, + "Element should have expected number of children"); + for (var i = 0; i < numChildren; i++) + checkNode(node.childNodes[i], childSchema[i]); + } +} + +</script> +</pre> +</body> +</html> diff --git a/browser/components/feeds/test/test_bug494328.html b/browser/components/feeds/test/test_bug494328.html new file mode 100644 index 000000000..054f62c1d --- /dev/null +++ b/browser/components/feeds/test/test_bug494328.html @@ -0,0 +1,36 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=494328 +--> +<head> + <title>Test for bug 494328</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=494328">Mozilla Bug 494328</a> +<p id="display"><iframe id="testFrame" src="bug494328-data.xml"></iframe></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +/** Test for Bug 494328 **/ +SimpleTest.waitForExplicitFinish(); + +addLoadEvent(function() { + var links = SpecialPowers.wrap($("testFrame")).contentDocument.getElementById("feedContent").querySelectorAll("div.enclosure > a"); + is(links[0].textContent, "Episode 1", "filename decoded incorrectly"); + is(links[1].textContent, "Episode #2", "filename decoded incorrectly"); + is(links[2].textContent, "http://www.example.com/podcasts/Episode #3/", "filename decoded incorrectly"); + is(links[3].textContent, "Is This Episode #4?", "filename decoded incorrectly"); +}); +addLoadEvent(SimpleTest.finish); + +</script> +</pre> +</body> +</html> + diff --git a/browser/components/feeds/test/test_bug589543.html b/browser/components/feeds/test/test_bug589543.html new file mode 100644 index 000000000..cee2a9661 --- /dev/null +++ b/browser/components/feeds/test/test_bug589543.html @@ -0,0 +1,32 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=589543 +--> +<head> + <title>Test feed preview subscribe UI</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=589543">Mozilla Bug 589543</a> +<p id="display"><iframe id="testFrame" src="bug589543-data.xml"></iframe></p> +<div id="content" style="display: none"> +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +/** Test for Bug 589543 **/ +SimpleTest.waitForExplicitFinish(); + +addLoadEvent(function() { + var doc = SpecialPowers.wrap($("testFrame")).contentDocument; + var popup = doc.getElementById("handlersMenuList"); + isnot(popup, null, "Feed preview should have a handlers popup"); +}); +addLoadEvent(SimpleTest.finish); + +</script> +</pre> +</body> +</html> diff --git a/browser/components/feeds/test/test_registerHandler.html b/browser/components/feeds/test/test_registerHandler.html new file mode 100644 index 000000000..34e61d034 --- /dev/null +++ b/browser/components/feeds/test/test_registerHandler.html @@ -0,0 +1,85 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=402788 +--> +<head> + <title>Test for Bug 402788</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=402788">Mozilla Bug 402788</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +/** Test for Bug 402788 **/ + + // return false if an exception has been catched, true otherwise + function testRegisterHandler(aIsProtocol, aTxt, aUri, aTitle) + { + try { + if (aIsProtocol) + navigator.registerProtocolHandler(aTxt, aUri, aTitle); + else + navigator.registerContentHandler(aTxt, aUri, aTitle); + } + catch (e) { + return false; + } + + return true; + } + + ok(navigator.registerProtocolHandler, "navigator.registerProtocolHandler should be defined"); + ok(navigator.registerContentHandler, "navigator.registerContentHandler should be defined"); + + // testing a generic case + is(testRegisterHandler(true, "foo", "http://mochi.test:8888/%s", "Foo handler"), true, "registering a foo protocol handler should work"); + is(testRegisterHandler(false, "application/rss+xml", "http://mochi.test:8888/%s", "Foo handler"), true, "registering a foo content handler should work"); + + // testing with wrong uris + is(testRegisterHandler(true, "foo", "http://mochi.test:8888/", "Foo handler"), false, "a protocol handler uri should contain %s"); + is(testRegisterHandler(false, "application/rss+xml", "http://mochi.test:8888/", "Foo handler"), false, "a content handler uri should contain %s"); + + // the spec explicitly allows relative urls to be passed + is(testRegisterHandler(true, "foo", "foo/%s", "Foo handler"), true, "a protocol handler uri should be valid"); + is(testRegisterHandler(false, "application/rss+xml", "foo/%s", "Foo handler"), true, "a content handler uri should be valid"); + + // we should only accept to register when the handler has the same host as the current page (bug 402287) + is(testRegisterHandler(true, "foo", "http://remotehost:8888/%s", "Foo handler"), false, "registering a foo protocol handler with a different host should not work"); + is(testRegisterHandler(false, "application/rss+xml", "http://remotehost:8888/%s", "Foo handler"), false, "registering a foo content handler with a different host should not work"); + + // restriction to http(s) for the uri of the handler (bug 401343) + // https should work (http already tested in the generic case) + is(testRegisterHandler(true, "foo", "https://mochi.test:8888/%s", "Foo handler"), true, "registering a foo protocol handler with https scheme should work"); + is(testRegisterHandler(false, "application/rss+xml", "https://mochi.test:8888/%s", "Foo handler"), true, "registering a foo content handler with https scheme should work"); + // ftp should not work + is(testRegisterHandler(true, "foo", "ftp://mochi.test:8888/%s", "Foo handler"), false, "registering a foo protocol handler with ftp scheme should not work"); + is(testRegisterHandler(false, "application/rss+xml", "ftp://mochi.test:8888/%s", "Foo handler"), false, "registering a foo content handler with ftp scheme should not work"); + // chrome should not work + is(testRegisterHandler(true, "foo", "chrome://mochi.test:8888/%s", "Foo handler"), false, "registering a foo protocol handler with chrome scheme should not work"); + is(testRegisterHandler(false, "application/rss+xml", "chrome://mochi.test:8888/%s", "Foo handler"), false, "registering a foo content handler with chrome scheme should not work"); + // foo should not work + is(testRegisterHandler(true, "foo", "foo://mochi.test:8888/%s", "Foo handler"), false, "registering a foo protocol handler with foo scheme should not work"); + is(testRegisterHandler(false, "application/rss+xml", "foo://mochi.test:8888/%s", "Foo handler"), false, "registering a foo content handler with foo scheme should not work"); + + // for security reasons, protocol handlers should never be registered for some schemes (chrome, vbscript, ...) (bug 402788) + is(testRegisterHandler(true, "chrome", "http://mochi.test:8888/%s", "chrome handler"), false, "registering a chrome protocol handler should not work"); + is(testRegisterHandler(true, "vbscript", "http://mochi.test:8888/%s", "vbscript handler"), false, "registering a vbscript protocol handler should not work"); + is(testRegisterHandler(true, "javascript", "http://mochi.test:8888/%s", "javascript handler"), false, "registering a javascript protocol handler should not work"); + is(testRegisterHandler(true, "moz-icon", "http://mochi.test:8888/%s", "moz-icon handler"), false, "registering a moz-icon protocol handler should not work"); + + // for security reasons, content handlers should never be registered for some types (html, ...) + is(testRegisterHandler(false, "application/rss+xml", "http://mochi.test:8888/%s", "Foo handler"), true, "registering rss content handlers should work"); + is(testRegisterHandler(false, "application/atom+xml", "http://mochi.test:8888/%s", "Foo handler"), true, "registering atom content handlers should work"); + todo_is(testRegisterHandler(false, "text/html", "http://mochi.test:8888/%s", "Foo handler"), false, "registering html content handlers should not work"); // bug 403798 + +</script> +</pre> +</body> +</html> diff --git a/browser/components/feeds/test/unit/.eslintrc.js b/browser/components/feeds/test/unit/.eslintrc.js new file mode 100644 index 000000000..d35787cd2 --- /dev/null +++ b/browser/components/feeds/test/unit/.eslintrc.js @@ -0,0 +1,7 @@ +"use strict"; + +module.exports = { + "extends": [ + "../../../../../testing/xpcshell/xpcshell.eslintrc.js" + ] +}; diff --git a/browser/components/feeds/test/unit/head_feeds.js b/browser/components/feeds/test/unit/head_feeds.js new file mode 100644 index 000000000..3b1135ef7 --- /dev/null +++ b/browser/components/feeds/test/unit/head_feeds.js @@ -0,0 +1,5 @@ +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cr = Components.results; + +var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); diff --git a/browser/components/feeds/test/unit/test_355473.js b/browser/components/feeds/test/unit/test_355473.js new file mode 100644 index 000000000..8a20d1389 --- /dev/null +++ b/browser/components/feeds/test/unit/test_355473.js @@ -0,0 +1,43 @@ +var Cu = Components.utils; +Cu.import("resource://gre/modules/NetUtil.jsm"); + +function run_test() { + var feedFeedURI = ios.newURI("feed://example.com/feed.xml", null, null); + var httpFeedURI = ios.newURI("feed:http://example.com/feed.xml", null, null); + var httpURI = ios.newURI("http://example.com/feed.xml", null, null); + + var httpsFeedURI = + ios.newURI("feed:https://example.com/feed.xml", null, null); + var httpsURI = ios.newURI("https://example.com/feed.xml", null, null); + + var feedChannel = NetUtil.newChannel({ + uri: feedFeedURI, + loadUsingSystemPrincipal: true + }); + + var httpChannel = NetUtil.newChannel({ + uri: httpFeedURI, + loadUsingSystemPrincipal: true + }); + + var httpsChannel = NetUtil.newChannel({ + uri: httpsFeedURI, + loadUsingSystemPrincipal: true + }); + + // not setting .originalURI to the original URI is naughty + do_check_true(feedFeedURI.equals(feedChannel.originalURI)); + do_check_true(httpFeedURI.equals(httpChannel.originalURI)); + do_check_true(httpsFeedURI.equals(httpsChannel.originalURI)); + + // actually using the horrible mess that's a feed: URI is suicidal + do_check_true(httpURI.equals(feedChannel.URI)); + do_check_true(httpURI.equals(httpChannel.URI)); + do_check_true(httpsURI.equals(httpsChannel.URI)); + + // check that we throw creating feed: URIs from file and ftp + Assert.throws(function() { ios.newURI("feed:ftp://example.com/feed.xml", null, null); }, + "Should throw an exception when trying to create a feed: URI with an ftp: inner"); + Assert.throws(function() { ios.newURI("feed:file:///var/feed.xml", null, null); }, + "Should throw an exception when trying to create a feed: URI with a file: inner"); +} diff --git a/browser/components/feeds/test/unit/test_758990.js b/browser/components/feeds/test/unit/test_758990.js new file mode 100644 index 000000000..e6f88baf2 --- /dev/null +++ b/browser/components/feeds/test/unit/test_758990.js @@ -0,0 +1,42 @@ +function run_test() { + var success = false; + try { + ios.newURI("feed:javascript:alert('hi');", null, null); + } + catch (e) { + success = e.result == Cr.NS_ERROR_MALFORMED_URI; + } + if (!success) + do_throw("We didn't throw NS_ERROR_MALFORMED_URI creating a feed:javascript: URI"); + + success = false; + try { + ios.newURI("feed:data:text/html,hi", null, null); + } + catch (e) { + success = e.result == Cr.NS_ERROR_MALFORMED_URI; + } + if (!success) + do_throw("We didn't throw NS_ERROR_MALFORMED_URI creating a feed:data: URI"); + + success = false; + try { + ios.newURI("pcast:javascript:alert('hi');", null, null); + } + catch (e) { + success = e.result == Cr.NS_ERROR_MALFORMED_URI; + } + if (!success) + do_throw("We didn't throw NS_ERROR_MALFORMED_URI creating a pcast:javascript: URI"); + + success = false; + try { + ios.newURI("pcast:data:text/html,hi", null, null); + } + catch (e) { + success = e.result == Cr.NS_ERROR_MALFORMED_URI; + } + if (!success) + do_throw("We didn't throw NS_ERROR_MALFORMED_URI creating a pcast:data: URI"); + +} diff --git a/browser/components/feeds/test/unit/xpcshell.ini b/browser/components/feeds/test/unit/xpcshell.ini new file mode 100644 index 000000000..9faf57396 --- /dev/null +++ b/browser/components/feeds/test/unit/xpcshell.ini @@ -0,0 +1,8 @@ +[DEFAULT] +head = head_feeds.js +tail = +firefox-appdir = browser +skip-if = toolkit == 'android' + +[test_355473.js] +[test_758990.js] diff --git a/browser/components/feeds/test/valid-feed.xml b/browser/components/feeds/test/valid-feed.xml new file mode 100644 index 000000000..0e700b6d8 --- /dev/null +++ b/browser/components/feeds/test/valid-feed.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + + <title>Example Feed</title> + <link href="http://example.org/"/> + <updated>2010-08-22T18:30:02Z</updated> + + <author> + <name>John Doe</name> + </author> + <id>urn:uuid:e2df8375-99be-4848-b05e-b9d407555267</id> + + <entry> + + <title>Item</title> + <link href="http://example.org/first"/> + <id>urn:uuid:9e0f4bed-33d3-4a9d-97ab-ecaa31b3f14a</id> + <updated>2010-08-22T18:30:02Z</updated> + + <summary>Some text.</summary> + </entry> + +</feed> diff --git a/browser/components/feeds/test/valid-unsniffable-feed.xml b/browser/components/feeds/test/valid-unsniffable-feed.xml new file mode 100644 index 000000000..e75315739 --- /dev/null +++ b/browser/components/feeds/test/valid-unsniffable-feed.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 512 bytes! +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + --> +<feed xmlns="http://www.w3.org/2005/Atom"> + + <title>Example Feed</title> + <link href="http://example.org/"/> + <updated>2010-08-22T18:30:02Z</updated> + + <author> + <name>John Doe</name> + </author> + <id>urn:uuid:e2df8375-99be-4848-b05e-b9d407555267</id> + + <entry> + + <title>Item</title> + <link href="http://example.org/first"/> + <id>urn:uuid:9e0f4bed-33d3-4a9d-97ab-ecaa31b3f14a</id> + <updated>2010-08-22T18:30:02Z</updated> + + <summary>Some text.</summary> + </entry> + +</feed> |