Bug 1465764 [wpt PR 11271] - Avoid uncaught exception in iframe if WebNFC is not supported, a=testonly
authorSimon Pieters <zcorpan@gmail.com>
Wed, 06 Jun 2018 17:41:12 +0000
changeset 422271 e5a51c261f1cd1a3ea043dafeb7358a8972bafda
parent 422270 938588f3dea76743c64be0a94e2df2677c66b75d
child 422272 3b88576150dfcb7024ed7b3003307462ce993572
push id34122
push userebalazs@mozilla.com
push dateMon, 11 Jun 2018 09:37:00 +0000
treeherdermozilla-central@9941eb8c3b29 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1465764, 11271, 11269
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/web-nfc/nfc_push.https.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -617219,17 +617219,17 @@
    "0577a5faa4d00fa8962a9d17b1404bf3822d910d",
    "manual"
   ],
   "web-nfc/nfc_insecure_context.html": [
    "a9fabb5e2f577581ff470924ee4c8c5f95c47f46",
    "testharness"
   ],
   "web-nfc/nfc_push.https.html": [
-   "ada53723b88641d04566f76f7af366f45ec783e9",
+   "6db968d910771fe1f4bcc1378eb45d0568c89071",
    "testharness"
   ],
   "web-nfc/nfc_push_ArrayBuffer-manual.https.html": [
    "acb2d28a5af18c96a234f4ff3312e7ea1831e23a",
    "manual"
   ],
   "web-nfc/nfc_push_DOMString-manual.https.html": [
    "7cdeafe31291135dd99eb956fc9c6ff1b76211c0",
--- a/testing/web-platform/tests/web-nfc/nfc_push.https.html
+++ b/testing/web-platform/tests/web-nfc/nfc_push.https.html
@@ -132,31 +132,35 @@ promise_test(t => {
 
 promise_test(t => {
   return promise_rejects(t, new TypeError(), navigator.nfc.cancelPush("invalid"));
 }, "nfc.cancelPush should fail with TypeError when invalid id value is provided.");
 
 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 => {
       if (message.data == 'Success') {
         resolve();
       } else if (message.data == 'Failure') {
         reject();
       }