Fix bug 668474 - Remote calendar with webcal:// location not working (regression). r=mschroeder
authorPhilipp Kewisch <mozilla@kewis.ch>
Thu, 07 Jul 2011 09:17:00 +0300
changeset 8337 6ed6ce9c50e0efeea80a141033464590e5ce5f26
parent 8336 8b58620e5e106377537cf2ff4e7370ce03653d3f
child 8338 936873f0612db38cb2c577fb26ff15f9a8c32b95
push idunknown
push userunknown
push dateunknown
reviewersmschroeder
bugs668474
Fix bug 668474 - Remote calendar with webcal:// location not working (regression). r=mschroeder
calendar/base/src/calItemModule.manifest
calendar/test/unit/test_webcal.js
--- a/calendar/base/src/calItemModule.manifest
+++ b/calendar/base/src/calItemModule.manifest
@@ -34,21 +34,21 @@ component {6fe88047-75b6-4874-80e8-5f580
 contract @mozilla.org/calendar/ics-parser;1 {6fe88047-75b6-4874-80e8-5f5800f14984}
 
 component {207a6682-8ff1-4203-9160-729ec28c8766} calItemModule.js
 contract @mozilla.org/calendar/ics-serializer;1 {207a6682-8ff1-4203-9160-729ec28c8766}
 
 component {f41392ab-dcad-4bad-818f-b3d1631c4d93} calItemModule.js
 contract @mozilla.org/calendar/itip-item;1 {f41392ab-dcad-4bad-818f-b3d1631c4d93}
 
-component {1e2fc0e2-bf5f-4d60-9f1e-5e92cf517c0b} calItemModule.js
-contract @mozilla.org/network/protocol;1?name=webcal {1e2fc0e2-bf5f-4d60-9f1e-5e92cf517c0b}
+component {1153c73a-39be-46aa-9ba9-656d188865ca} calItemModule.js
+contract @mozilla.org/network/protocol;1?name=webcal {1153c73a-39be-46aa-9ba9-656d188865ca}
 
-component {b2ee6f91-b061-4527-97a1-b85361775fc1} calItemModule.js
-contract @mozilla.org/network/protocol;1?name=webcals {b2ee6f91-b061-4527-97a1-b85361775fc1}
+component {bdf71224-365d-4493-856a-a7e74026f766} calItemModule.js
+contract @mozilla.org/network/protocol;1?name=webcals {bdf71224-365d-4493-856a-a7e74026f766}
 
 component {04027036-5884-4a30-b4af-f2cad79f6edf} calItemModule.js
 contract @mozilla.org/calendar/recurrence-info;1 {04027036-5884-4a30-b4af-f2cad79f6edf}
 
 component {76810fae-abad-4019-917a-08e95d5bbd68} calItemModule.js
 contract @mozilla.org/calendar/relation;1 {76810fae-abad-4019-917a-08e95d5bbd68}
 
 component {2547331f-34c0-4a4b-b93c-b503538ba6d6} calItemModule.js
new file mode 100644
--- /dev/null
+++ b/calendar/test/unit/test_webcal.js
@@ -0,0 +1,90 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Calendar code.
+ *
+ * The Initial Developer of the Original Code is
+ *   Philipp Kewisch <mozilla@kewis.ch>
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+do_load_httpd_js();
+
+var httpserver = null;
+
+// TODO webcals doesn't work since httpd.js doesn't support ssl without ssltunnel
+var testUris = ["webcal://localhost:4444/test_webcal"  /* ,
+                "webcals://localhost:4445/test_webcals" */
+               ];
+
+var testListener = {
+    onStartRequest: function onStartRequest(request, context) {
+        var chan = request.QueryInterface(Components.interfaces.nsIChannel);
+        do_check_eq(chan.status, Components.results.NS_OK);
+    },
+    onDataAvailable: function onDataAvailable(request, context, stream, offset, count) {
+        stream.read(count);
+    },
+    onStopRequest: function onStopRequest(request, context, statusCode) {
+        // TODO For some reason we're getting error 0x80570021 here
+        // (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS), but we can't get the
+        // actual error :-(
+        // var chan = request.QueryInterface(Components.interfaces.nsIChannel);
+        // do_check_eq(chan.status, Components.results.NS_OK);
+
+        startNextTest();
+        do_test_finished();
+    }
+};
+
+function startNextTest() {
+    let nextUri = testUris.shift();
+    if (nextUri) {
+        let chan = cal.getIOService().newChannel(nextUri, null, null);
+        chan.asyncOpen(testListener, null);
+        do_test_pending();
+    } else {
+        do_test_pending();
+        httpserv.stop(do_test_finished);
+    }
+}
+
+function run_test() {
+
+    httpserv = new nsHttpServer();
+
+    httpserv.registerPathHandler("/", {
+        handle: function(request, response) {
+        }
+    });
+
+    httpserv.identity.add("https", "localhost", 4445);
+    httpserv.start(4444);
+    startNextTest();
+}