Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TrustedTypes - injection sync API ref #37952

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hamishwillee
Copy link
Collaborator

This is update of injection sinks reference docs for TrustedTypes. I'm doing it for an FF release, so might not capture all of it.

Dependent (links to stuff added by #37917)

  • Document.write()
  • Document.writeln()
  • Element.innerHTML
  • ShadowRoot.innerHTML
  • More ... tbd

Draft, because I'm still working out an appropriate level of docs in ref vs cross linking to the overviews.

Related docs work in #37518

@github-actions github-actions bot added Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed labels Feb 4, 2025

In Edge only, calling `document.write()` more than once in an {{HTMLElement("iframe")}} causes the error "SCRIPT70: Permission denied".
We use the {{domxref("Window.trustedTypes")}} to access the global {{domxref("TrustedTypePolicyFactory")}}, and call its {{domxref("TrustedTypePolicyFactory/createPolicy","createPolicy()")}} method to define the sanitize function used for creating {{domxref("TrustedHTML")}} objects from text.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below here is stuff I am going to inject into the example.

Copy link
Contributor

github-actions bot commented Feb 4, 2025

Preview URLs

Flaws (1)

URL: /en-US/docs/Web/API/Document/write
Title: Document: write() method
Flaw count: 1

  • macros:
    • Macro produces link /en-US/docs/Web/HTML/Element/h1 which is a redirect
External URLs (2)

URL: /en-US/docs/Web/API/Document/write
Title: Document: write() method

(comment last updated: 2025-02-07 06:38:16)

Comment on lines 113 to 114
Using `document.write()` in [deferred](/en-US/docs/Web/HTML/Element/script#defer) or [asynchronous](/en-US/docs/Web/HTML/Element/script#async) scripts will be ignored and you'll get a message like "A call to `document.write()` from an asynchronously-loaded external script was ignored" in the error console.
Starting with version 55, Chrome will not execute `<script>` elements injected via `document.write()` when specific conditions are met. For more information, refer to [Intervening against document.write()](https://developer.chrome.com/blog/removing-document-write/).
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from old version. I have not verified it, but I expect it still to be true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant