Skip to content

Commit

Permalink
feat(Worker): add URLSearchParams (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdanyow authored and gja committed Dec 3, 2018
1 parent 996cec5 commit af6f1be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions app/__tests__/worker_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion app/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit af6f1be

Please sign in to comment.