@@ -151,6 +151,33 @@ describe("browser permission routes", () => {
|
151 | 151 | }); |
152 | 152 | }); |
153 | 153 | |
| 154 | +it("rejects loose timeoutMs values before granting permissions", async () => { |
| 155 | +const { response, profileCtx } = await callGrant({ |
| 156 | +origin: "https://meet.google.com", |
| 157 | +permissions: ["audioCapture"], |
| 158 | +timeoutMs: "1e3", |
| 159 | +}); |
| 160 | + |
| 161 | +expect(response.statusCode).toBe(400); |
| 162 | +expect(response.body).toStrictEqual({ error: "timeoutMs must be a positive integer." }); |
| 163 | +expect(profileCtx.ensureBrowserAvailable).not.toHaveBeenCalled(); |
| 164 | +expect(cdpMocks.getChromeWebSocketUrl).not.toHaveBeenCalled(); |
| 165 | +expect(cdpMocks.send).not.toHaveBeenCalled(); |
| 166 | +}); |
| 167 | + |
| 168 | +it("keeps the minimum permission timeout for small valid values", async () => { |
| 169 | +const { response } = await callGrant({ |
| 170 | +origin: "https://meet.google.com", |
| 171 | +permissions: ["audioCapture"], |
| 172 | +timeoutMs: "1", |
| 173 | +}); |
| 174 | + |
| 175 | +expect(response.statusCode).toBe(200); |
| 176 | +expect(cdpMocks.getChromeWebSocketUrl).toHaveBeenCalledWith("http://127.0.0.1:18800", 1000, { |
| 177 | +allowPrivateNetwork: false, |
| 178 | +}); |
| 179 | +}); |
| 180 | + |
154 | 181 | it("keeps required permissions when an optional permission is unsupported", async () => { |
155 | 182 | cdpMocks.send.mockImplementation(async (_method: string, params?: Record<string, unknown>) => { |
156 | 183 | const permissions = Array.isArray(params?.permissions) ? params.permissions : []; |
|