forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extensions/web): add structuredClone function (denoland#11572)
Co-authored-by: Luca Casonato <[email protected]>
- Loading branch information
1 parent
02c74fb
commit 16ae4a0
Showing
9 changed files
with
107 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { assert, assertEquals } from "./test_util.ts"; | ||
|
||
// Basic tests for the structured clone algorithm. Mainly tests TypeScript | ||
// typings. Actual functionality is tested in WPT. | ||
|
||
Deno.test("self.structuredClone", async () => { | ||
const arrayOriginal = ["hello world"]; | ||
const channelOriginal = new MessageChannel(); | ||
const [arrayCloned, portTransferred] = self | ||
.structuredClone([arrayOriginal, channelOriginal.port2], { | ||
transfer: [channelOriginal.port2], | ||
}); | ||
assert(arrayOriginal !== arrayCloned); // not the same identity | ||
assertEquals(arrayCloned, arrayOriginal); // but same value | ||
channelOriginal.port1.postMessage("1"); | ||
await new Promise((resolve) => portTransferred.onmessage = () => resolve(1)); | ||
channelOriginal.port1.close(); | ||
portTransferred.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters