Bug 1428414 - Add a PaymentRequest local dev. server. r=jaws
MozReview-Commit-ID: 4MsdRuXIiLE
--- a/toolkit/components/payments/docs/index.rst
+++ b/toolkit/components/payments/docs/index.rst
@@ -20,20 +20,20 @@ Web Payments `does not work without e10s
Logging
-------
Set the pref ``dom.payments.loglevel`` to "Debug" to increase the verbosity of console messages.
Unprivileged UI Development
---------------------------
-During development of the unprivileged custom elements, you can load the dialog over a file: URI or
-local server without even requiring a build. Simply load
-`toolkit/components/payments/res/paymentRequest.xhtml` in the browser. Use the debugging console to
-load sample data.
+During development of the unprivileged custom elements, you can load the dialog from a
+local server without even requiring a build. Simply run `./mach python toolkit/components/payments/server.py`
+then load `http://localhost:8000/paymentRequest.xhtml?debug=1` in the browser.
+Use the debugging console to load sample data.
Debugging Console
-----------------
To open the debugging console in the dialog, use the keyboard shortcut
**Ctrl-Alt-d (Ctrl-Option-d on macOS)**. While loading `paymentRequest.xhtml` directly in the
browser, add `?debug=1` to have the debugging console open by default.
new file mode 100644
--- /dev/null
+++ b/toolkit/components/payments/server.py
@@ -0,0 +1,18 @@
+import BaseHTTPServer
+from SimpleHTTPServer import SimpleHTTPRequestHandler
+
+
+class RequestHandler(SimpleHTTPRequestHandler, object):
+ def translate_path(self, path):
+ # Map autofill paths to their own directory
+ autofillPath = "/formautofill"
+ if (path.startswith(autofillPath)):
+ path = "browser/extensions/formautofill/content" + path[len(autofillPath):]
+ else:
+ path = "toolkit/components/payments/res" + path
+
+ return super(RequestHandler, self).translate_path(path)
+
+
+if __name__ == '__main__':
+ BaseHTTPServer.test(RequestHandler, BaseHTTPServer.HTTPServer)