]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/content/dactyl.js
Import 1.0 supporting Firefox up to 14.*
[dactyl.git] / common / content / dactyl.js
index dc9df88be5fd42c2adfc36014e01c939a3d56bb8..2933dcd95d2a35e65ef0a1794d507e6b37188c3c 100644 (file)
@@ -887,11 +887,15 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
      * Opens one or more URLs. Returns true when load was initiated, or
      * false on error.
      *
-     * @param {string|object|Array} urls A representation of the URLs to open. May be
-     *     either a string, which will be passed to
-     *     {@link Dactyl#parseURLs}, an array in the same format as
-     *     would be returned by the same, or an object as returned by
-     *     {@link DOM#formData}.
+     * @param {string|Array} urls A representation of the URLs to open.
+     *     A string will be passed to {@link Dactyl#parseURLs}. An array may
+     *     contain elements of the following forms:
+     *
+     *      • {string}                    A URL to open.
+     *      • {[string, {string|Array}]}  Pair of a URL and POST data.
+     *      • {object}                    Object compatible with those returned
+     *                                    by {@link DOM#formData}.
+     *
      * @param {object} params A set of parameters specifying how to open the
      *     URLs. The following properties are recognized:
      *
@@ -952,6 +956,18 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                     loc = { url: loc[0], postData: loc[1] };
                 else if (isString(loc))
                     loc = { url: loc };
+                else
+                    loc = Object.create(loc);
+
+                if (isString(loc.postData))
+                    loc.postData = ["application/x-www-form-urlencoded", loc.postData];
+
+                if (isArray(loc.postData)) {
+                    let stream = services.MIMEStream(services.StringStream(loc.postData[1]));
+                    stream.addHeader("Content-Type", loc.postData[0]);
+                    stream.addContentLength = true;
+                    loc.postData = stream;
+                }
 
                 // decide where to load the first url
                 switch (where) {
@@ -1939,7 +1955,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                 if (dactyl.commandLineOptions.rcFile == "NONE" || dactyl.commandLineOptions.noPlugins)
                     options["loadplugins"] = [];
 
-                if (options["loadplugins"])
+                if (options["loadplugins"].length)
                     dactyl.loadPlugins();
             }
             catch (e) {