Bug 1427939 - Fix console logging line numbers for paymentRequest.xhtml over HTTP. r=sfoster
This fixes the console output to show the lines the log comes from which eases debugging.
* Also fix a leftover unused argument always getting logged.
MozReview-Commit-ID: 1YxrrinWta2
--- a/toolkit/components/payments/res/paymentRequest.js
+++ b/toolkit/components/payments/res/paymentRequest.js
@@ -50,37 +50,37 @@ var paymentRequest = {
}
default: {
throw new Error("Unexpected event type");
}
}
},
sendMessageToChrome(messageType, detail = {}) {
- log.debug("sendMessageToChrome: ", messageType, detail);
+ log.debug("sendMessageToChrome:", messageType, detail);
let event = new CustomEvent("paymentContentToChrome", {
bubbles: true,
detail: Object.assign({
messageType,
}, detail),
});
document.dispatchEvent(event);
},
toggleDebuggingConsole() {
let debuggingConsole = document.getElementById("debugging-console");
- if (!debuggingConsole.src) {
+ if (debuggingConsole.hidden && !debuggingConsole.src) {
debuggingConsole.src = "debugging.html";
}
debuggingConsole.hidden = !debuggingConsole.hidden;
},
onChromeToContent({detail}) {
let {messageType} = detail;
- log.debug("onChromeToContent: ", messageType);
+ log.debug("onChromeToContent:", messageType);
switch (messageType) {
case "responseSent": {
document.querySelector("payment-dialog").requestStore.setState({
changesPrevented: true,
completionState: "processing",
});
break;
@@ -91,18 +91,18 @@ var paymentRequest = {
}
case "updateState": {
document.querySelector("payment-dialog").setStateFromParent(detail);
break;
}
}
},
- onPaymentRequestLoad(requestId) {
- log.debug("onPaymentRequestLoad:", requestId);
+ onPaymentRequestLoad() {
+ log.debug("onPaymentRequestLoad");
window.addEventListener("unload", this, {once: true});
this.sendMessageToChrome("paymentDialogReady");
// Automatically show the debugging console if loaded with a truthy `debug` query parameter.
if (new URLSearchParams(location.search).get("debug")) {
this.toggleDebuggingConsole();
}
},
--- a/toolkit/components/payments/res/unprivileged-fallbacks.js
+++ b/toolkit/components/payments/res/unprivileged-fallbacks.js
@@ -1,36 +1,29 @@
/* 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/. */
/**
* This file defines fallback objects to be used during development outside
* of the paymentDialogWrapper. When loaded in the wrapper, a frame script
- * overwrites these methods.
+ * overwrites these methods. Since these methods need to get overwritten in the
+ * global scope, it can't be converted into an ES module.
*/
/* eslint-disable no-console */
/* exported log, PaymentDialogUtils */
"use strict";
var log = {
- error(...args) {
- console.error("log.js", ...args);
- },
- warn(...args) {
- console.warn("log.js", ...args);
- },
- info(...args) {
- console.info("log.js", ...args);
- },
- debug(...args) {
- console.debug("log.js", ...args);
- },
+ error: console.error.bind(console, "paymentRequest.xhtml:"),
+ warn: console.warn.bind(console, "paymentRequest.xhtml:"),
+ info: console.info.bind(console, "paymentRequest.xhtml:"),
+ debug: console.debug.bind(console, "paymentRequest.xhtml:"),
};
var PaymentDialogUtils = {
getAddressLabel(address) {
return `${address.name} (${address.guid})`;
},
isCCNumber(str) {
return str.length > 0;