Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap-structured-clone.html

Issue 2178513002: Add layout test to make sure origin clean flag is preserved (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: favoring one test file Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap-structured-clone.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap-structured-clone.html b/third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap-structured-clone.html
new file mode 100644
index 0000000000000000000000000000000000000000..b3515cec9b34388147868b80b794d6d022dcb19e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap-structured-clone.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script id="myWorker" type="text/worker">
+self.onmessage = function(e) {
+ postMessage(e.data);
+};
+</script>
+<script>
+function makeWorker(script) {
+ var blob = new Blob([script]);
+ return new Worker(URL.createObjectURL(blob));
+}
+var worker = makeWorker(document.getElementById('myWorker').textContent);
+
+function shouldBeTainted(imageBitmap) {
+ var canvas = document.createElement("canvas");
+ canvas.width = 10;
+ canvas.height = 10;
+ var context = canvas.getContext("2d");
+ context.drawImage(imageBitmap, 0, 0, 10, 10);
+ assert_throws(null, function () { context.getImageData(0, 0, 10, 10); }, 'ImageBitmap should be tainted');
+}
+
+function postToWorker(message, transferable) {
+ return new Promise((resolve, reject) => {
+ function onMessage(e) {
+ resolve(e.data);
+ worker.removeEventListener("message", onMessage);
+ }
+ worker.postMessage(message, transferable);
+ worker.addEventListener("message", onMessage);
+ });
+}
+
+promise_test(function() {
+ return new Promise((resolve, reject) => {
+ var image = new Image();
+ image.onload = function() {
+ createImageBitmap(image).then(imageBitmap => {
+ var replyPromise = postToWorker(imageBitmap, [imageBitmap]);
+ resolve(replyPromise);
Justin Novosad 2016/07/26 14:07:52 This is a nested promise. I am pretty sure the tes
xidachen 2016/07/26 15:13:10 Changed to async_test in the new patch.
+ });
+ }
+ image.src = 'http://localhost:8080/security/resources/abe.png';
Justin Novosad 2016/07/26 14:07:52 Not the best thing to hard code 'http://localhost:
xidachen 2016/07/26 15:13:10 Per off-line discussion, will leave the path as lo
+ }).then(shouldBeTainted);
+}, 'Transfer or structured-clone an ImageBitmap should preserve the originClean flag.');
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698