Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-beans-enter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/web-worker-runtime": patch
---

feat: support for using `lynx.queueMicrotask`.
1 change: 1 addition & 0 deletions cspell.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
// lighthouse CI
"lhci",
"lh",
"queueMicrotask",
],
// Glob
"ignorePaths": [
Expand Down
9 changes: 9 additions & 0 deletions packages/web-platform/web-tests/tests/react.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

const expectHasText = async (page: Page, text: string) => {
const hasText = (await page.getByText(text).count()) === 1;
await expect(hasText).toBe(true);

Check failure on line 38 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux-all-on-ui / check

[webkit] › tests/react.spec.ts:122:5 › reactlynx3 tests › basic › basic-setsate-with-cb

2) [webkit] › tests/react.spec.ts:122:5 › reactlynx3 tests › basic › basic-setsate-with-cb ─────── Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false 36 | const expectHasText = async (page: Page, text: string) => { 37 | const hasText = (await page.getByText(text).count()) === 1; > 38 | await expect(hasText).toBe(true); | ^ 39 | }; 40 | 41 | const expectNoText = async (page: Page, text: string) => { at expectHasText (/home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:38:25) at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:125:7
};

const expectNoText = async (page: Page, text: string) => {
Expand Down Expand Up @@ -602,7 +602,7 @@
document.querySelector('lynx-view')!.remove();
});
await wait(50);
expect(message).toContain('fin');

Check failure on line 605 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux-all-on-ui / check

[webkit] › tests/react.spec.ts:593:5 › reactlynx3 tests › apis › api-dispose

3) [webkit] › tests/react.spec.ts:593:5 › reactlynx3 tests › apis › api-dispose ────────────────── Error: expect(received).toContain(expected) // indexOf Expected value: "fin" Received array: ["NYI: profileStart. This is an issue of lynx-core."] 603 | }); 604 | await wait(50); > 605 | expect(message).toContain('fin'); | ^ 606 | expect(page.workers().length).toStrictEqual(1); 607 | }); 608 | at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:605:23
expect(page.workers().length).toStrictEqual(1);
});

Expand Down Expand Up @@ -933,7 +933,7 @@
globalThis.lynxView.sendGlobalEvent('event-test', ['change']);
});
await wait(100);
await expect(target).toHaveCSS(

Check failure on line 936 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux-all-on-ui / check

[webkit] › tests/react.spec.ts:927:5 › reactlynx3 tests › apis › api-sendGlobalEvent

4) [webkit] › tests/react.spec.ts:927:5 › reactlynx3 tests › apis › api-sendGlobalEvent ────────── Error: Timed out 5000ms waiting for expect(locator).toHaveCSS(expected) Locator: locator('#target') Expected string: "rgb(0, 128, 0)" Received string: "rgb(255, 192, 203)" Call log: - expect.toHaveCSS with timeout 5000ms - waiting for locator('#target') 9 × locator resolved to <x-view id="target" lynx-tag="view" lynx-unique-id="2"></x-view> - unexpected value "rgb(255, 192, 203)" 934 | }); 935 | await wait(100); > 936 | await expect(target).toHaveCSS( | ^ 937 | 'background-color', 938 | 'rgb(0, 128, 0)', 939 | ); // green; at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:936:28

Check failure on line 936 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux-all-on-ui / check

[webkit] › tests/react.spec.ts:927:5 › reactlynx3 tests › apis › api-sendGlobalEvent

4) [webkit] › tests/react.spec.ts:927:5 › reactlynx3 tests › apis › api-sendGlobalEvent ────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toHaveCSS(expected) Locator: locator('#target') Expected string: "rgb(0, 128, 0)" Received string: "rgb(255, 192, 203)" Call log: - expect.toHaveCSS with timeout 5000ms - waiting for locator('#target') 9 × locator resolved to <x-view id="target" lynx-tag="view" lynx-unique-id="2"></x-view> - unexpected value "rgb(255, 192, 203)" 934 | }); 935 | await wait(100); > 936 | await expect(target).toHaveCSS( | ^ 937 | 'background-color', 938 | 'rgb(0, 128, 0)', 939 | ); // green; at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:936:28

Check failure on line 936 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux-all-on-ui / check

[chromium] › tests/react.spec.ts:927:5 › reactlynx3 tests › apis › api-sendGlobalEvent

