blob: ba747828421385bb21ec8060390222623c48debb [file] [log] [blame]
<!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>
function getAbsoluteUrl(url) {
return new URL(url, document.baseURI).toString();
}
share_test(mock => {
mock.pushShareResult('true', 'the object', getAbsoluteUrl('384957'),
blink.mojom.ShareError.OK);
const objectWithToString = {toString() { return 'the object'; }};
return callWithKeyDown(() => navigator.share(
{title: true, text: objectWithToString, url: 384957}));
}, 'share of types other than string (expect implicitly converted to string)');
share_test(mock => {
// null fields should convert into the string 'null' (because the field is
// not nullable, it just converts to a string like any other type).
mock.pushShareResult('null', '', getAbsoluteUrl('null'),
blink.mojom.ShareError.OK);
return callWithKeyDown(() => navigator.share(
{title: null, text: undefined, url: null}));
}, 'share of null/undefined dict values');
</script>