]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/modules/protocol.jsm
Import r6923 from upstream hg supporting Firefox up to 22.0a1
[dactyl.git] / common / modules / protocol.jsm
index edb642ecb888aff28704bdaa6f011a0ae69d9c03..82b59a39f2246d7a1a8fe09e1345a14dd08f8df0 100644 (file)
@@ -1,14 +1,13 @@
-// Copyright (c) 2008-2011 by Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
 //
 // This work is licensed for reuse under an MIT license. Details are
 // given in the LICENSE.txt file included with this file.
-/* use strict */
+"use strict";
 
-Components.utils.import("resource://dactyl/bootstrap.jsm");
 defineModule("protocol", {
     exports: ["LocaleChannel", "Protocol", "RedirectChannel", "StringChannel", "XMLChannel"],
     require: ["services", "util"]
-}, this);
+});
 
 var systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal);
 
@@ -51,8 +50,12 @@ function NetError(orig, error) {
     }).data.QueryInterface(Ci.nsIChannel);
 }
 function RedirectChannel(to, orig, time, message) {
-    let html = <html><head><meta http-equiv="Refresh" content={(time || 0) + ";" + to}/></head>
-                     <body><h2 style="text-align: center">{message || ""}</h2></body></html>.toXMLString();
+    let html = DOM.toXML(
+        ["html", {},
+            ["head", {},
+                ["meta", { "http-equiv": "Refresh", content: (time || 0) + ";" + to }]],
+            ["body", {},
+                ["h2", { style: "text-align: center" }, message || ""]]]);
     return StringChannel(html, "text/html", services.io.newURI(to, null, null));
 }
 
@@ -187,7 +190,7 @@ function XMLChannel(uri, contentType, noErrorChannel, unprivileged) {
     let type = this.channel.contentType;
     if (/^text\/|[\/+]xml$/.test(type)) {
         let stream = services.InputStream(channelStream);
-        let [, pre, doctype, url, extra, open, post] = util.regexp(<![CDATA[
+        let [, pre, doctype, url, extra, open, post] = util.regexp(literal(/*
                 ^ ([^]*?)
                 (?:
                     (<!DOCTYPE \s+ \S+ \s+) (?:SYSTEM \s+ "([^"]*)" | ((?:[^[>\s]|\s[^[])*))
@@ -195,7 +198,7 @@ function XMLChannel(uri, contentType, noErrorChannel, unprivileged) {
                     ([^]*)
                 )?
                 $
-            ]]>, "x").exec(stream.read(4096));
+            */), "x").exec(stream.read(4096));
         this.writes.push(pre);
         if (doctype) {
             this.writes.push(doctype + (extra || "") + " [\n");
@@ -224,6 +227,7 @@ XMLChannel.prototype = {
             this.writes.push(services.io.newChannel(url, null, this.uri).open());
         }
         catch (e) {
+            util.dump("addChannel('" + url + "'):");
             util.reportError(e);
         }
     },