Visible Text within DOM Integrity
Summary
This document describes a format for ensuring the integrity of the rendered text of target elements.
Terminology
For terms not explained in this document, please see Terminology.
- Content Attestation (CA)
Visible Text Target Format
Below is a format of Visible Text Target.
{
"type": "VisibleTextTargetIntegrity",
"cssSelector": "<CSS Selector>",
"integrity": "sha256-GtNUUolQVlwIkQU9JknWkwkhfdiVmHr/BOnLFFHC5jI="
}
JSON Schema
{
"title": "Visible Text Target",
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["VisibleTextTargetIntegrity"]
},
"integrity": {
"type": "string"
},
"cssSelector": {
"type": "string"
}
},
"additionalProperties": true,
"required": ["type", "integrity", "cssSelector"]
}
Property
- The type of Content Integrity Descriptor. It MUST be
VisibleTextTargetIntegrity. integrity: REQUIRED. It MUST be thesriStringdata type. For available hash functions, it MUST conform to Hash Algorithm. Example:sha256-4HLmAAYVRClrk+eCIrI1Rlf5/IKK0+wGoYjRs9vzl7U=cssSelector: REQUIRED. It MUST be a CSS Selector (Selectors Level 3).
Validation Process
- Searches for an element specified by a CSS selector in the
cssSelectorproperty. The target element is searched for using thequerySelectorAll()method, starting from the root element of the page'sdocument(for example, the<html>element for an HTML document).- If there is a syntax error in the
cssSelectorproperty, it may be treated as a verification failure (e.g.DOMExceptionSyntaxError). - If no elements are found, it may be treated as a verification failure.
- If there is a syntax error in the
- Use the
innerTextattribute of those elements to get the target as aDOMString. - Encode all objects into UTF-8. If there are multiple objects, combine their contents.
- Validate the result and the
integrityproperty using the methods specified in SRI section 3.3.5.- If an unsupported hash algorithm is used, it may be treated as a verification failure.
The string obtained by the innerText attribute is defined in HTML Standard Chapter 3 as the "as rendered" text obtained by executing get the text steps. If you run get the text steps on an element that is being rendered, you will get a string that has been processed after the rendered text collection steps have been run, with newline characters and other processing added.
Visible Text Targets use the innerText attribute and are different from the textContent attribute.
See Differences from innerText - MDN for the main differences between the two.
How to identify element location
Searches for an element specified by the CSS selector in the cssSelector property.