{"ScriptPreparationCode":"const isUserAgentToggleOnNative = (allowedUserAgents, userAgent) =\u003E {\r\n allowedUserAgents.indexOf(userAgent) \u003E -1\r\n}\r\n\r\nconst getUserAgent = () =\u003E {\r\n const userAgent = typeof navigator !== \u0022undefined\u0022 ? navigator?.userAgent : \u0022\u0022\r\n switch (true) {\r\n case userAgent.includes(DATADOG_SYNTHETICS_USER_AGENT):\r\n return DATADOG_SYNTHETICS_USER_AGENT\r\n case userAgent.includes(K6_USER_AGENT):\r\n return K6_USER_AGENT\r\n default:\r\n return userAgent\r\n }\r\n}\r\n\r\nconst USERNAME_PASSWORD_ALLOWED_USER_AGENTS = [\u0022DatadogSynthetics\u0022, \u0022k6\u0022]\r\n\r\nconst isUserAgentToggleOnRegex = allowedUserAgents =\u003E {\r\n const userAgent = typeof navigator !== \u0022undefined\u0022 ? navigator?.userAgent : \u0022\u0022\r\n const regex = new RegExp(\u0060(${allowedUserAgents.join(\u0022|\u0022)})\u0060)\r\n return regex.test(userAgent)\r\n}\r\n\r\nconst DATADOG_SYNTHETICS_USER_AGENT = \u0027DatadogSynthetics\u0027, K6_USER_AGENT = \u0027k6\u0027;\r\n\r\n","TestCases":[{"Name":"Regex","Code":"/*When writing async/deferred tests, use \u0060deferred.resolve()\u0060 to mark test as done*/\r\n\r\n\r\nisUserAgentToggleOnRegex(USERNAME_PASSWORD_ALLOWED_USER_AGENTS)","IsDeferred":false},{"Name":"Native","Code":"\r\n\r\nisUserAgentToggleOnNative(USERNAME_PASSWORD_ALLOWED_USER_AGENTS, getUserAgent());","IsDeferred":false}]}