nfc-prompt-manual.https.html (1729B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>Web NFC: prompt closes when page reloads</title> 4 <link rel="help" href="https://w3c.github.io/web-nfc/"/> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <p> 8 This manual test checks that Web NFC prompt closes when page reloads. 9 </p> 10 <ol> 11 <li>Make sure NFC is disabled at system level</li> 12 <li>Click button to open Web NFC prompt</li> 13 <li>Accept first Web NFC prompt if needed</li> 14 <li>Wait 3 seconds when prompted about turning on the NFC adapter on the system level</li> 15 <li>Page reloads, click button if Web NFC prompt closed</li> 16 </ol> 17 <script> 18 19 promise_test(async (t) => { 20 if (window.location.search === "?didPromptClose") { 21 const button = document.createElement("button"); 22 button.textContent = "Did Web NFC prompt close?"; 23 24 await new Promise((resolve) => { 25 button.onclick = () => { 26 document.body.removeChild(button); 27 resolve(); 28 }; 29 document.body.appendChild(button); 30 }); 31 return; 32 } 33 34 const button = document.createElement("button"); 35 button.textContent = "Click to open Web NFC prompt"; 36 37 await new Promise((resolve) => { 38 button.onclick = () => { 39 document.body.removeChild(button); 40 resolve(); 41 }; 42 document.body.appendChild(button); 43 }); 44 45 // Web NFC prompt shows up. 46 const ndef = new NDEFReader(); 47 ndef.scan(); 48 49 // Wait 3 seconds to give time to user to accept first Web NFC prompt. 50 await new Promise((resolve) => setTimeout(resolve, 3000)); 51 52 // Reload page and manually check that Web NFC prompt closes. 53 window.location.search = "?didPromptClose"; 54 }, "Web NFC prompt should close when page reloads."); 55 56 </script>