summaryrefslogtreecommitdiff
path: root/packages/webapi/test/internals.js
blob: 84f918fb628d244ae5c73d42c809b099e97467d1 (plain) (blame)
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
import { assert, test } from '../run/test.setup.js'
import { polyfill } from '../mod.js'

test(() => {
	return [
		{
			name: 'Includes polyfill.internals functionality',
			test() {
				const target = {}
	
				polyfill(target, { exclude: 'window document' })

				const pseudo = { ...target }

				assert.equal(Reflect.has(pseudo, 'document'), false)

				const CustomElement = class extends pseudo.HTMLElement {}

				pseudo.customElements.define('custom-element', CustomElement)

				polyfill.internals(pseudo, 'Document')

				assert.equal(Reflect.has(pseudo, 'document'), true)

				assert.equal(CustomElement.prototype.isPrototypeOf(pseudo.document.createElement('custom-element')), true)
			},
		}
	]
})