Skip to content

Commit a6087b9

Browse files
committed
Test that PaymentRequest throws when its document is not active
See whatwg/html#2160 w3c/payment-request#361
1 parent 04b3b0d commit a6087b9

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!doctype html>
2+
<title>PaymentRequest &lt;iframe allowpaymentrequest> in non-active document</title>
3+
<script src=/resources/testharness.js></script>
4+
<script src=/resources/testharnessreport.js></script>
5+
<script src=/common/utils.js></script>
6+
<iframe id="iframe" allowpaymentrequest></iframe>
7+
<script>
8+
async_test((t) => {
9+
const iframe = document.getElementById('iframe');
10+
const paymentArgs = [[{supportedMethods: ['foo']}], {total: {label: 'label', amount: {currency: 'USD', value: '5.00'}}}];
11+
12+
onload = () => {
13+
const win = window[0];
14+
const grabbedPaymentRequest = win.PaymentRequest;
15+
win.location.href = make_absolute_url({
16+
hostname: '{{domains[www1]}}',
17+
path: '/common/blank.html'
18+
});
19+
iframe.onload = t.step_func_done(() => {
20+
assert_throws({name: 'SecurityError'}, () => {
21+
new grabbedPaymentRequest(...paymentArgs);
22+
});
23+
});
24+
}
25+
});
26+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
<title>PaymentRequest &lt;iframe allowpaymentrequest> basic</title>
3+
<script src=/resources/testharness.js></script>
4+
<script src=/resources/testharnessreport.js></script>
5+
<iframe id="iframe" allowpaymentrequest></iframe>
6+
<script>
7+
async_test((t) => {
8+
const iframe = document.getElementById('iframe');
9+
const paymentArgs = [[{supportedMethods: ['foo']}], {total: {label: 'label', amount: {currency: 'USD', value: '5.00'}}}];
10+
11+
onload = t.step_func_done(() => {
12+
new window[0].PaymentRequest(...paymentArgs);
13+
});
14+
});
15+
</script>

0 commit comments

Comments
 (0)