event-onclose.https.html (1336B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Notification.onclose (basic)</title> 4 <link rel="author" title="Apple Inc." href="http://www.apple.com/"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-vendor.js"></script> 9 <script> 10 promise_setup(() => { 11 return test_driver.set_permission({ name: "notifications" }, "granted") 12 }) 13 14 promise_test(async t => { 15 const notification = new Notification("New Email Received") 16 await new Promise(resolve => { 17 notification.onshow = resolve; 18 }) 19 notification.close() 20 const event = await new Promise(resolve => { 21 notification.onclose = resolve; 22 }) 23 assert_equals(Object.prototype.toString.call(event), "[object Event]") 24 assert_equals(event.type, "close", "Checked the event type.") 25 }, "Invoked the onclose event handler.") 26 27 promise_test(async t => { 28 const notification = new Notification("New Email Received") 29 notification.close() 30 const event = await new Promise((resolve) => { 31 notification.onclose = resolve; 32 notification.onerror = resolve 33 }) 34 assert_equals(event.type, "close", "Checked the event type.") 35 }, "Invoked the onclose event handler on immediate close.") 36 </script>