Bug 1654227 - enable WPT + mochitests again for Web Payments r=kamidphish

Re-enable the tests... there are some painful fails but we should deal with them on a case by case basis.

Differential Revision: https://phabricator.services.mozilla.com/D84332
This commit is contained in:
Marcos Cáceres 2020-07-24 05:14:04 +00:00
Родитель 132ea835ae
Коммит 4b7144c3a5
18 изменённых файлов: 147 добавлений и 142 удалений

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

@ -832,7 +832,7 @@ already_AddRefed<Promise> PaymentRequest::Abort(ErrorResult& aRv) {
}
if (mState != eInteractive) {
aRv.ThrowSecurityError(
aRv.ThrowInvalidStateError(
"The PaymentRequest's state should be 'Interactive'");
return nullptr;
}

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

@ -3,7 +3,7 @@ prefs =
dom.payments.request.enabled=true
# skip-if !e10s will be removed once non-e10s is supported
# Android crashes on nearly all tests, bug 1525959
skip-if = !e10s || !nightly_build || toolkit == 'android' || true # we don't ship webpayments right now bug 1514425
skip-if = !e10s || !nightly_build || toolkit == 'android'
scheme = https
support-files =
blank_page.html

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

@ -8,9 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345367
<title>Test for Bug 1345367</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript">
"use strict";
<script>
SimpleTest.waitForExplicitFinish();
var gUrl = SimpleTest.getTestFileURL('GeneralChromeScript.js');
@ -29,61 +27,61 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345367
},
};
function testBeforeShow() {
return new Promise((resolve, reject) => {
const payRequest = new PaymentRequest(defaultMethods, defaultDetails);
payRequest.abort().then((result) => {
ok(false, "Should throw 'InvalidStateError', but got resolved.");
resolve();
}).catch((err) => {
is(err.name, "InvalidStateError",
"Expected 'InvalidStateError', but got '" + err.name + "'");
resolve();
});
});
async function testBeforeShow() {
const payRequest = new PaymentRequest(defaultMethods, defaultDetails);
try {
await payRequest.abort();
ok(false, "Should throw 'InvalidStateError', but got resolved.");
} catch (err) {
console.log(err)
is(err.name, "InvalidStateError", "Expected 'InvalidStateError', but got '" + err.name + "'");
}
}
function testAfterShow() {
const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
return new Promise((resolve, reject) => {
const payRequest = new PaymentRequest(defaultMethods, defaultDetails);
const acceptPromise = payRequest.show();
payRequest.abort().then((abortResult) => {
is(abortResult, undefined, "Should be resolved with undefined.");
resolve();
}).catch( (err) => {
ok(false, "Expected no error, but got '" + err.name + "'.");
resolve();
}).finally(handler.destruct);
});
async function testAfterShow() {
const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
const payRequest = new PaymentRequest(defaultMethods, defaultDetails);
const acceptPromise = payRequest.show();
try {
const abortResult = await payRequest.abort();
is(abortResult, undefined, "Should be resolved with undefined.");
} catch (err) {
ok(false, "Expected no error, but got '" + err.name + "'.");
} finally {
handler.destruct();
}
}
function teardown() {
gScript.addMessageListener("teardown-complete", function teardownCompleteHandler() {
gScript.removeMessageListener("teardown-complete", teardownCompleteHandler);
gScript.destroy();
SimpleTest.finish();
return new Promise(resolve => {
gScript.addMessageListener("teardown-complete", function teardownCompleteHandler() {
gScript.removeMessageListener("teardown-complete", teardownCompleteHandler);
gScript.destroy();
resolve();
});
gScript.sendAsyncMessage("teardown");
});
gScript.sendAsyncMessage("teardown");
}
function runTests() {
testBeforeShow()
.then(testAfterShow)
.then(teardown)
.catch( e => {
async function runTests() {
try{
await testBeforeShow();
await testAfterShow();
} catch(e) {
ok(false, "Unexpected error: " + e.name);
SimpleTest.finish();
});
} finally {
await teardown();
}
}
window.addEventListener('load', function() {
SpecialPowers.pushPrefEnv({
window.addEventListener('load', async () => {
await SpecialPowers.pushPrefEnv({
'set': [
['dom.payments.request.enabled', true],
]
}, runTests);
});
await runTests();
SimpleTest.finish();
});
</script>

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

@ -8,10 +8,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1408234
<title>Test for closing PaymentRequest</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="DefaultData.js"></script>
<script type="application/javascript">
"use strict";
<script src="DefaultData.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
var gUrl = SimpleTest.getTestFileURL('ClosePaymentChromeScript.js');
@ -146,48 +144,57 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1408234
async function testUpdateWithRespondedPayment() {
const testName = "testUpdateWithRespondedPayment";
await requestChromeAction("test-setup", testName);
return new Promise(resolve => {
let nextStatus = ["creating", "showing", "closing", "updating", "finishing"];
let currStatus = nextStatus.shift();
let ifr = document.createElement('iframe');
let handler = undefined;
let listener = async function(event) {
is(event.data, "successful",
`${testName}: Expected 'successful' when ${currStatus}, but got '${event.data}'.`);
switch (currStatus) {
case "creating":
handler = SpecialPowers.getDOMWindowUtils(ifr.contentWindow).setHandlingUserInput(true);
ifr.contentWindow.postMessage("show PaymentRequest", "*");
break;
case "showing":
await requestChromeAction("update-payment");
break;
case "closing":
await requestChromeAction("reject-payment", false);
break;
case "updating":
await requestChromeAction("close-check");
ifr.contentWindow.postMessage("updateWith PaymentRequest", "*");
break;
case "finishing":
handler.destruct();
document.body.removeChild(ifr);
window.removeEventListener("message", listener);
resolve();
break;
default:
ok(false, testName + ": Unknown status()" + currStatus);
break;
}
currStatus = nextStatus.shift();
}
window.addEventListener("message", listener);
ifr.src = "simple_payment_request.html";
document.body.appendChild(ifr);
const nextStatus = ["creating", "showing", "closing", "updating", "finishing"];
const ifr = document.createElement('iframe');
let finishResolver;
let finishRejector;
const finishedPromise = new Promise(async (res, rej) => {
finishResolver = res;
finishRejector = rej;
});
let handler;
const listener = async event => {
const currStatus = nextStatus.shift();
is(event.data, "successful",
`${testName}: Expected 'successful' when ${currStatus}, but got '${event.data}'.`);
switch (currStatus) {
case "creating":
ifr.contentWindow.postMessage("show PaymentRequest", "*");
handler = SpecialPowers.getDOMWindowUtils(ifr.contentWindow).setHandlingUserInput(true);
break;
case "showing":
await requestChromeAction("update-payment");
break;
case "closing":
await requestChromeAction("reject-payment", false);
break;
case "updating":
await requestChromeAction("close-check");
ifr.contentWindow.postMessage("updateWith PaymentRequest", "*");
break;
case "finishing":
finishResolver();
break;
default:
const msg = `${testName}: Unknown status() ${currStatus}`;
ok(false, msg);
finishRejector(new Error(msg));
break;
}
}
window.addEventListener("message", listener);
ifr.src = "simple_payment_request.html";
document.body.appendChild(ifr);
await new Promise(loadResolve => {
ifr.onload = loadResolve;
});
await finishedPromise;
handler.destruct();
document.body.removeChild(ifr);
window.removeEventListener("message", listener);
}
function getLoadedPaymentRequest(iframe, url) {
function getLoadedPaymentRequest(iframe, url = "blank_page.html") {
return new Promise(resolve => {
iframe.addEventListener(
"load",
@ -202,42 +209,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1408234
});
}
async function testNonfullyActivePayment() {
const testName = "testNonfullyActivePayment";
await requestChromeAction("test-setup", testName);
return new Promise(async (resolve) => {
const outer = document.createElement("iframe");
outer.allowPaymentRequest = true;
document.body.appendChild(outer);
await getLoadedPaymentRequest(outer,"blank_page.html");
const inner = outer.contentDocument.createElement("iframe");
inner.allowPaymentRequest = true;
outer.contentDocument.body.appendChild(inner);
const request = await getLoadedPaymentRequest(inner,"blank_page.html");
ok(request, `${testName}: PaymentRequest in inner iframe should exist.`);
await new Promise(res => {
outer.addEventListener("load", res);
outer.src = "simple_payment_request.html";
});
let handler = SpecialPowers.getDOMWindowUtils(inner.contentWindow).setHandlingUserInput(true);
try {
const showPromise = await request.show();
ok(false, `${testName}: expected 'AbortError', but got resolved.`);
} catch (error) {
is(error.name, "AbortError",
`${testName}: expected 'AbortError'.`);
}
await handler.destruct();
inner.remove();
outer.remove();
resolve();
});
}
async function teardown() {
return new Promise((resolve) => {
gScript.addMessageListener("teardown-complete", function teardownCompleteHandler() {
@ -259,7 +230,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1408234
await testCloseByRedirectingAfterShow();
await testCloseByRemovingIframe();
await testUpdateWithRespondedPayment();
await testNonfullyActivePayment();
await teardown();
} catch(e) {
ok(false, "test_closePayment.html: Unexpected error: " + e.name);

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

@ -1,3 +1 @@
implementation-status: backlog
prefs: [dom.payments.request.enabled:true]
disabled: true # https://bugzilla.mozilla.org/show_bug.cgi?id=1514425

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

@ -1,5 +1,5 @@
[active-document-cross-origin.https.sub.html]
[PaymentRequest <iframe allowpaymentrequest> in non-active document (cross-origin)]
expected:
if not e10s: FAIL
FAIL

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

@ -1,5 +1,4 @@
[active-document-same-origin.https.html]
[PaymentRequest <iframe allowpaymentrequest> in non-active document (same-origin)]
expected:
if not e10s: FAIL
FAIL

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

@ -1,4 +1,5 @@
[removing-allowpaymentrequest.https.sub.html]
[PaymentRequest removing allowpaymentrequest after load and then navigating]
expected: FAIL
expected:
if not e10s: FAIL

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

@ -0,0 +1,5 @@
[setting-allowpaymentrequest-timing.https.sub.html]
[PaymentRequest setting allowpaymentrequest after document creation, before response]
expected:
FAIL

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

@ -1,4 +1,4 @@
[setting-allowpaymentrequest.https.sub.html]
[PaymentRequest setting allowpaymentrequest after load and then navigating]
expected: FAIL
expected:
if not e10s: FAIL

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

@ -433,3 +433,10 @@
expected:
if not e10s: FAIL
[PaymentRequest interface: operation hasEnrolledInstrument()]
expected:
FAIL
[PaymentRequest interface: paymentRequest must inherit property "hasEnrolledInstrument()" with the proper type]
expected:
FAIL

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

@ -0,0 +1,8 @@
[interfaces.https.html]
[PaymentRequest interface: operation hasEnrolledInstrument()]
expected:
FAIL
[PaymentRequest interface: new PaymentRequest([{supportedMethods: 'foo'}\], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} }) must inherit property "hasEnrolledInstrument()" with the proper type]
expected:
FAIL

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

@ -1,6 +1,6 @@
[payment-is-showing.https.html]
disabled:
if os == "android" and not e10s: https://bugzilla.mozilla.org/show_bug.cgi?id=1526265
TRUE # https://bugzilla.mozilla.org/show_bug.cgi?id=1654223
expected:
if debug and not e10s and (os == "linux"): OK
TIMEOUT

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

@ -4,21 +4,16 @@
if not e10s: FAIL
[Test for PaymentRequest.abort() method]
expected: FAIL
expected:
if not e10s: FAIL
[Calling abort() multiple times is always a new object.]
expected:
if not e10s: FAIL
[Test for PaymentRequest.abort() method 1]
expected: FAIL
[The same request cannot be shown multiple times.]
expected: FAIL
[aborting a request before it is shown doesn't prevent it from being shown later.]
expected: FAIL
[Aborting a request before it is shown doesn't prevent it from being shown later.]
expected: FAIL

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

@ -1,4 +1,5 @@
[payment-request-hasenrolledinstrument-method.tentative.https.html]
[If request.[[state\]\] is "interactive", then return a promise rejected with an "InvalidStateError" DOMException.]
expected: FAIL

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

@ -0,0 +1,17 @@
[payment-request-show-method.https.html]
[Throws if the promise [[state\]\] is not 'created'.]
expected:
FAIL
[If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException.]
expected:
FAIL
[If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException.]
expected:
FAIL
[Calling show() multiple times always returns a new promise.]
expected:
FAIL

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

@ -8,6 +8,9 @@
<script src='/resources/testdriver-vendor.js'></script>
<script>
"use strict";
setup({ allow_uncaught_exception: true });
const unsupportedMethods = [
{ supportedMethods: "this-is-not-supported" },
{ supportedMethods: "https://not.supported" },

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

@ -8,6 +8,9 @@
<script src="/resources/testdriver-vendor.js"></script>
<script>
"use strict";
setup({ allow_uncaught_exception: true });
const defaultMethods = Object.freeze([
{ supportedMethods: "basic-card" },
{