diff --git a/app/__tests__/worker_spec.js b/app/__tests__/worker_spec.js index 208c9e8..95810c0 100644 --- a/app/__tests__/worker_spec.js +++ b/app/__tests__/worker_spec.js @@ -36,6 +36,18 @@ describe("Workers", () => { expect(url.searchParams.get("foo")).toBe("bar"); }); + test('It has support for URLSearchParams', () => { + const worker = new Worker( + 'foo.com', + `addEventListener('test', () => new URLSearchParams({ foo: 'bar' }))` + ); + const params = worker.triggerEvent('test'); + expect(params.has('foo')).toBe(true); + expect(params.get('foo')).toBe('bar'); + expect(params.has('baz')).toBe(false); + expect(params.get('baz')).toBe(null); + }); + test('It has support for base64 encoding APIs', () => { const worker = new Worker( 'foo.com', diff --git a/app/worker.js b/app/worker.js index 9f365ae..97253b9 100644 --- a/app/worker.js +++ b/app/worker.js @@ -30,7 +30,7 @@ class Worker { } evaluateWorkerContents(workerContents, kvStores) { - const context = { Request, Response, Headers, URL, atob, btoa, crypto, TextDecoder, TextEncoder, console }; + const context = { Request, Response, Headers, URL, URLSearchParams, atob, btoa, crypto, TextDecoder, TextEncoder, console }; const script = new Script(workerContents); script.runInContext( createContext(