8) [chromium] › tests/react.spec.ts:927:5 › reactlynx3 tests › apis › api-sendGlobalEvent ──────── Error: Timed out 5000ms waiting for expect(locator).toHaveCSS(expected) Locator: locator('#target') Expected string: "rgb(0, 128, 0)" Received string: "rgb(255, 192, 203)" Call log: - expect.toHaveCSS with timeout 5000ms - waiting for locator('#target') 9 × locator resolved to <x-view id="target" lynx-tag="view" lynx-unique-id="2"></x-view> - unexpected value "rgb(255, 192, 203)" 934 | }); 935 | await wait(100); > 936 | await expect(target).toHaveCSS( | ^ 937 | 'background-color', 938 | 'rgb(0, 128, 0)', 939 | ); // green; at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:936:28
'background-color',
'rgb(0, 128, 0)',
); // green;
Expand All @@ -956,6 +956,15 @@
await wait(100);
await expect(result).toHaveCSS('background-color', 'rgb(0, 128, 0)'); // green
});
test(
'api-queueMicrotask',
async ({ page }, { title }) => {
await goto(page, title);
await wait(200);
const target = page.locator('#target');
await expect(target).toHaveCSS('background-color', 'rgb(0, 128, 0)'); // green
},
);
});

test.describe('configs', () => {
Expand Down Expand Up @@ -1137,7 +1146,7 @@
await wait(100);
const target = page.locator('#target');
await target.click();
await expect(await target.getAttribute('style')).toContain('green');

Check failure on line 1149 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux / check

[webkit] › tests/react.spec.ts:1144:5 › reactlynx3 tests › configs › config-mode-dev-with-all-in-one

2) [webkit] › tests/react.spec.ts:1144:5 › reactlynx3 tests › configs › config-mode-dev-with-all-in-one Error: expect(received).toContain(expected) // indexOf Expected substring: "green" Received string: "height: 100px; width: 100px; background: pink;" 1147 | const target = page.locator('#target'); 1148 | await target.click(); > 1149 | await expect(await target.getAttribute('style')).toContain('green'); | ^ 1150 | await target.click(); 1151 | await expect(await target.getAttribute('style')).toContain('pink'); 1152 | }); at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:1149:56

Check failure on line 1149 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux / check

[webkit] › tests/react.spec.ts:1144:5 › reactlynx3 tests › configs › config-mode-dev-with-all-in-one

2) [webkit] › tests/react.spec.ts:1144:5 › reactlynx3 tests › configs › config-mode-dev-with-all-in-one Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toContain(expected) // indexOf Expected substring: "green" Received string: "height: 100px; width: 100px; background: pink;" 1147 | const target = page.locator('#target'); 1148 | await target.click(); > 1149 | await expect(await target.getAttribute('style')).toContain('green'); | ^ 1150 | await target.click(); 1151 | await expect(await target.getAttribute('style')).toContain('pink'); 1152 | }); at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:1149:56
await target.click();
await expect(await target.getAttribute('style')).toContain('pink');
});
Expand Down Expand Up @@ -2077,7 +2086,7 @@
await page.locator('.focus').click({ force: true });
await wait(100);
const result = await page.locator('.result').first().innerText();
expect(result).toBe('bindfocus');

Check failure on line 2089 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux / check

[webkit] › tests/react.spec.ts:2081:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-focus

3) [webkit] › tests/react.spec.ts:2081:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-focus Error: expect(received).toBe(expected) // Object.is equality Expected: "bindfocus" Received: "" 2087 | await wait(100); 2088 | const result = await page.locator('.result').first().innerText(); > 2089 | expect(result).toBe('bindfocus'); | ^ 2090 | }, 2091 | ); 2092 | // input/focus test-case end at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:2089:26

Check failure on line 2089 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux / check

[webkit] › tests/react.spec.ts:2081:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-focus

3) [webkit] › tests/react.spec.ts:2081:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-focus Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: "bindfocus" Received: "" 2087 | await wait(100); 2088 | const result = await page.locator('.result').first().innerText(); > 2089 | expect(result).toBe('bindfocus'); | ^ 2090 | }, 2091 | ); 2092 | // input/focus test-case end at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:2089:26

Check failure on line 2089 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux / check

[webkit] › tests/react.spec.ts:2081:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-focus

3) [webkit] › tests/react.spec.ts:2081:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-focus Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: "bindfocus" Received: "" 2087 | await wait(100); 2088 | const result = await page.locator('.result').first().innerText(); > 2089 | expect(result).toBe('bindfocus'); | ^ 2090 | }, 2091 | ); 2092 | // input/focus test-case end at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:2089:26

Check failure on line 2089 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux-all-on-ui / check

[webkit] › tests/react.spec.ts:2081:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-focus

