зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1465764 [wpt PR 11271] - Avoid uncaught exception in iframe if WebNFC is not supported, a=testonly
Automatic update from web-platform-testsAvoid uncaught exception in iframe if WebNFC is not supported (#11271) Part of #11269. -- wpt-commits: dcdd59c1c0902c1a3fa79ab4ead6321f26ddc4bd wpt-pr: 11271
This commit is contained in:
Родитель
769d97acf1
Коммит
e7d5ca782f
|
@ -617224,7 +617224,7 @@
|
|||
"testharness"
|
||||
],
|
||||
"web-nfc/nfc_push.https.html": [
|
||||
"ada53723b88641d04566f76f7af366f45ec783e9",
|
||||
"6db968d910771fe1f4bcc1378eb45d0568c89071",
|
||||
"testharness"
|
||||
],
|
||||
"web-nfc/nfc_push_ArrayBuffer-manual.https.html": [
|
||||
|
|
|
@ -137,21 +137,25 @@ promise_test(t => {
|
|||
promise_test(() => {
|
||||
return new Promise((resolve,reject) => {
|
||||
let iframe = document.createElement('iframe');
|
||||
iframe.srcdoc = '<script>' +
|
||||
' window.onmessage = message => {' +
|
||||
' if (message.data === "Ready") {' +
|
||||
' let onSuccess = () => { parent.postMessage("Failure", "*"); };' +
|
||||
' let onError = error => {' +
|
||||
' if (error.name == "SecurityError") {' +
|
||||
' parent.postMessage("Success", "*");' +
|
||||
' } else {' +
|
||||
' parent.postMessage("Failure", "*");' +
|
||||
' }' +
|
||||
' };' +
|
||||
' navigator.nfc.push("Test").then(onSuccess, onError);' +
|
||||
' }' +
|
||||
' };' +
|
||||
'<\/script>';
|
||||
iframe.srcdoc = `<script>
|
||||
window.onmessage = message => {
|
||||
if (message.data === "Ready") {
|
||||
let onSuccess = () => { parent.postMessage("Failure", "*"); };
|
||||
let onError = error => {
|
||||
if (error.name == "SecurityError") {
|
||||
parent.postMessage("Success", "*");
|
||||
} else {
|
||||
parent.postMessage("Failure", "*");
|
||||
}
|
||||
};
|
||||
try {
|
||||
navigator.nfc.push("Test").then(onSuccess, onError);
|
||||
} catch(e) {
|
||||
parent.postMessage("Failure", "*");
|
||||
}
|
||||
}
|
||||
};
|
||||
<\/script>`;
|
||||
iframe.onload = () => iframe.contentWindow.postMessage('Ready', '*');
|
||||
document.body.appendChild(iframe);
|
||||
window.onmessage = message => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче