mirror of
https://github.com/servo/servo.git
synced 2025-08-15 18:35:33 +01:00
Auto merge of #15519 - gterzian:implement_structuredclone_callbacks, r=jdm
implement structured clone callbacks - support Blob cloning <!-- Please describe your changes on the following line: --> 1. Implement stubs for structured clone callbacks. 2. Support Blob cloning. Partial implementation of https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #15021 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15519) <!-- Reviewable:end -->
This commit is contained in:
commit
7be9f0e7c4
4 changed files with 212 additions and 7 deletions
|
@ -0,0 +1,35 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Safe passing of structured data - Blob</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var blob = new Blob(['<a id="a"><b id="b">hey!</b></a>'], {type:"text/plain"});
|
||||
window.addEventListener("message", this.step_func(function(msg) {
|
||||
assert_true(msg.data instanceof Blob);
|
||||
assert_equals(msg.data.size, blob.size);
|
||||
assert_equals(msg.data.type, blob.type);
|
||||
var cloned_content, original_content;
|
||||
var reader = new FileReader();
|
||||
reader.addEventListener("loadend", this.step_func(function() {
|
||||
original_content = reader.result;
|
||||
var reader2 = new FileReader();
|
||||
reader2.addEventListener("loadend", this.step_func_done(function() {
|
||||
cloned_content = reader2.result;
|
||||
assert_equals(typeof cloned_content, typeof original_content);
|
||||
assert_equals(cloned_content, original_content);
|
||||
}));
|
||||
reader2.readAsText(msg.data);
|
||||
}));
|
||||
reader.readAsText(blob);
|
||||
}), false);
|
||||
window.postMessage(blob, '*');
|
||||
}, "Cloning a Blob into the same realm");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue