summaryrefslogtreecommitdiffstats
path: root/comm/calendar/test/unit/test_webcal.js
diff options
context:
space:
mode:
Diffstat (limited to 'comm/calendar/test/unit/test_webcal.js')
-rw-r--r--comm/calendar/test/unit/test_webcal.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/comm/calendar/test/unit/test_webcal.js b/comm/calendar/test/unit/test_webcal.js
new file mode 100644
index 0000000000..77d9576f4b
--- /dev/null
+++ b/comm/calendar/test/unit/test_webcal.js
@@ -0,0 +1,44 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
+var { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
+
+function run_test() {
+ let httpserv = new HttpServer();
+ httpserv.registerPrefixHandler("/", {
+ handle(request, response) {
+ response.setStatusLine(request.httpVersion, 200, "OK");
+ equal(request.path, "/test_webcal");
+ },
+ });
+ httpserv.start(-1);
+
+ let baseUri = "://localhost:" + httpserv.identity.primaryPort + "/test_webcal";
+ add_test(check_webcal_uri.bind(null, "webcal" + baseUri));
+ // TODO webcals needs bug 466524 to be fixed
+ // add_test(check_webcal_uri.bind(null, "webcals" + baseUri));
+ add_test(() => httpserv.stop(run_next_test));
+
+ // Now lets go...
+ run_next_test();
+}
+
+function check_webcal_uri(aUri) {
+ let uri = Services.io.newURI(aUri);
+
+ let channel = Services.io.newChannelFromURI(
+ uri,
+ null,
+ Services.scriptSecurityManager.getSystemPrincipal(),
+ null,
+ Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
+ Ci.nsIContentPolicy.TYPE_OTHER
+ );
+
+ NetUtil.asyncFetch(channel, (data, status, request) => {
+ ok(Components.isSuccessCode(status));
+ run_next_test();
+ });
+}