summaryrefslogtreecommitdiffstats
path: root/remote/test/puppeteer/test-d/JSHandle.test-d.ts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /remote/test/puppeteer/test-d/JSHandle.test-d.ts
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'remote/test/puppeteer/test-d/JSHandle.test-d.ts')
-rw-r--r--remote/test/puppeteer/test-d/JSHandle.test-d.ts84
1 files changed, 84 insertions, 0 deletions
diff --git a/remote/test/puppeteer/test-d/JSHandle.test-d.ts b/remote/test/puppeteer/test-d/JSHandle.test-d.ts
new file mode 100644
index 0000000000..fa7348d28e
--- /dev/null
+++ b/remote/test/puppeteer/test-d/JSHandle.test-d.ts
@@ -0,0 +1,84 @@
+import {expectNotAssignable, expectNotType, expectType} from 'tsd';
+
+import type {ElementHandle, JSHandle} from 'puppeteer';
+
+declare const handle: JSHandle;
+
+{
+ expectType<unknown>(await handle.evaluate('document'));
+ expectType<number>(
+ await handle.evaluate(() => {
+ return 1;
+ })
+ );
+ expectType<HTMLElement>(
+ await handle.evaluate(() => {
+ return document.body;
+ })
+ );
+ expectType<string>(
+ await handle.evaluate(() => {
+ return '';
+ })
+ );
+ expectType<string>(
+ await handle.evaluate((value, str) => {
+ expectNotAssignable<never>(value);
+ expectType<string>(str);
+ return '';
+ }, '')
+ );
+}
+
+{
+ expectType<JSHandle>(await handle.evaluateHandle('document'));
+ expectType<JSHandle<number>>(
+ await handle.evaluateHandle(() => {
+ return 1;
+ })
+ );
+ expectType<JSHandle<string>>(
+ await handle.evaluateHandle(() => {
+ return '';
+ })
+ );
+ expectType<JSHandle<string>>(
+ await handle.evaluateHandle((value, str) => {
+ expectNotAssignable<never>(value);
+ expectType<string>(str);
+ return '';
+ }, '')
+ );
+ expectType<ElementHandle<HTMLElement>>(
+ await handle.evaluateHandle(() => {
+ return document.body;
+ })
+ );
+}
+
+declare const handle2: JSHandle<{test: number}>;
+
+{
+ {
+ expectType<JSHandle<number>>(await handle2.getProperty('test'));
+ expectNotType<JSHandle<unknown>>(await handle2.getProperty('test'));
+ }
+ {
+ expectType<JSHandle<unknown>>(
+ await handle2.getProperty('key-doesnt-exist')
+ );
+ expectNotType<JSHandle<string>>(
+ await handle2.getProperty('key-doesnt-exist')
+ );
+ expectNotType<JSHandle<number>>(
+ await handle2.getProperty('key-doesnt-exist')
+ );
+ }
+}
+
+{
+ void handle.evaluate((value, other) => {
+ expectType<unknown>(value);
+ expectType<{test: number}>(other);
+ }, handle2);
+}