| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script src="../resources/mojo-helpers.js"></script> | 4 <script src="../resources/mojo-helpers.js"></script> |
| 5 <script src="resources/mock-share-service.js"></script> | 5 <script src="resources/mock-share-service.js"></script> |
| 6 <script> | 6 <script> |
| 7 | 7 |
| 8 function getAbsoluteUrl(url) { | 8 function getAbsoluteUrl(url) { |
| 9 return new URL(url, location).toString(); | 9 return new URL(url, location).toString(); |
| 10 } | 10 } |
| 11 | 11 |
| 12 share_test((t, mock) => { | 12 share_test((t, webshare, mock) => { |
| 13 let url = 'https://www.example.com/some/path?some_query#some_fragment'; | 13 let url = 'https://www.example.com/some/path?some_query#some_fragment'; |
| 14 mock.pushShareResult('the title', 'the message', getAbsoluteUrl(url), null); | 14 mock.pushShareResult('the title', 'the message', getAbsoluteUrl(url), |
| 15 webshare.ShareError.OK); |
| 15 return callWithKeyDown(() => navigator.share( | 16 return callWithKeyDown(() => navigator.share( |
| 16 {title: 'the title', text: 'the message', url: url})); | 17 {title: 'the title', text: 'the message', url: url})); |
| 17 }, 'successful share'); | 18 }, 'successful share'); |
| 18 | 19 |
| 19 share_test((t, mock) => { | 20 share_test((t, webshare, mock) => { |
| 20 mock.pushShareResult('', '', '', null); | 21 mock.pushShareResult('', '', '', webshare.ShareError.OK); |
| 21 return callWithKeyDown(() => navigator.share({})); | 22 return callWithKeyDown(() => navigator.share({})); |
| 22 }, 'successful share with empty ShareData'); | 23 }, 'successful share with empty ShareData'); |
| 23 | 24 |
| 24 share_test((t, mock) => { | 25 share_test((t, webshare, mock) => { |
| 25 let url = '//www.example.com/some/path?some_query#some_fragment'; | 26 let url = '//www.example.com/some/path?some_query#some_fragment'; |
| 26 mock.pushShareResult('', '', getAbsoluteUrl(url), null); | 27 mock.pushShareResult('', '', getAbsoluteUrl(url), webshare.ShareError.OK); |
| 27 return callWithKeyDown(() => navigator.share({url: url})); | 28 return callWithKeyDown(() => navigator.share({url: url})); |
| 28 }, 'successful share with URL without a scheme'); | 29 }, 'successful share with URL without a scheme'); |
| 29 | 30 |
| 30 share_test((t, mock) => { | 31 share_test((t, webshare, mock) => { |
| 31 let url = '/some/path?some_query#some_fragment'; | 32 let url = '/some/path?some_query#some_fragment'; |
| 32 mock.pushShareResult('', '', getAbsoluteUrl(url), null); | 33 mock.pushShareResult('', '', getAbsoluteUrl(url), webshare.ShareError.OK); |
| 33 return callWithKeyDown(() => navigator.share({url: url})); | 34 return callWithKeyDown(() => navigator.share({url: url})); |
| 34 }, 'successful share with a path-only URL'); | 35 }, 'successful share with a path-only URL'); |
| 35 | 36 |
| 36 share_test((t, mock) => { | 37 share_test((t, webshare, mock) => { |
| 37 let url = 'foo'; | 38 let url = 'foo'; |
| 38 mock.pushShareResult('', '', getAbsoluteUrl(url), null); | 39 mock.pushShareResult('', '', getAbsoluteUrl(url), webshare.ShareError.OK); |
| 39 return callWithKeyDown(() => navigator.share({url: url})); | 40 return callWithKeyDown(() => navigator.share({url: url})); |
| 40 }, 'successful share with a relative URL'); | 41 }, 'successful share with a relative URL'); |
| 41 | 42 |
| 42 share_test((t, mock) => { | 43 share_test((t, webshare, mock) => { |
| 43 let url = ''; | 44 let url = ''; |
| 44 mock.pushShareResult('', '', getAbsoluteUrl(url), null); | 45 mock.pushShareResult('', '', getAbsoluteUrl(url), webshare.ShareError.OK); |
| 45 return callWithKeyDown(() => navigator.share({url: url})); | 46 return callWithKeyDown(() => navigator.share({url: url})); |
| 46 }, 'successful share with an empty URL'); | 47 }, 'successful share with an empty URL'); |
| 47 | 48 |
| 48 share_test((t, mock) => { | 49 share_test((t, webshare, mock) => { |
| 49 let url = 'data:foo'; | 50 let url = 'data:foo'; |
| 50 mock.pushShareResult('', '', getAbsoluteUrl(url), null); | 51 mock.pushShareResult('', '', getAbsoluteUrl(url), webshare.ShareError.OK); |
| 51 return callWithKeyDown(() => navigator.share({url: url})); | 52 return callWithKeyDown(() => navigator.share({url: url})); |
| 52 }, 'successful share with a data URL'); | 53 }, 'successful share with a data URL'); |
| 53 | 54 |
| 54 </script> | 55 </script> |
| OLD | NEW |