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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/cross-origin-OffscreenCanvas2D-transferToImageBitmap.html

Issue 1928043002: Add drawImage() originClean() getSecurityOrigin() to OffscreenCanvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: drawImage API added to interface listing Created 4 years, 7 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <canvas id='output' width='200' height='400'></canvas>
5 <script src="/js-test-resources/js-test.js"></script>
6 <script id='myWorker' type='text/worker'>
7 self.onmessage = function(e) {
8 var aCanvas = new OffscreenCanvas(200, 400);
9 var ctx = aCanvas.getContext('2d');
10
11 // Draw a tainted imagebitmap into OffscreenCanvas 2d
12 ctx.drawImage(e.data, 0, 0, 10, 10);
13
14 var image = aCanvas.transferToImageBitmap();
15 self.postMessage(image, [image]);
16 };
17 </script>
18 <script>
19 description("The taintedness of the imagebitmap drawn to OffscrenCanvas must be transfered");
20
21 window.jsTestIsAsync = true;
22
23 function shouldBeTainted(imageBitmap) {
24 var canvas = document.createElement("canvas");
25 canvas.width = 10;
26 canvas.height = 10;
27 var context = canvas.getContext("2d");
28 context.drawImage(imageBitmap, 0, 0, 10, 10);
29 try {
30 var imageData = context.getImageData(0, 0, 10, 10);
31 testFailed("ImageBitmap is not tainted.");
32 } catch (e) {
33 testPassed("ImageBitmap is tainted. Threw error: " + e);
34 }
35 }
36
37 var blob = new Blob([document.getElementById('myWorker').textContent]);
38 var worker = new Worker(URL.createObjectURL(blob));
39 worker.addEventListener('message', msg => {
40 shouldBeTainted(msg.data);
41 finishJSTest();
42 });
43
44 var image = document.createElement('img');
45 image.src = 'http://localhost:8080/security/resources/abe.png';
46 image.addEventListener('load', function() {
47 createImageBitmap(image, 0, 0, 10, 10).then(
48 function(imagebitmap) {
49 // Post the tainted imagebitmap to worker
50 worker.postMessage(imagebitmap, [imagebitmap]);
51 },
52 function(e) {
53 testFailed("Image rejected unexpectedly. ");
54 debug(e);
55 }
56 );
57 });
58
59 </script>
60 </body>
61 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698