Repository navigation
Expand file tree
/
Copy pathtest-utils.js
More file actions
36 lines (32 loc) · 1.45 KB
/
Copy pathtest-utils.js
File metadata and controls
36 lines (32 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Tests for utils
*/
import { setup } from './helpers/harness.js'
describe('Ensure utils behave as expected', () => {
let browser
let server
let teardown
let setupServer
let gotoAndWait
beforeAll(async () => {
({ browser, setupServer, teardown, gotoAndWait } = await setup({ withExtension: true }))
server = setupServer()
})
afterAll(async () => {
await server?.close()
await teardown()
})
it('should toString DDGProxy correctly', async () => {
const port = server.address().port
const page = await browser.newPage()
await gotoAndWait(page, `http://localhost:${port}/blank.html`, { platform: { name: 'extension' } })
const toStringResult = await page.evaluate('HTMLCanvasElement.prototype.getContext.toString()')
expect(toStringResult).toEqual('function getContext() { [native code] }')
const toStringToStringResult = await page.evaluate('HTMLCanvasElement.prototype.getContext.toString.toString()')
expect(toStringToStringResult).toEqual('function toString() { [native code] }')
/* TOFIX: This is failing because the toString() call is being proxied and the result is not what we expect
const callToStringToStringResult = await page.evaluate('String.toString.call(HTMLCanvasElement.prototype.getContext.toString)')
expect(callToStringToStringResult).toEqual('function toString() { [native code] }')
*/
})
})

