зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1381186 - add show/abort chrome test. r=MattN
MozReview-Commit-ID: I6Umm24nNvA --HG-- extra : rebase_source : 8c6b5c08280a5bd1da971718b90cdf818ad0ec65
This commit is contained in:
Родитель
759140610e
Коммит
2f52051a3e
|
@ -399,8 +399,10 @@
|
||||||
@RESPATH@/components/nsSearchService.js
|
@RESPATH@/components/nsSearchService.js
|
||||||
@RESPATH@/components/nsSearchSuggestions.js
|
@RESPATH@/components/nsSearchSuggestions.js
|
||||||
@RESPATH@/components/nsSidebar.js
|
@RESPATH@/components/nsSidebar.js
|
||||||
|
#ifdef NIGHTLY_BUILD
|
||||||
@RESPATH@/components/payments.manifest
|
@RESPATH@/components/payments.manifest
|
||||||
@RESPATH@/components/paymentUIService.js
|
@RESPATH@/components/paymentUIService.js
|
||||||
|
#endif
|
||||||
@RESPATH@/components/passwordmgr.manifest
|
@RESPATH@/components/passwordmgr.manifest
|
||||||
@RESPATH@/components/nsLoginInfo.js
|
@RESPATH@/components/nsLoginInfo.js
|
||||||
@RESPATH@/components/nsLoginManager.js
|
@RESPATH@/components/nsLoginManager.js
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Blank page</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
BLANK PAGE
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,4 +1,10 @@
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
|
head = head.js
|
||||||
|
|
||||||
support-files =
|
support-files =
|
||||||
|
blank_page.html
|
||||||
|
|
||||||
[browser_request_summary.js]
|
[browser_request_summary.js]
|
||||||
|
[browser_show_dialog.js]
|
||||||
|
# Bug 1365964 - Payment Request isn't implemented for non-e10s
|
||||||
|
skip-if = !e10s
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
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}, ContentTasks.createAndShowRequest);
|
||||||
|
|
||||||
|
// get a reference to the UI dialog and the requestId
|
||||||
|
let win = await getDialogWindow();
|
||||||
|
let requestId = requestIdForWindow(win);
|
||||||
|
ok(requestId, "requestId should be defined");
|
||||||
|
ok(!win.closed, "dialog should not be closed");
|
||||||
|
|
||||||
|
// abort the payment request
|
||||||
|
await ContentTask.spawn(browser, null, async() => content.rq.abort());
|
||||||
|
ok(win.closed, "dialog should be closed");
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,49 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/* eslint
|
||||||
|
"no-unused-vars": ["error", {
|
||||||
|
vars: "local",
|
||||||
|
args: "none",
|
||||||
|
varsIgnorePattern: "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$",
|
||||||
|
}],
|
||||||
|
*/
|
||||||
|
|
||||||
|
const REQUEST_ID_PREFIX = "paymentRequest-";
|
||||||
|
const BLANK_PAGE_URL = "https://example.com/browser/toolkit/components/" +
|
||||||
|
"payments/test/browser/blank_page.html";
|
||||||
|
const PREF_PAYMENT_ENABLED = "dom.payments.request.enabled";
|
||||||
|
|
||||||
|
|
||||||
|
async function getDialogWindow() {
|
||||||
|
let win;
|
||||||
|
await BrowserTestUtils.waitForCondition(() => {
|
||||||
|
win = Services.wm.getMostRecentWindow(null);
|
||||||
|
return win.name.startsWith(REQUEST_ID_PREFIX);
|
||||||
|
}, "payment dialog should be the most recent");
|
||||||
|
|
||||||
|
return win;
|
||||||
|
}
|
||||||
|
|
||||||
|
function requestIdForWindow(window) {
|
||||||
|
let windowName = window.name;
|
||||||
|
|
||||||
|
return windowName.startsWith(REQUEST_ID_PREFIX) ?
|
||||||
|
windowName.replace(REQUEST_ID_PREFIX, "") : // returns suffix, which is the requestId
|
||||||
|
null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common content tasks functions to be used with ContentTask.spawn.
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
add_task(async function setup_head() {
|
||||||
|
await SpecialPowers.pushPrefEnv({set: [[PREF_PAYMENT_ENABLED, true]]});
|
||||||
|
});
|
Загрузка…
Ссылка в новой задаче