From 6c7e96d93ea36c11c41c66a840f6b63d54b23317 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Thu, 27 Mar 2025 01:03:25 -0700 Subject: [PATCH] Handle createPolicy gracefully (#2031) --- skyvern/webeye/scraper/domUtils.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/skyvern/webeye/scraper/domUtils.js b/skyvern/webeye/scraper/domUtils.js index e08a7a1b..ffa346a8 100644 --- a/skyvern/webeye/scraper/domUtils.js +++ b/skyvern/webeye/scraper/domUtils.js @@ -1882,12 +1882,17 @@ function createHintMarkersForGroups(groups) { } catch (e) { // Ensure trustedTypes is available if (typeof trustedTypes !== "undefined") { - const escapeHTMLPolicy = trustedTypes.createPolicy("default", { - createHTML: (string) => string, - }); - hintMarker.element.innerHTML = escapeHTMLPolicy.createHTML( - hintMarker.hintString.toUpperCase(), - ); + try { + const escapeHTMLPolicy = trustedTypes.createPolicy("hint-policy", { + createHTML: (string) => string, + }); + hintMarker.element.innerHTML = escapeHTMLPolicy.createHTML( + hintMarker.hintString.toUpperCase(), + ); + } catch (policyError) { + console.warn("Could not create trusted types policy:", policyError); + // Skip updating the hint marker if policy creation fails + } } else { console.error("trustedTypes is not supported in this environment."); }