|
1 | 1 | import fs from "fs";
|
2 |
| -import { test, expect, Page } from "@playwright/test"; |
3 |
| - |
4 |
| -import { setupDebugLog, setupProxy } from "../support"; |
| 2 | +import { test, expect } from "@playwright/test"; |
| 3 | +import { setupDebugLog, setupProxy, resolveBinding } from "../support"; |
5 | 4 |
|
6 | 5 | if (!process.env.RUBY_NPM_PACKAGE_ROOT) {
|
7 | 6 | test.skip("skip", () => {});
|
@@ -34,57 +33,6 @@ if (!process.env.RUBY_NPM_PACKAGE_ROOT) {
|
34 | 33 | });
|
35 | 34 | });
|
36 | 35 |
|
37 |
| - const resolveBinding = async (page: Page, name: string) => { |
38 |
| - let checkResolved; |
39 |
| - const resolvedValue = new Promise((resolve) => { |
40 |
| - checkResolved = resolve; |
41 |
| - }); |
42 |
| - await page.exposeBinding(name, async (source, v) => { |
43 |
| - checkResolved(v); |
44 |
| - }); |
45 |
| - return async () => await resolvedValue; |
46 |
| - }; |
47 |
| - |
48 |
| - test.describe('data-eval="async"', () => { |
49 |
| - test("JS::Object#await returns value", async ({ page }) => { |
50 |
| - const resolve = await resolveBinding(page, "checkResolved"); |
51 |
| - await page.setContent(` |
52 |
| - <script src="https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@latest/dist/browser.script.iife.js"></script> |
53 |
| - <script type="text/ruby" data-eval="async"> |
54 |
| - require "js" |
55 |
| - JS.global.checkResolved JS.global[:Promise].resolve(42).await |
56 |
| - </script> |
57 |
| - `); |
58 |
| - expect(await resolve()).toBe(42); |
59 |
| - }); |
60 |
| - |
61 |
| - test("JS::Object#await throws error on default attr", async ({ page }) => { |
62 |
| - await page.setContent(` |
63 |
| - <script src="https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@latest/dist/browser.script.iife.js"></script> |
64 |
| - <script type="text/ruby"> |
65 |
| - require "js" |
66 |
| - JS.global[:Promise].resolve(42).await |
67 |
| - </script> |
68 |
| - `); |
69 |
| - const error = await page.waitForEvent("pageerror"); |
70 |
| - expect(error.message).toMatch( |
71 |
| - /please ensure that you specify `data-eval="async"`/, |
72 |
| - ); |
73 |
| - }); |
74 |
| - |
75 |
| - test("default stack size is enough to require 'json'", async ({ page }) => { |
76 |
| - const resolve = await resolveBinding(page, "checkResolved"); |
77 |
| - await page.setContent(` |
78 |
| - <script src="https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@latest/dist/browser.script.iife.js"></script> |
79 |
| - <script type="text/ruby" data-eval="async"> |
80 |
| - require 'json' |
81 |
| - JS.global.checkResolved "ok" |
82 |
| - </script> |
83 |
| - `); |
84 |
| - expect(await resolve()).toBe("ok"); |
85 |
| - }); |
86 |
| - }); |
87 |
| - |
88 | 36 | test.describe("JS::RequireRemote#load", () => {
|
89 | 37 | test("JS::RequireRemote#load returns true", async ({ page }) => {
|
90 | 38 | const resolve = await resolveBinding(page, "checkResolved");
|
|
0 commit comments