servo/tests/wpt/web-platform-tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest.https.sub.html
Ms2ger 296fa2512b Update web-platform-tests and CSS tests.
- Update CSS tests to revision e05bfd5e30ed662c2f8a353577003f8eed230180.
- Update web-platform-tests to revision a052787dd5c069a340031011196b73affbd68cd9.
2017-02-06 22:38:29 +01:00

38 lines
1.3 KiB
HTML

<!doctype html>
<title>PaymentRequest setting allowpaymentrequest after load and then navigating</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id="log"></div>
<script>
async_test((t) => {
const iframe = document.createElement('iframe');
// no allowpaymentrequest attribute
let i = 0;
const path = location.pathname.substring(0, location.pathname.lastIndexOf('/') + 1);
iframe.src = "https://{{domains[www1]}}:{{ports[https][0]}}" + path + "echo-PaymentRequest.html";
iframe.onload = t.step_func(() => {
if (i === 0) {
iframe.allowPaymentRequest = true;
}
iframe.contentWindow.postMessage('What is the result of new PaymentRequest(...)?', '*');
});
window.onmessage = t.step_func((e) => {
i++;
if (i === 1) {
assert_equals(e.data.message, 'Exception', 'before navigation');
assert_array_equals(e.data.details, [true /* ex instanceof DOMException*/, 18 /* ex.code */, 'SecurityError' /* ex.name */], 'before navigation');
// Navigate the iframe. This will fire a second 'load' event on the iframe.
iframe.contentWindow.location.href = iframe.src + '?2';
} else {
assert_equals(e.data.message, 'Success', 'after navigation');
t.done();
}
});
document.body.appendChild(iframe);
});
</script>