| <!DOCTYPE html> | 
 | <script src="../resources/testharness.js"></script> | 
 | <script src="../resources/testharnessreport.js"></script> | 
 | <script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script> | 
 | <script src="file:///gen/third_party/blink/public/platform/modules/webshare/webshare.mojom.js"></script> | 
 | <script src="resources/mock-share-service.js"></script> | 
 | <script> | 
 |  | 
 | async function assertRejectsWithError(promise, name) { | 
 |   try { | 
 |     await promise; | 
 |     assert_unreached('expected promise to reject with ' + name); | 
 |   } catch (error) { | 
 |     assert_equals(error.name, name); | 
 |   } | 
 | } | 
 |  | 
 | share_test(mock => { | 
 |   mock.pushShareResult('the title', 'the message', 'data:the url', | 
 |                        blink.mojom.ShareError.CANCELED); | 
 |   return callWithKeyDown(() => assertRejectsWithError( | 
 |       navigator.share({ | 
 |           title: 'the title', | 
 |           text: 'the message', | 
 |           url: 'data:the url' | 
 |       }), | 
 |       'AbortError')); | 
 | }, 'share with user cancellation'); | 
 |  | 
 | share_test(mock => { | 
 |   mock.pushShareResult('the title', 'the message', 'data:the url', | 
 |                        blink.mojom.ShareError.INTERNAL_ERROR); | 
 |   return callWithKeyDown(() => assertRejectsWithError( | 
 |       navigator.share({ | 
 |           title: 'the title', | 
 |           text: 'the message', | 
 |           url: 'data:the url' | 
 |       }), | 
 |       'AbortError')); | 
 | }, 'share with invalid url template'); | 
 |  | 
 | </script> |