Auto merge of #24123 - gterzian:redo_blob, r=jdm

Restructure Blob, structured serialization

<!-- Please describe your changes on the following line: -->
FIX #24052 and also address the "cloning" half of FIX #23917

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/24123)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-12-19 16:16:56 -05:00 committed by GitHub
commit bac9903fbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 991 additions and 489 deletions

View file

@ -360210,9 +360210,15 @@
{}
]
],
"html/infrastructure/safe-passing-of-structured-data/structured_clone_blob.html": [
"html/infrastructure/safe-passing-of-structured-data/structured_clone_blob.window.js": [
[
"html/infrastructure/safe-passing-of-structured-data/structured_clone_blob.html",
"html/infrastructure/safe-passing-of-structured-data/structured_clone_blob.window.html",
{}
]
],
"html/infrastructure/safe-passing-of-structured-data/structured_clone_blob_array.window.js": [
[
"html/infrastructure/safe-passing-of-structured-data/structured_clone_blob_array.window.html",
{}
]
],
@ -655445,8 +655451,12 @@
"995edac8da9d95ac6f151863b5cd48994941a347",
"testharness"
],
"html/infrastructure/safe-passing-of-structured-data/structured_clone_blob.html": [
"6b1abf5ef8d30c2494effac489db79732d0c12d4",
"html/infrastructure/safe-passing-of-structured-data/structured_clone_blob.window.js": [
"490e78165de820d31f25cd3f09416a8cbf1b1c66",
"testharness"
],
"html/infrastructure/safe-passing-of-structured-data/structured_clone_blob_array.window.js": [
"b976d5b212652bf763b4a6039a70c26758c84ccf",
"testharness"
],
"html/infrastructure/safe-passing-of-structured-data/structuredclone_0.html": [

View file

@ -1,35 +0,0 @@
<!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>

View file

@ -0,0 +1,22 @@
async_test(function(t) {
var blob = new Blob(['<a id="a"><b id="b">hey!</b></a>'], {type:"text/plain"});
onmessage = t.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", t.step_func(function() {
original_content = reader.result;
var reader2 = new FileReader();
reader2.addEventListener("loadend", t.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);
});
postMessage(blob, '*');
}, "Cloning a blob into the same realm");

View file

@ -0,0 +1,25 @@
async_test(function(t) {
var blob = new Blob(['<a id="a"><b id="b">hey!</b></a>'], {type:"text/plain"});
var another_blob = new Blob(['<a id="a"><b id="b">hey!</b></a>'], {type:"text/plain"});
onmessage = t.step_func(function(msg) {
assert_true(msg.data instanceof Array);
assert_equals(msg.data.length, 2);
msg.data.forEach((function(blob, index) {
assert_true(blob instanceof Blob);
var cloned_content, original_content;
var reader = new FileReader();
reader.addEventListener("loadend", t.step_func(function() {
original_content = reader.result;
var reader2 = new FileReader();
reader2.addEventListener("loadend", t.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[index]);
}));
reader.readAsText(blob);
}));
});
postMessage([blob, another_blob], '*');
}, "Cloning an array of blobs into the same realm");