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

Side by Side 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, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
6 <script id="myWorker" type="text/worker">
7 self.onmessage = function(e) {
8 postMessage(e.data);
9 };
10 </script>
11 <script>
12 function makeWorker(script) {
13 var blob = new Blob([script]);
14 return new Worker(URL.createObjectURL(blob));
15 }
16 var worker = makeWorker(document.getElementById('myWorker').textContent);
17
18 function shouldBeTainted(imageBitmap) {
19 var canvas = document.createElement("canvas");
20 canvas.width = 10;
21 canvas.height = 10;
22 var context = canvas.getContext("2d");
23 context.drawImage(imageBitmap, 0, 0, 10, 10);
24 assert_throws(null, function () { context.getImageData(0, 0, 10, 10); }, 'Im ageBitmap should be tainted');
25 }
26
27 function postToWorker(message, transferable) {
28 return new Promise((resolve, reject) => {
29 function onMessage(e) {
30 resolve(e.data);
31 worker.removeEventListener("message", onMessage);
32 }
33 worker.postMessage(message, transferable);
34 worker.addEventListener("message", onMessage);
35 });
36 }
37
38 promise_test(function() {
39 return new Promise((resolve, reject) => {
40 var image = new Image();
41 image.onload = function() {
42 createImageBitmap(image).then(imageBitmap => {
43 var replyPromise = postToWorker(imageBitmap, [imageBitmap]);
44 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.
45 });
46 }
47 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
48 }).then(shouldBeTainted);
49 }, 'Transfer or structured-clone an ImageBitmap should preserve the originClean flag.');
50 </script>
51 </body>
52 </html>
OLDNEW
« 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