Bug 1416967 - Support payment request development over file: with CSP and a debugging console. r=jaws

MozReview-Commit-ID: 3FgDhVN7IWR

--HG--
extra : rebase_source : d84170ea513eef432b55d5d03df18ddf584c5d2f
This commit is contained in:
Matthew Noorenberghe 2017-11-13 21:10:54 -08:00
Родитель fbd7ca1890
Коммит 9e0cf0c910
8 изменённых файлов: 62 добавлений и 10 удалений

Просмотреть файл

@ -2,7 +2,6 @@
module.exports = {
rules: {
"mozilla/balanced-listeners": "error",
"mozilla/var-only-at-top-level": "error",
"array-bracket-spacing": ["error", "never"],

Просмотреть файл

@ -14,12 +14,13 @@ 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,
})
``
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,
})
To open the debugging console in the dialog, use the keyboard shortcut **Ctrl-Alt-d (Ctrl-Option-d on macOS)**.
Communication with the DOM

Просмотреть файл

@ -9,4 +9,6 @@ toolkit.jar:
content/payments/paymentDialogFrameScript.js (content/paymentDialogFrameScript.js)
content/payments/paymentDialog.xhtml (content/paymentDialog.xhtml)
% resource payments %res/payments/
res/payments (res/paymentRequest.*)
res/payments (res/paymentRequest.*)
res/payments/debugging.html (res/debugging.html)
res/payments/debugging.js (res/debugging.js)

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE html>
<!-- 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>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">
<script src="debugging.js"></script>
</head>
<body>
<div>
<button id="refresh">Refresh</button>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,18 @@
/* 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/. */
let buttonActions = {
refresh() {
window.parent.location.reload(true);
},
};
window.addEventListener("click", function onButtonClick(evt) {
let id = evt.target.id;
if (!id || typeof(buttonActions[id]) != "function") {
return;
}
buttonActions[id]();
});

Просмотреть файл

@ -6,6 +6,10 @@ html {
background: -moz-dialog;
}
#debugging-console {
float: right;
}
#total {
border: 1px solid black;
margin: 5px;

Просмотреть файл

@ -18,6 +18,8 @@ let PaymentRequest = {
// listen to content
window.addEventListener("paymentChromeToContent", this);
window.addEventListener("keypress", this);
this.domReadyPromise = new Promise(function dcl(resolve) {
window.addEventListener("DOMContentLoaded", resolve, {once: true});
}).then(this.handleEvent.bind(this));
@ -41,6 +43,14 @@ let PaymentRequest = {
}
break;
}
case "keypress": {
if (event.code != "KeyD" || !event.altKey || !event.ctrlKey) {
break;
}
let debuggingConsole = document.getElementById("debugging-console");
debuggingConsole.hidden = !debuggingConsole.hidden;
break;
}
case "unload": {
this.onPaymentRequestUnload();
break;

Просмотреть файл

@ -5,11 +5,13 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'"/>
<title></title>
<link rel="stylesheet" href="resource://payments/paymentRequest.css" />
<script src="resource://payments/paymentRequest.js"></script>
<link rel="stylesheet" href="paymentRequest.css"/>
<script src="paymentRequest.js"></script>
</head>
<body>
<iframe id="debugging-console" hidden="hidden" src="debugging.html"></iframe>
<div id="host-name"></div>
<div id="total">