New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement structured clone callbacks - support Blob cloning #15519
Merged
bors-servo
merged 2 commits into
servo:master
from
gterzian:implement_structuredclone_callbacks
Mar 22, 2017
+212
−7
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
support structured cloning for Blob
- Loading branch information
commit 5c4f0be04872f5f2e8736b15a2169f9479509a0e
| @@ -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); | ||
gterzian
Author
Member
|
||
| 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> | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
I think this will be more maintainable going forward if we create a
write_blobfunction and move the contents of this outerifblock into it.