mirror of
https://github.com/servo/servo.git
synced 2025-08-10 16:05:43 +01:00
support structured cloning for Blob
This commit is contained in:
parent
ec84560e7f
commit
5c4f0be048
4 changed files with 163 additions and 24 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