|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet |
|
4 href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
|
5 <window title="Make sure feed preview works when a default reader is selected" |
|
6 xmlns:html="http://www.w3.org/1999/xhtml" |
|
7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
8 <script type="application/javascript" |
|
9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
10 |
|
11 <body xmlns="http://www.w3.org/1999/xhtml" /> |
|
12 |
|
13 <script type="application/javascript"> |
|
14 SimpleTest.waitForExplicitFinish(); |
|
15 |
|
16 const Cc = Components.classes; |
|
17 const Ci = Components.interfaces; |
|
18 |
|
19 var wccrID = "@mozilla.org/embeddor.implemented/web-content-handler-registrar;1"; |
|
20 /* abort the test if web feed handlers are not available */ |
|
21 if (!Cc[wccrID]) |
|
22 SimpleTest.finish() |
|
23 |
|
24 /* Turn off the first run UI */ |
|
25 var prefBranch = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); |
|
26 prefBranch.setBoolPref("browser.feeds.showFirstRunUI", false); |
|
27 |
|
28 /* register a handler for the feed type */ |
|
29 const MAYBE_FEED = "application/vnd.mozilla.maybe.feed"; |
|
30 var handlerPage = "http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/demohandler.html?feedurl=%s"; |
|
31 var wccr = Cc[wccrID].getService(Ci.nsIWebContentConverterService); |
|
32 wccr.registerContentHandler(MAYBE_FEED, handlerPage, "Demo handler", null); |
|
33 var demoHandler = wccr.getWebContentHandlerByURI(MAYBE_FEED, handlerPage); |
|
34 wccr.setAutoHandler(MAYBE_FEED, demoHandler); |
|
35 |
|
36 /* Don't show the preview page */ |
|
37 prefBranch.setCharPref("browser.feeds.handler", "reader"); |
|
38 |
|
39 function finishUp() { |
|
40 var theframe = document.getElementById('theframe'); |
|
41 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"; |
|
42 is(theframe.contentDocument.URL, previewURL); |
|
43 |
|
44 /* remove our demoHandler */ |
|
45 wccr.setAutoHandler(MAYBE_FEED, null); |
|
46 wccr.removeContentHandler(MAYBE_FEED, handlerPage); |
|
47 prefBranch.setCharPref("browser.feeds.handler", "ask"); |
|
48 prefBranch.setBoolPref("browser.feeds.showFirstRunUI", true); |
|
49 |
|
50 SimpleTest.finish(); |
|
51 } |
|
52 </script> |
|
53 <html:iframe src="http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/sample_feed.atom" height="400px" |
|
54 id="theframe" onload="finishUp();"> |
|
55 </html:iframe> |
|
56 </window> |