Bug 1428414 - Add a PaymentRequest local dev. server. r=jaws draft
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Tue, 20 Mar 2018 00:05:42 -0700
changeset 776191 23865bf7c4ce13885cecae86b05661c66397d451
parent 776018 c44f60c43432d468639b5fe078420e60c13fd3de
child 776192 a46a935e7886e81d7e39fe2d606305bba8bdddac
push id104830
push usermozilla@noorenberghe.ca
push dateMon, 02 Apr 2018 19:39:39 +0000
reviewersjaws
bugs1428414
milestone61.0a1
Bug 1428414 - Add a PaymentRequest local dev. server. r=jaws MozReview-Commit-ID: 4MsdRuXIiLE
toolkit/components/payments/docs/index.rst
toolkit/components/payments/server.py
--- 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)