You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/optimization-detective/detect.js
+36-19Lines changed: 36 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -161,6 +161,17 @@ async function getAlreadySubmittedSessionStorageKey(
161
161
currentUrl,
162
162
urlMetricGroupStatus
163
163
){
164
+
// Check if crypto.subtle is available.
165
+
if(!window.crypto||!window.crypto.subtle){
166
+
// eslint-disable-next-line no-console
167
+
console.warn(
168
+
'[Optimization Detective] Web Crypto API is not available. This API is only available in secure contexts (HTTPS). Detection cannot proceed. If you are testing locally, ensure you use HTTPS or run on localhost.'
169
+
);
170
+
thrownewError(
171
+
'Web Crypto API is unavailable in this context. Try using HTTPS or localhost.'
172
+
);
173
+
}
174
+
164
175
constmessage=[
165
176
currentETag,
166
177
currentUrl,
@@ -391,27 +402,33 @@ export default async function detect( {
391
402
return;
392
403
}
393
404
394
-
// Abort if the client already submitted a URL Metric for this URL and viewport group.
0 commit comments