content icon indicating copy to clipboard operation
content copied to clipboard

Navigator: share() live example missing permission

Open Josh-Cena opened this issue 1 year ago • 7 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share

What specific section or headline is this issue about?

Sharing a URL

What information was incorrect, unhelpful, or incomplete?

Example shows "Error: NotAllowedError: Third-party iframes are not allowed to call share() unless explicitly allowed via Feature-Policy (web-share)"

What did you expect to see?

Working example

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
  • Folder: en-us/web/api/navigator/share
  • MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share
  • GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/navigator/share/index.md
  • Last commit: https://github.com/mdn/content/commit/0f20b09ca00bc43ff68a212a4c9aa6a81bd0bd40
  • Document last modified: 2023-10-30T22:09:50.000Z

Josh-Cena avatar Feb 05 '24 20:02 Josh-Cena

This has to move to yari as there is no way for an author to set the permissions on an example.

Edit. And in the meantime we should perhaps add a note about the error to the page. Note that when I say "in the meantime" I mean "forever" - we've got years-old issues on yari related to this same kind of problem.

hamishwillee avatar Feb 05 '24 21:02 hamishwillee

Hmmm, I vividly remember there's a macro parameter that allows you to do this, but I haven't payed attention to related errors in a long time.

Josh-Cena avatar Feb 05 '24 23:02 Josh-Cena

It looks like you're right - we should document this in https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Page_structures/Live_samples

Do you happen to know if you can use comma separation with no value to specify no values for the other items? i.e. do I have to specify all items between 0 and 6 in order to specify the feature?

// Parameters:
//  $0 - The ID of the header block containing the sample
//  $1 - The width of the iframe (optional)
//  $2 - The height of the iframe (optional)
//  $3 - The url of a screenshot of the sample working as intended (optional)
//  $4 - (Deprecated) The slug from which to load the sample (optional; current page used if not provided)
//  $5 - (Deprecated) The class name of the frame; defaults to "sample-code-frame". If you
//       pass this parameter and give it a value other than "sample-code-frame",
//       then the "Open in CodePen"/"Open in JSFiddle" buttons will not be displayed.
//  $6 - Allowed features (like geolocation, microphone), separated by semicolons (optional).
//       Defaults to ''.

hamishwillee avatar Feb 06 '24 01:02 hamishwillee

@hamishwillee I think it's basically a JS function call. You can use "" as a placeholder, and it will not be called out as using deprecated params. These was a discussion about removing these parameters.

Josh-Cena avatar Feb 06 '24 01:02 Josh-Cena

related? https://github.com/mdn/content/issues/23403

wbamberg avatar Feb 06 '24 02:02 wbamberg

Yeah, could be. I was using Safari on ipad, so I think there's no compatibility issues.

Josh-Cena avatar Feb 06 '24 15:02 Josh-Cena

Fixed by #32244. Specifying web-share as the option to the macro works on chrome and FF (when feature enabled), at least on the PR server.

hamishwillee avatar Feb 13 '24 00:02 hamishwillee