Bug 1477670 - remove tests for registerContentHandler, r?jkt draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 24 Jul 2018 18:04:10 +0100 (2018-07-24)
changeset 823485 504044b6b75dd791d1735f7b63c40a5ac84c5efb
parent 823465 87bcafe428a4ad6017e59b915581ae00aa863407
child 823486 3bb4546ee88c4362f62ecb406c74dd5fab2053ef
push id117695
push userbmo:gijskruitbosch+bugs@gmail.com
push dateFri, 27 Jul 2018 13:16:45 +0000 (2018-07-27)
reviewersjkt
bugs1477670
milestone63.0a1
Bug 1477670 - remove tests for registerContentHandler, r?jkt MozReview-Commit-ID: DIshLjsXnev
browser/components/feeds/test/chrome/chrome.ini
browser/components/feeds/test/chrome/test_423060.xul
browser/components/feeds/test/test_registerHandler.html
--- a/browser/components/feeds/test/chrome/chrome.ini
+++ b/browser/components/feeds/test/chrome/chrome.ini
@@ -2,12 +2,11 @@
 prefs =
   browser.feeds.unsafelyFrameFeeds=true
 
 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]
deleted file mode 100644
--- a/browser/components/feeds/test/chrome/test_423060.xul
+++ /dev/null
@@ -1,53 +0,0 @@
-<?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();
-
-    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>
--- a/browser/components/feeds/test/test_registerHandler.html
+++ b/browser/components/feeds/test/test_registerHandler.html
@@ -18,82 +18,65 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 402788 **/
   SimpleTest.waitForExplicitFinish();
 
   // 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);
+      navigator.registerProtocolHandler(aTxt, aUri, aTitle);
     } catch (e) {
       return false;
     }
 
     return true;
   }
 
   async function tests() {
     await SpecialPowers.pushPrefEnv({
       set: [
-        ["dom.registerContentHandler.enabled", true],
         ["dom.registerProtocolHandler.insecure.enabled", true],
       ]
     });
-    ok(navigator.registerContentHandler, "navigator.registerContentHandler should be defined");
 
     // testing a generic case
     is(testRegisterHandler(true, "web+foo", "http://mochi.test:8888/%s", "Foo handler"), true, "registering a web+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, "web+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, "web+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, "fweb+oo", "http://remotehost:8888/%s", "Foo handler"), false, "registering a web+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, "web+foo", "https://mochi.test:8888/%s", "Foo handler"), true, "registering a web+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, "web+foo", "ftp://mochi.test:8888/%s", "Foo handler"), false, "registering a web+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, "web+foo", "chrome://mochi.test:8888/%s", "Foo handler"), false, "registering a web+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, "web+foo", "foo://mochi.test:8888/%s", "Foo handler"), false, "registering a web+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");
 
     // registering anything not on the list of safe schemes and unprefixed by web+ shouldn't work
     is(testRegisterHandler(true, "foo", "http://mochi.test:8888/%s", "chrome handler"), false, "registering a foo protocol handler should not work");
     is(testRegisterHandler(true, "web+", "http://mochi.test:8888/%s", "chrome handler"), false, "registering a 'web+' protocol handler should not work");
     is(testRegisterHandler(true, "web+1", "http://mochi.test:8888/%s", "chrome handler"), false, "registering a 'web+1' 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
     SimpleTest.finish();
   }
 
   tests();
 
 </script>
 </pre>
 </body>