{"ScriptPreparationCode":"const isUserAgentToggleOnNative = (allowedUserAgents) =\u003E {\r\n const userAgent = typeof navigator !== \u0022undefined\u0022 ? navigator?.userAgent : \u0022\u0022\r\n return allowedUserAgents.some(x=\u003E userAgent.includes(x));\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":"isUserAgentToggleOnNative(USERNAME_PASSWORD_ALLOWED_USER_AGENTS);","IsDeferred":false},{"Name":"Regex with useragent having value","Code":"const navigator = {\r\n userAgent: \u0027k6\u0027\r\n}\r\nisUserAgentToggleOnRegex(USERNAME_PASSWORD_ALLOWED_USER_AGENTS)","IsDeferred":false},{"Name":"NAtive with useragent having value","Code":"const navigator = {\r\n userAgent: \u0027k6\u0027\r\n}\r\nisUserAgentToggleOnNative(USERNAME_PASSWORD_ALLOWED_USER_AGENTS);","IsDeferred":false}]}