v160 · graphics · canvas
Feature-detection kit
toneMapping is a dictionary member, not an interface — there is no window.CanvasToneMapping to test for, and browsers silently ignore dictionary members they do not know. So how does an HDR editor decide whether to ask for "extended"? Run four independent detectors, see where they disagree, and watch the app pick its rendering path from the one that actually proves the contract.
Shipping status & how to enable. Chrome 160 is planned to ship this enabled for everyone. Until then it sits behind the Blink runtime feature CanvasToneMapping (status experimental in runtime_enabled_features.json5). To run it today in Chrome or Canary: turn on chrome://flags/#enable-experimental-web-platform-features (there is no dedicated chrome://flags entry), or launch with --enable-blink-features=CanvasToneMapping. Seeing brighter-than-white pixels additionally needs an HDR-capable display and OS HDR mode — this page reports (dynamic-range: high) so you know which case you are in.
Probing this browser…
Run the detectors
| detector | what it proves | result |
|---|---|---|
| 1. member read | A getter on settings.toneMapping is invoked during getContext ⇒ the IDL dictionary knows the member. | not run |
| 2. enum validated | {mode: "not-a-mode"} throws TypeError ⇒ CanvasToneMappingMode is enforced. | not run |
| 3. default reflected | getContextAttributes().toneMapping.mode === "standard" with no setting. | not run |
| 4. extended reflected | Asking for "extended" reports "extended" ⇒ the setting took effect. | not run |
why the detectors disagree
Different builds sit at different points of the rollout, and each detector catches a different stage. Measured in this project’s test container (Chrome 153): without the flag, detector 3 already passes (the reflection lists a constant "standard") while 1, 2 and 4 fail — so a detector that only checks for a toneMapping key in getContextAttributes() is a false positive. With --enable-blink-features=CanvasToneMapping, detectors 1–3 pass but 4 still fails: the member is parsed and validated, yet "extended" is not reported back. Only detector 4 proves the contract the WPT pins, so it is the one to branch on.
function supportsExtendedToneMapping() {
try {
const ctx = document.createElement("canvas")
.getContext("2d", { toneMapping: { mode: "extended" } });
return ctx.getContextAttributes().toneMapping?.mode === "extended";
} catch { return false; }
}
// NOT enough: "toneMapping" in ctx.getContextAttributes()
// (Chrome 153 reflects a constant "standard" with the feature off)