browser/components/feeds/test/chrome/test_423060.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/feeds/test/chrome/test_423060.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,56 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet
     1.7 +  href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     1.8 +<window title="Make sure feed preview works when a default reader is selected"
     1.9 +  xmlns:html="http://www.w3.org/1999/xhtml"
    1.10 +  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.11 +  <script type="application/javascript"
    1.12 +   src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +
    1.14 +  <body xmlns="http://www.w3.org/1999/xhtml" />
    1.15 +
    1.16 +  <script type="application/javascript">
    1.17 +    SimpleTest.waitForExplicitFinish();
    1.18 +
    1.19 +    const Cc = Components.classes;
    1.20 +    const Ci = Components.interfaces;
    1.21 +
    1.22 +    var wccrID = "@mozilla.org/embeddor.implemented/web-content-handler-registrar;1";
    1.23 +    /* abort the test if web feed handlers are not available */
    1.24 +    if (!Cc[wccrID])
    1.25 +      SimpleTest.finish()
    1.26 +
    1.27 +    /* Turn off the first run UI */
    1.28 +    var prefBranch = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
    1.29 +    prefBranch.setBoolPref("browser.feeds.showFirstRunUI", false);
    1.30 +
    1.31 +    /* register a handler for the feed type */
    1.32 +    const MAYBE_FEED = "application/vnd.mozilla.maybe.feed";
    1.33 +    var handlerPage = "http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/demohandler.html?feedurl=%s";
    1.34 +    var wccr = Cc[wccrID].getService(Ci.nsIWebContentConverterService);
    1.35 +    wccr.registerContentHandler(MAYBE_FEED, handlerPage, "Demo handler", null);
    1.36 +    var demoHandler = wccr.getWebContentHandlerByURI(MAYBE_FEED, handlerPage);
    1.37 +    wccr.setAutoHandler(MAYBE_FEED, demoHandler);
    1.38 +
    1.39 +    /* Don't show the preview page */
    1.40 +    prefBranch.setCharPref("browser.feeds.handler", "reader");
    1.41 +
    1.42 +    function finishUp() {
    1.43 +      var theframe = document.getElementById('theframe');
    1.44 +      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";
    1.45 +      is(theframe.contentDocument.URL, previewURL);
    1.46 +
    1.47 +      /* remove our demoHandler */
    1.48 +      wccr.setAutoHandler(MAYBE_FEED, null);
    1.49 +      wccr.removeContentHandler(MAYBE_FEED, handlerPage);
    1.50 +      prefBranch.setCharPref("browser.feeds.handler", "ask");
    1.51 +      prefBranch.setBoolPref("browser.feeds.showFirstRunUI", true);
    1.52 +
    1.53 +      SimpleTest.finish();
    1.54 +    }
    1.55 +  </script>
    1.56 +  <html:iframe src="http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/sample_feed.atom" height="400px" 
    1.57 +    id="theframe" onload="finishUp();">
    1.58 +  </html:iframe>
    1.59 +</window>

mercurial