Backed out 5 changesets (bug 1383300) for leaks
authorPhil Ringnalda <philringnalda@gmail.com>
Fri, 03 Nov 2017 20:13:58 -0700
changeset 443421 ab983c341420850665acbad872d398cb3b8c9066
parent 443420 6eece4a582994d925f1b9bd28a6bd4d1ba467b27
child 443422 a6e70d92a22f98a28c2e8a0082bf62a29a1a7556
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1383300
milestone58.0a1
backs out3879080f60c23f6f08dde68e4f073873ea9d64cb
bc8f24ca5bb3abdab417af45017b91a9a44a0745
908e2e2a759b9579c74d92950598ea09439c3233
71b84c8137051478ac2e60dea8c42c4863c7188f
34fa5b4d4d596ae654b3571700afa42c290d7cc7
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
Backed out 5 changesets (bug 1383300) for leaks CLOSED TREE Backed out changeset 3879080f60c2 (bug 1383300) Backed out changeset bc8f24ca5bb3 (bug 1383300) Backed out changeset 908e2e2a759b (bug 1383300) Backed out changeset 71b84c813705 (bug 1383300) Backed out changeset 34fa5b4d4d59 (bug 1383300) MozReview-Commit-ID: BVz3KG0Qixi
toolkit/components/payments/content/paymentDialog.css
toolkit/components/payments/content/paymentDialog.js
toolkit/components/payments/content/paymentDialog.xhtml
toolkit/components/payments/content/paymentDialogFrameScript.js
toolkit/components/payments/docs/index.rst
toolkit/components/payments/jar.mn
toolkit/components/payments/moz.build
toolkit/components/payments/paymentUIService.js
toolkit/components/payments/res/paymentRequest.css
toolkit/components/payments/res/paymentRequest.js
toolkit/components/payments/res/paymentRequest.xhtml
toolkit/components/payments/test/PaymentTestUtils.jsm
toolkit/components/payments/test/browser/browser.ini
toolkit/components/payments/test/browser/browser_host_name.js
toolkit/components/payments/test/browser/browser_show_dialog.js
toolkit/components/payments/test/browser/browser_total.js
toolkit/components/payments/test/browser/head.js
deleted file mode 100644
--- a/toolkit/components/payments/content/paymentDialog.css
+++ /dev/null
@@ -1,11 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-body {
-  margin: 0;
-}
-
-#paymentRequestFrame {
-  border: none;
-}
--- a/toolkit/components/payments/content/paymentDialog.js
+++ b/toolkit/components/payments/content/paymentDialog.js
@@ -8,57 +8,34 @@
  */
 
 "use strict";
 
 const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
 const paymentSrv = Cc["@mozilla.org/dom/payments/payment-request-service;1"]
                      .getService(Ci.nsIPaymentRequestService);
 
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
 let PaymentDialog = {
   componentsLoaded: new Map(),
   frame: null,
   mm: null,
-  request: null,
 
-  init(requestId, frame) {
-    if (!requestId || typeof(requestId) != "string") {
-      throw new Error("Invalid PaymentRequest ID");
-    }
-    this.request = paymentSrv.getPaymentRequestById(requestId);
-
-    if (!this.request) {
-      throw new Error(`PaymentRequest not found: ${requestId}`);
-    }
-
+  init(frame) {
     this.frame = frame;
     this.mm = frame.frameLoader.messageManager;
-
-    XPCOMUtils.defineLazyGetter(this, "log", () => {
-      let {ConsoleAPI} = Cu.import("resource://gre/modules/Console.jsm", {});
-      return new ConsoleAPI({
-        maxLogLevelPref: "dom.payments.loglevel",
-        prefix: `paymentDialog (${requestId})`,
-      });
-    });
-
-    this.log.debug("init:", this.request);
     this.mm.addMessageListener("paymentContentToChrome", this);
     this.mm.loadFrameScript("chrome://payments/content/paymentDialogFrameScript.js", true);
-    this.frame.src = "resource://payments/paymentRequest.xhtml";
   },
 
-  createShowResponse({acceptStatus, methodName = "", data = null,
+  createShowResponse({requestId, acceptStatus, methodName = "", data = null,
                       payerName = "", payerEmail = "", payerPhone = ""}) {
     let showResponse = this.createComponentInstance(Ci.nsIPaymentShowActionResponse);
     let methodData = this.createComponentInstance(Ci.nsIGeneralResponseData);
 
-    showResponse.init(this.request.requestId,
+    showResponse.init(requestId,
                       acceptStatus,
                       methodName,
                       methodData,
                       payerName,
                       payerEmail,
                       payerPhone);
     return showResponse;
   },
@@ -80,50 +57,38 @@ let PaymentDialog = {
     if (!component) {
       component = Cc[componentName];
       this.componentsLoaded.set(componentName, component);
     }
 
     return component.createInstance(componentInterface);
   },
 
-  onPaymentCancel() {
+  onPaymentCancel(requestId) {
     const showResponse = this.createShowResponse({
+      requestId,
       acceptStatus: Ci.nsIPaymentActionResponse.PAYMENT_REJECTED,
     });
     paymentSrv.respondPayment(showResponse);
     window.close();
   },
 
   receiveMessage({data}) {
-    let {messageType} = data;
+    let {messageType, requestId} = data;
 
     switch (messageType) {
       case "initializeRequest": {
-        let requestSerialized = JSON.parse(JSON.stringify(this.request));
-
-        // Manually serialize the nsIPrincipal.
-        let displayHost = this.request.topLevelPrincipal.URI.displayHost;
-        requestSerialized.topLevelPrincipal = {
-          URI: {
-            displayHost,
-          },
-        };
-
         this.mm.sendAsyncMessage("paymentChromeToContent", {
           messageType: "showPaymentRequest",
-          data: {
-            request: requestSerialized,
-          },
+          data: window.arguments[0],
         });
         break;
       }
       case "paymentCancel": {
-        this.onPaymentCancel();
+        this.onPaymentCancel(requestId);
         break;
       }
     }
   },
 };
 
 let frame = document.getElementById("paymentRequestFrame");
-let requestId = (new URLSearchParams(window.location.search)).get("requestId");
-PaymentDialog.init(requestId, frame);
+PaymentDialog.init(frame);
--- a/toolkit/components/payments/content/paymentDialog.xhtml
+++ b/toolkit/components/payments/content/paymentDialog.xhtml
@@ -1,20 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
   <title></title>
-  <link rel="stylesheet" href="chrome://payments/content/paymentDialog.css"/>
 </head>
-
 <body>
   <iframe type="content"
           id="paymentRequestFrame"
           mozbrowser="true"
           remote="true"
-          name="paymentRequestFrame"></iframe>
+          name="paymentRequestFrame"
+          src="resource://payments/paymentRequest.xhtml"></iframe>
   <script src="chrome://payments/content/paymentDialog.js"></script>
 </body>
 </html>
--- a/toolkit/components/payments/content/paymentDialogFrameScript.js
+++ b/toolkit/components/payments/content/paymentDialogFrameScript.js
@@ -19,50 +19,56 @@
 
 /* eslint-env mozilla/frame-script */
 
 const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 let PaymentFrameScript = {
   init() {
-    XPCOMUtils.defineLazyGetter(this, "log", () => {
-      let {ConsoleAPI} = Cu.import("resource://gre/modules/Console.jsm", {});
-      return new ConsoleAPI({
-        maxLogLevelPref: "dom.payments.loglevel",
-        prefix: "paymentDialogFrameScript",
-      });
-    });
-
+    this.defineLazyLogGetter(this, "frameScript");
     addEventListener("paymentContentToChrome", this, false, true);
 
     addMessageListener("paymentChromeToContent", this);
   },
 
   handleEvent(event) {
     this.sendToChrome(event);
   },
 
   receiveMessage({data: {messageType, data}}) {
     this.sendToContent(messageType, data);
   },
 
   sendToChrome({detail}) {
-    let {messageType} = detail;
-    this.log.debug("sendToChrome:", messageType, detail);
-    this.sendMessageToChrome(messageType, detail);
+    let {messageType, requestId} = detail;
+    this.log.debug(`received message from content: ${messageType} ... ${requestId}`);
+    this.sendMessageToChrome(messageType, {
+      requestId,
+    });
+  },
+
+  defineLazyLogGetter(scope, logPrefix) {
+    XPCOMUtils.defineLazyGetter(scope, "log", () => {
+      let {ConsoleAPI} = Cu.import("resource://gre/modules/Console.jsm", {});
+      return new ConsoleAPI({
+        maxLogLevelPref: "dom.payments.loglevel",
+        prefix: logPrefix,
+      });
+    });
   },
 
   sendToContent(messageType, detail = {}) {
-    this.log.debug("sendToContent", messageType, detail);
+    this.log.debug(`sendToContent (${messageType})`);
     let response = Object.assign({messageType}, detail);
-    let event = new content.CustomEvent("paymentChromeToContent", {
-      detail: Cu.cloneInto(response, content),
+    let event = new content.document.defaultView.CustomEvent("paymentChromeToContent", {
+      bubbles: true,
+      detail: Cu.cloneInto(response, content.document.defaultView),
     });
-    content.dispatchEvent(event);
+    content.document.dispatchEvent(event);
   },
 
-  sendMessageToChrome(messageType, data = {}) {
-    sendAsyncMessage("paymentContentToChrome", Object.assign(data, {messageType}));
+  sendMessageToChrome(messageType, detail = {}) {
+    sendAsyncMessage("paymentContentToChrome", Object.assign(detail, {messageType}));
   },
 };
 
 PaymentFrameScript.init();
--- a/toolkit/components/payments/docs/index.rst
+++ b/toolkit/components/payments/docs/index.rst
@@ -9,23 +9,16 @@ JSDoc style comments are used within the
 .. toctree::
    :maxdepth: 5
 
 Debugging
 =========
 
 Set the pref ``dom.payments.loglevel`` to "Debug".
 
-To open a debugger in the context of the remote payment frame, run the following while the dialog is the most recent window:
-``
-gDevToolsBrowser.openContentProcessToolbox({
-  selectedBrowser: Services.wm.getMostRecentWindow(null).document.getElementById("paymentRequestFrame").frameLoader,
-})
-``
-
 
 Communication with the DOM
 ==========================
 
 Communication from the DOM to the UI happens via the `paymentUIService.js` (implementing ``nsIPaymentUIService``).
 The UI talks to the DOM code via the ``nsIPaymentRequestService`` interface.
 
 
@@ -34,12 +27,12 @@ Dialog Architecture
 
 Privileged wrapper XHTML document (paymentDialog.xhtml) containing a remote ``<iframe mozbrowser="true" remote="true">`` containing unprivileged XHTML (paymentRequest.xhtml).
 Keeping the dialog contents unprivileged is useful since the dialog will render payment line items and shipping options that are provided by web developers and should therefore be considered untrusted.
 In order to communicate across the process boundary a privileged frame script (`paymentDialogFrameScript.js`) is loaded into the iframe to relay messages.
 This is because the unprivileged document cannot access message managers.
 Instead, all communication across the privileged/unprivileged boundary is done via custom DOM events:
 
 * A ``paymentContentToChrome`` event is dispatched when the dialog contents want to communicate with the privileged dialog wrapper.
-* A ``paymentChromeToContent`` event is dispatched on the ``window`` with the ``detail`` property populated when the privileged dialog wrapper communicates with the unprivileged dialog.
+* A ``paymentChromeToContent`` event is dispatched on the ``document`` with the ``detail`` property populated when the privileged dialog wrapper communicates with the unprivileged dialog.
 
 These events are converted to/from message manager messages of the same name to communicate to the other process.
 The purpose of `paymentDialogFrameScript.js` is to simply convert unprivileged DOM events to/from messages from the other process.
--- a/toolkit/components/payments/jar.mn
+++ b/toolkit/components/payments/jar.mn
@@ -1,12 +1,11 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 toolkit.jar:
 %   content payments %content/payments/
-    content/payments/paymentDialog.css                (content/paymentDialog.css)
     content/payments/paymentDialog.js                 (content/paymentDialog.js)
     content/payments/paymentDialogFrameScript.js      (content/paymentDialogFrameScript.js)
     content/payments/paymentDialog.xhtml              (content/paymentDialog.xhtml)
 %   resource payments %res/payments/
     res/payments (res/paymentRequest.*)
--- a/toolkit/components/payments/moz.build
+++ b/toolkit/components/payments/moz.build
@@ -9,15 +9,13 @@ BROWSER_CHROME_MANIFESTS += ['test/brows
 with Files('**'):
     BUG_COMPONENT = ('Toolkit', 'WebPayments UI')
 
 EXTRA_COMPONENTS += [
     'payments.manifest',
     'paymentUIService.js',
 ]
 
+EXTRA_JS_MODULES += []
+
 JAR_MANIFESTS += ['jar.mn']
 
 SPHINX_TREES['docs'] = 'docs'
-
-TESTING_JS_MODULES += [
-    'test/PaymentTestUtils.jsm',
-]
--- a/toolkit/components/payments/paymentUIService.js
+++ b/toolkit/components/payments/paymentUIService.js
@@ -20,46 +20,51 @@ const { classes: Cc, interfaces: Ci, res
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this,
                                    "paymentSrv",
                                    "@mozilla.org/dom/payments/payment-request-service;1",
                                    "nsIPaymentRequestService");
 
-function PaymentUIService() {
-  this.wrappedJSObject = this;
-  XPCOMUtils.defineLazyGetter(this, "log", () => {
+function defineLazyLogGetter(scope, logPrefix) {
+  XPCOMUtils.defineLazyGetter(scope, "log", () => {
     let {ConsoleAPI} = Cu.import("resource://gre/modules/Console.jsm", {});
     return new ConsoleAPI({
       maxLogLevelPref: "dom.payments.loglevel",
-      prefix: "Payment UI Service",
+      prefix: logPrefix,
     });
   });
+}
+
+function PaymentUIService() {
+  this.wrappedJSObject = this;
+  defineLazyLogGetter(this, "Payment UI Service");
   this.log.debug("constructor");
 }
 
 PaymentUIService.prototype = {
   classID: Components.ID("{01f8bd55-9017-438b-85ec-7c15d2b35cdc}"),
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIPaymentUIService]),
   DIALOG_URL: "chrome://payments/content/paymentDialog.xhtml",
   REQUEST_ID_PREFIX: "paymentRequest-",
 
   // nsIPaymentUIService implementation:
 
   showPayment(requestId) {
-    this.log.debug("showPayment:", requestId);
+    this.log.debug(`showPayment: ${requestId}`);
     let chromeWindow = Services.wm.getMostRecentWindow("navigator:browser");
-    chromeWindow.openDialog(`${this.DIALOG_URL}?requestId=${requestId}`,
+    chromeWindow.openDialog(this.DIALOG_URL,
                             `${this.REQUEST_ID_PREFIX}${requestId}`,
-                            "modal,dialog,centerscreen,resizable=no");
+                            "modal,dialog,centerscreen",
+                            {requestId});
   },
 
   abortPayment(requestId) {
-    this.log.debug("abortPayment:", requestId);
+    this.log.debug(`abortPayment: ${requestId}`);
     let abortResponse = Cc["@mozilla.org/dom/payments/payment-abort-action-response;1"]
                           .createInstance(Ci.nsIPaymentAbortActionResponse);
 
     let enu = Services.wm.getEnumerator(null);
     let win;
     while ((win = enu.getNext())) {
       if (win.name == `${this.REQUEST_ID_PREFIX}${requestId}`) {
         this.log.debug(`closing: ${win.name}`);
@@ -74,25 +79,25 @@ PaymentUIService.prototype = {
       Ci.nsIPaymentActionResponse.ABORT_SUCCEEDED :
       Ci.nsIPaymentActionResponse.ABORT_FAILED;
 
     abortResponse.init(requestId, response);
     paymentSrv.respondPayment(abortResponse);
   },
 
   completePayment(requestId) {
-    this.log.debug("completePayment:", requestId);
+    this.log.debug(`completePayment: ${requestId}`);
     let completeResponse = Cc["@mozilla.org/dom/payments/payment-complete-action-response;1"]
                              .createInstance(Ci.nsIPaymentCompleteActionResponse);
     completeResponse.init(requestId, Ci.nsIPaymentActionResponse.COMPLTETE_SUCCEEDED);
     paymentSrv.respondPayment(completeResponse.QueryInterface(Ci.nsIPaymentActionResponse));
   },
 
   updatePayment(requestId) {
-    this.log.debug("updatePayment:", requestId);
+    this.log.debug(`updatePayment: ${requestId}`);
   },
 
   // other helper methods
 
   requestIdForWindow(window) {
     let windowName = window.name;
 
     return windowName.startsWith(this.REQUEST_ID_PREFIX) ?
--- a/toolkit/components/payments/res/paymentRequest.css
+++ b/toolkit/components/payments/res/paymentRequest.css
@@ -1,24 +1,4 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-html {
-  background: -moz-dialog;
-}
-
-#total {
-  border: 1px solid black;
-  margin: 5px;
-  text-align: center;
-}
-
-#total .label {
-  font-size: 15px;
-  font-weight: bold;
-}
-
-#cancel {
-  position: absolute;
-  bottom: 10px;
-  left: 10px;
-}
--- a/toolkit/components/payments/res/paymentRequest.js
+++ b/toolkit/components/payments/res/paymentRequest.js
@@ -6,17 +6,17 @@
  * Loaded in the unprivileged frame of each payment dialog.
  *
  * Communicates with privileged code via DOM Events.
  */
 
 "use strict";
 
 let PaymentRequest = {
-  request: null,
+  requestId: null,
 
   init() {
     // listen to content
     window.addEventListener("paymentChromeToContent", this);
 
     // listen to user events
     window.addEventListener("DOMContentLoaded", this, {once: true});
 
@@ -52,37 +52,29 @@ let PaymentRequest = {
       }
     }
   },
 
   sendMessageToChrome(messageType, detail = {}) {
     let event = new CustomEvent("paymentContentToChrome", {
       bubbles: true,
       detail: Object.assign({
+        requestId: this.requestId,
         messageType,
       }, detail),
     });
     document.dispatchEvent(event);
   },
 
   onChromeToContent({detail}) {
-    let {messageType} = detail;
+    let {messageType, requestId} = detail;
 
     switch (messageType) {
       case "showPaymentRequest": {
-        this.request = detail.request;
-
-        let hostNameEl = document.getElementById("host-name");
-        hostNameEl.textContent = this.request.topLevelPrincipal.URI.displayHost;
-
-        let totalItem = this.request.paymentDetails.totalItem;
-        let totalEl = document.getElementById("total");
-        totalEl.querySelector(".value").textContent = totalItem.amount.value;
-        totalEl.querySelector(".currency").textContent = totalItem.amount.currency;
-        totalEl.querySelector(".label").textContent = totalItem.label;
+        this.requestId = requestId;
         break;
       }
     }
   },
 
   onPaymentRequestLoad(requestId) {
     let cancelBtn = document.getElementById("cancel");
     cancelBtn.addEventListener("click", this, {once: true});
--- a/toolkit/components/payments/res/paymentRequest.xhtml
+++ b/toolkit/components/payments/res/paymentRequest.xhtml
@@ -5,20 +5,13 @@
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
   <title></title>
   <link rel="stylesheet" href="resource://payments/paymentRequest.css" />
   <script src="resource://payments/paymentRequest.js"></script>
 </head>
 <body>
-  <div id="host-name"></div>
-
-  <div id="total">
-    <h2 class="label"></h2>
-    <span class="value"></span>
-    <span class="currency"></span>
-  </div>
   <div id="controls-container">
     <button id="cancel">Cancel payment</button>
   </div>
 </body>
 </html>
deleted file mode 100644
--- a/toolkit/components/payments/test/PaymentTestUtils.jsm
+++ /dev/null
@@ -1,73 +0,0 @@
-"use strict";
-
-this.EXPORTED_SYMBOLS = ["PaymentTestUtils"];
-
-const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
-
-this.PaymentTestUtils = {
-  /**
-   * Common content tasks functions to be used with ContentTask.spawn.
-   */
-  ContentTasks: {
-    /* eslint-env mozilla/frame-script */
-    /**
-     * Create a new payment request and cache it as `rq`.
-     *
-     * @param {Object} args
-     * @param {PaymentMethodData[]} methodData
-     * @param {PaymentDetailsInit} details
-     * @param {PaymentOptions} options
-     */
-    createRequest: ({methodData, details, options}) => {
-      const rq = new content.PaymentRequest(methodData, details, options);
-      content.rq = rq; // assign it so we can retrieve it later
-    },
-
-    /**
-     * Create a new payment request cached as `rq` and then show it.
-     *
-     * @param {Object} args
-     * @param {PaymentMethodData[]} methodData
-     * @param {PaymentDetailsInit} details
-     * @param {PaymentOptions} options
-     */
-    createAndShowRequest: ({methodData, details, options}) => {
-      const rq = new content.PaymentRequest(methodData, details, options);
-      content.rq = rq; // assign it so we can retrieve it later
-      rq.show();
-    },
-
-    /**
-     * Click the cancel button
-     *
-     * Don't await on this task since the cancel can close the dialog before
-     * ContentTask can resolve the promise.
-     *
-     * @returns {undefined}
-     */
-    manuallyClickCancel: () => {
-      content.document.getElementById("cancel").click();
-    },
-  },
-
-  /**
-   * Common PaymentMethodData for testing
-   */
-  MethodData: {
-    basicCard: {
-      supportedMethods: "basic-card",
-    },
-  },
-
-  /**
-   * Common PaymentDetailsInit for testing
-   */
-  Details: {
-    total60USD: {
-      total: {
-        label: "Total due",
-        amount: { currency: "USD", value: "60.00" },
-      },
-    },
-  },
-};
--- a/toolkit/components/payments/test/browser/browser.ini
+++ b/toolkit/components/payments/test/browser/browser.ini
@@ -1,12 +1,9 @@
 [DEFAULT]
 head = head.js
-prefs =
-  dom.payments.request.enabled=true
-skip-if = !e10s # Bug 1365964 - Payment Request isn't implemented for non-e10s
 support-files =
   blank_page.html
 
-[browser_host_name.js]
 [browser_request_summary.js]
 [browser_show_dialog.js]
-[browser_total.js]
+# Bug 1365964 - Payment Request isn't implemented for non-e10s
+skip-if = !e10s
deleted file mode 100644
--- a/toolkit/components/payments/test/browser/browser_host_name.js
+++ /dev/null
@@ -1,35 +0,0 @@
-"use strict";
-
-async function withBasicRequestDialogForOrigin(origin, dialogTaskFn) {
-  const args = {
-    methodData: [PTU.MethodData.basicCard],
-    details: PTU.Details.total60USD,
-  };
-  await spawnInDialogForMerchantTask(PTU.ContentTasks.createRequest, dialogTaskFn, args, {
-    origin,
-  });
-}
-
-/* eslint-disable mozilla/no-cpows-in-tests */
-add_task(async function test_host() {
-  await withBasicRequestDialogForOrigin("https://example.com", () => {
-    is(content.document.querySelector("#host-name").textContent, "example.com",
-       "Check basic host name");
-  });
-});
-
-add_task(async function test_host_subdomain() {
-  await withBasicRequestDialogForOrigin("https://test1.example.com", () => {
-    is(content.document.querySelector("#host-name").textContent, "test1.example.com",
-       "Check host name with subdomain");
-  });
-});
-
-add_task(async function test_host_IDN() {
-  await withBasicRequestDialogForOrigin("https://xn--hxajbheg2az3al.xn--jxalpdlp", () => {
-    is(content.document.querySelector("#host-name").textContent,
-       "\u03C0\u03B1\u03C1\u03AC\u03B4\u03B5\u03B9\u03B3\u03BC\u03B1." +
-       "\u03B4\u03BF\u03BA\u03B9\u03BC\u03AE",
-       "Check IDN domain");
-  });
-});
--- a/toolkit/components/payments/test/browser/browser_show_dialog.js
+++ b/toolkit/components/payments/test/browser/browser_show_dialog.js
@@ -1,20 +1,27 @@
 "use strict";
 
-const methodData = [PTU.MethodData.basicCard];
-const details = PTU.Details.total60USD;
+const methodData = [{
+  supportedMethods: ["basic-card"],
+}];
+const details = {
+  total: {
+    label: "Total due",
+    amount: { currency: "USD", value: "60.00" },
+  },
+};
 
 add_task(async function test_show_abort_dialog() {
   await BrowserTestUtils.withNewTab({
     gBrowser,
     url: BLANK_PAGE_URL,
   }, async browser => {
     // start by creating a PaymentRequest, and show it
-    await ContentTask.spawn(browser, {methodData, details}, PTU.ContentTasks.createAndShowRequest);
+    await ContentTask.spawn(browser, {methodData, details}, ContentTasks.createAndShowRequest);
 
     // get a reference to the UI dialog and the requestId
     let win = await getPaymentWidget();
     let requestId = paymentUISrv.requestIdForWindow(win);
     ok(requestId, "requestId should be defined");
     is(win.closed, false, "dialog should not be closed");
 
     // abort the payment request
@@ -25,26 +32,27 @@ add_task(async function test_show_abort_
 
 add_task(async function test_show_manualAbort_dialog() {
   await BrowserTestUtils.withNewTab({
     gBrowser,
     url: BLANK_PAGE_URL,
   }, async browser => {
     let dialogReadyPromise = waitForWidgetReady();
     // start by creating a PaymentRequest, and show it
-    await ContentTask.spawn(browser, {methodData, details}, PTU.ContentTasks.createAndShowRequest);
+    await ContentTask.spawn(browser, {methodData, details}, ContentTasks.createAndShowRequest);
 
     // get a reference to the UI dialog and the requestId
     let [win] = await Promise.all([getPaymentWidget(), dialogReadyPromise]);
     ok(win, "Got payment widget");
     let requestId = paymentUISrv.requestIdForWindow(win);
     ok(requestId, "requestId should be defined");
     is(win.closed, false, "dialog should not be closed");
 
     // abort the payment request manually
     let frame = await getPaymentFrame(win);
     ok(frame, "Got payment frame");
     await dialogReadyPromise;
     info("dialog ready");
-    spawnPaymentDialogTask(frame, PTU.ContentTasks.manuallyClickCancel);
+    spawnPaymentDialogTask(frame, ContentTasks.manuallyClickCancel);
+
     await BrowserTestUtils.waitForCondition(() => win.closed, "dialog should be closed");
   });
 });
deleted file mode 100644
--- a/toolkit/components/payments/test/browser/browser_total.js
+++ /dev/null
@@ -1,18 +0,0 @@
-"use strict";
-
-/* eslint-disable mozilla/no-cpows-in-tests */
-add_task(async function test_total() {
-  const testTask = ({methodData, details}) => {
-    is(content.document.querySelector("#total > .value").textContent,
-       details.total.amount.value,
-       "Check total value");
-    is(content.document.querySelector("#total > .currency").textContent,
-       details.total.amount.currency,
-       "Check currency");
-  };
-  const args = {
-    methodData: [PTU.MethodData.basicCard],
-    details: PTU.Details.total60USD,
-  };
-  await spawnInDialogForMerchantTask(PTU.ContentTasks.createRequest, testTask, args);
-});
--- a/toolkit/components/payments/test/browser/head.js
+++ b/toolkit/components/payments/test/browser/head.js
@@ -3,34 +3,22 @@
 /* eslint
   "no-unused-vars": ["error", {
     vars: "local",
     args: "none",
     varsIgnorePattern: "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$",
   }],
 */
 
-
-const BLANK_PAGE_PATH = "/browser/toolkit/components/payments/test/browser/blank_page.html";
-const BLANK_PAGE_URL = "https://example.com" + BLANK_PAGE_PATH;
-
-const paymentSrv = Cc["@mozilla.org/dom/payments/payment-request-service;1"]
-                     .getService(Ci.nsIPaymentRequestService);
+const BLANK_PAGE_URL = "https://example.com/browser/toolkit/components/" +
+                       "payments/test/browser/blank_page.html";
+const PREF_PAYMENT_ENABLED = "dom.payments.request.enabled";
 const paymentUISrv = Cc["@mozilla.org/dom/payments/payment-ui-service;1"]
                      .getService().wrappedJSObject;
-const {PaymentTestUtils: PTU} = Cu.import("resource://testing-common/PaymentTestUtils.jsm", {});
 
-function getPaymentRequests() {
-  let requestsEnum = paymentSrv.enumerate();
-  let requests = [];
-  while (requestsEnum.hasMoreElements()) {
-    requests.push(requestsEnum.getNext().QueryInterface(Ci.nsIPaymentRequest));
-  }
-  return requests;
-}
 
 /**
  * Return the container (e.g. dialog or overlay) that the payment request contents are shown in.
  * This abstracts away the details of the widget used so that this can more earily transition from a
  * dialog to another kind of overlay.
  * Consumers shouldn't rely on a dialog window being returned.
  * @returns {Promise}
  */
@@ -43,17 +31,17 @@ async function getPaymentWidget() {
 
   return win;
 }
 
 async function getPaymentFrame(widget) {
   return widget.document.getElementById("paymentRequestFrame");
 }
 
-function waitForMessageFromWidget(messageType, widget = null) {
+async function waitForMessageFromWidget(messageType, widget = null) {
   info("waitForMessageFromWidget: " + messageType);
   return new Promise(resolve => {
     Services.mm.addMessageListener("paymentContentToChrome", function onMessage({data, target}) {
       if (data.messageType != messageType) {
         return;
       }
       if (widget && widget != target) {
         return;
@@ -68,99 +56,35 @@ function waitForMessageFromWidget(messag
 async function waitForWidgetReady(widget = null) {
   return waitForMessageFromWidget("paymentDialogReady", widget);
 }
 
 function spawnPaymentDialogTask(paymentDialogFrame, taskFn, args = null) {
   return ContentTask.spawn(paymentDialogFrame.frameLoader, args, taskFn);
 }
 
-async function withMerchantTab({browser = gBrowser, url = BLANK_PAGE_URL} = {
-  browser: gBrowser,
-  url: BLANK_PAGE_URL,
-}, taskFn) {
-  await BrowserTestUtils.withNewTab({
-    gBrowser: browser,
-    url,
-  }, taskFn);
-
-  paymentSrv.cleanup(); // Temporary measure until bug 1408234 is fixed.
-
-  await new Promise(resolve => {
-    SpecialPowers.exactGC(resolve);
-  });
-}
-
 /**
- * Load the privileged payment dialog wrapper document in a new tab and run the
- * task function.
- *
- * @param {string} requestId of the PaymentRequest
- * @param {Function} taskFn to run in the dialog with the frame as an argument.
- * @returns {Promise} which resolves when the dialog document is loaded
+ * Common content tasks functions to be used with ContentTask.spawn.
  */
-function withNewDialogFrame(requestId, taskFn) {
-  async function dialogTabTask(dialogBrowser) {
-    let paymentRequestFrame = dialogBrowser.contentDocument.getElementById("paymentRequestFrame");
-    // Ensure the inner frame is loaded
-    await spawnPaymentDialogTask(paymentRequestFrame, async function ensureLoaded() {
-      await ContentTaskUtils.waitForCondition(() => content.document.readyState == "complete",
-                                              "Waiting for the unprivileged frame to load");
-    });
-    await taskFn(paymentRequestFrame);
-  }
-
-  let args = {
-    gBrowser,
-    url: `chrome://payments/content/paymentDialog.xhtml?requestId=${requestId}`,
-  };
-  return BrowserTestUtils.withNewTab(args, dialogTabTask);
-}
+let ContentTasks = {
+  createAndShowRequest: async ({methodData, details, options}) => {
+    let rq = new content.PaymentRequest(methodData, details, options);
+    content.rq = rq; // assign it so we can retrieve it later
+    rq.show();
+  },
 
-/**
- * Spawn a content task inside the inner unprivileged frame of a privileged Payment Request dialog.
- *
- * @param {string} requestId
- * @param {Function} contentTaskFn
- * @param {object?} [args = null] for the content task
- * @returns {Promise}
- */
-function spawnTaskInNewDialog(requestId, contentTaskFn, args = null) {
-  return withNewDialogFrame(requestId, async function spawnTaskInNewDialog_tabTask(reqFrame) {
-    await spawnPaymentDialogTask(reqFrame, contentTaskFn, args);
-  });
-}
+  /**
+   * Click the cancel button
+   *
+   * Don't await on this task since the cancel can close the dialog before
+   * ContentTask can resolve the promise.
+   *
+   * @returns {undefined}
+   */
+  manuallyClickCancel: () => {
+    content.document.getElementById("cancel").click();
+  },
+};
 
-/**
- * Open a merchant tab with the given merchantTaskFn to create a PaymentRequest
- * and then open the associated PaymentRequest dialog in a new tab and run the
- * associated dialogTaskFn. The same taskArgs are passed to both functions.
- *
- * @param {Function} merchantTaskFn
- * @param {Function} dialogTaskFn
- * @param {Object} taskArgs
- * @param {Object} options
- * @param {string} options.origin
- */
-async function spawnInDialogForMerchantTask(merchantTaskFn, dialogTaskFn, taskArgs, {
-  origin = "https://example.com",
-} = {
-  origin: "https://example.com",
-}) {
-  await withMerchantTab({
-    url: origin + BLANK_PAGE_PATH,
-  }, async merchBrowser => {
-    await ContentTask.spawn(merchBrowser, taskArgs, merchantTaskFn);
-
-    const requests = getPaymentRequests();
-    is(requests.length, 1, "Should have one payment request");
-    let request = requests[0];
-    ok(!!request.requestId, "Got a payment request with an ID");
-
-    await spawnTaskInNewDialog(request.requestId, dialogTaskFn, taskArgs);
-  });
-}
 
 add_task(async function setup_head() {
-  SimpleTest.registerCleanupFunction(function cleanup() {
-    paymentSrv.cleanup();
-  });
+  await SpecialPowers.pushPrefEnv({set: [[PREF_PAYMENT_ENABLED, true]]});
 });