5) [webkit] › tests/react.spec.ts:2081:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-focus Error: expect(received).toBe(expected) // Object.is equality Expected: "bindfocus" Received: "" 2087 | await wait(100); 2088 | const result = await page.locator('.result').first().innerText(); > 2089 | expect(result).toBe('bindfocus'); | ^ 2090 | }, 2091 | ); 2092 | // input/focus test-case end at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:2089:26
},
);
// input/focus test-case end
Expand All @@ -2088,7 +2097,7 @@
await page.locator('input').click({ force: true });
await wait(100);
const result = await page.locator('.result').first().innerText();
expect(result).toBe('bindfocus');

Check failure on line 2100 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux / check

[webkit] › tests/react.spec.ts:2095:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-bindfocus

4) [webkit] › tests/react.spec.ts:2095:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-bindfocus Error: expect(received).toBe(expected) // Object.is equality Expected: "bindfocus" Received: "" 2098 | await wait(100); 2099 | const result = await page.locator('.result').first().innerText(); > 2100 | expect(result).toBe('bindfocus'); | ^ 2101 | }); 2102 | // input/bindfocus test-case end 2103 | at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:2100:24

Check failure on line 2100 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux / check

[webkit] › tests/react.spec.ts:2095:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-bindfocus

4) [webkit] › tests/react.spec.ts:2095:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-bindfocus Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: "bindfocus" Received: "" 2098 | await wait(100); 2099 | const result = await page.locator('.result').first().innerText(); > 2100 | expect(result).toBe('bindfocus'); | ^ 2101 | }); 2102 | // input/bindfocus test-case end 2103 | at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:2100:24

Check failure on line 2100 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux / check

[webkit] › tests/react.spec.ts:2095:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-bindfocus

4) [webkit] › tests/react.spec.ts:2095:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-bindfocus Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: "bindfocus" Received: "" 2098 | await wait(100); 2099 | const result = await page.locator('.result').first().innerText(); > 2100 | expect(result).toBe('bindfocus'); | ^ 2101 | }); 2102 | // input/bindfocus test-case end 2103 | at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:2100:24

Check failure on line 2100 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux-all-on-ui / check

[webkit] › tests/react.spec.ts:2095:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-bindfocus

6) [webkit] › tests/react.spec.ts:2095:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-bindfocus Error: expect(received).toBe(expected) // Object.is equality Expected: "bindfocus" Received: "" 2098 | await wait(100); 2099 | const result = await page.locator('.result').first().innerText(); > 2100 | expect(result).toBe('bindfocus'); | ^ 2101 | }); 2102 | // input/bindfocus test-case end 2103 | at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:2100:24
});
// input/bindfocus test-case end

Expand All @@ -2098,7 +2107,7 @@
await page.locator('input').press('Enter');
await wait(100);
const result = await page.locator('.result').first().innerText();
expect(result).toBe('bindconfirm');

Check failure on line 2110 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux / check

[webkit] › tests/react.spec.ts:2105:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-bindconfirm

5) [webkit] › tests/react.spec.ts:2105:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-bindconfirm Error: expect(received).toBe(expected) // Object.is equality Expected: "bindconfirm" Received: "" 2108 | await wait(100); 2109 | const result = await page.locator('.result').first().innerText(); > 2110 | expect(result).toBe('bindconfirm'); | ^ 2111 | }); 2112 | // input/bindconfirm test-case end 2113 | at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:2110:24

Check failure on line 2110 in packages/web-platform/web-tests/tests/react.spec.ts

View workflow job for this annotation

GitHub Actions / playwright-linux-all-on-ui / check

[webkit] › tests/react.spec.ts:2105:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-bindconfirm

7) [webkit] › tests/react.spec.ts:2105:7 › reactlynx3 tests › elements › x-input › basic-element-x-input-bindconfirm Error: expect(received).toBe(expected) // Object.is equality Expected: "bindconfirm" Received: "" 2108 | await wait(100); 2109 | const result = await page.locator('.result').first().innerText(); > 2110 | expect(result).toBe('bindconfirm'); | ^ 2111 | }); 2112 | // input/bindconfirm test-case end 2113 | at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/react.spec.ts:2110:24
});
// input/bindconfirm test-case end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2023 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { root, useEffect, useState } from '@lynx-js/react';

function App() {
const [color, setColor] = useState('pink');
useEffect(() => {
lynx.queueMicrotask(() => {
setColor('green');
});
}, []);

return (
<view
id='target'
style={{
height: '100px',
width: '100px',
background: color,
}}
/>
);
}

root.render(<App></App>);
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@ export function createBackgroundLynx(
mainThreadRpc,
config.customSections,
),
queueMicrotask: (callback: () => void) => {
queueMicrotask(callback);
},
};
}
Loading