Bug 1428414 - Add a PaymentRequest local dev. server. r=jaws
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Tue, 20 Mar 2018 00:05:42 -0700
changeset 411558 b4f0025c830369df929c2557390e5289affc13fc
parent 411557 1fb1569b61d292785497c3f662b8a387c638695a
child 411559 4fa0e33621e398a08243851c72c6b5415decc722
push id101686
push useraciure@mozilla.com
push dateTue, 03 Apr 2018 21:59:31 +0000
treeherdermozilla-inbound@8d846598d35d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1428414
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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)