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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/offscreencanvas-read-blocked-no-crossorigin.html

Issue 2570613002: Add OffscreenCanvas to ImageBitmapSource union typedef (Closed)
Patch Set: Created 4 years 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 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <script>
5
6 function verifyOffscreenCanvasTaintedThenDone(offscreen, t) {
7 assert_throws("SecurityError", function() {
8 offscreen.getContext("2d").getImageData(0, 0, 1, 1);
9 }, "Check getImageData blocked.");
10 offscreen.convertToBlob().then(
11 function() {
12 assert_unreached("Promise returned by convertToBlob was resolved.");
13 t.done();
14 },
15 rejectionValue => {
16 assert_equals(rejectionValue.name, "SecurityError");
17 t.done();
18 }
19 );
20 }
21
22 async_test(t => {
23 var image = new Image();
24 // Notice that we don't set the image.crossOrigin property.
25 image.src = "http://localhost:8000/security/resources/abe-allow-star.php";
26 image.onload = function() {
27 var offscreen = new OffscreenCanvas(10, 10);
28 var ctx = offscreen.getContext('2d');
29 ctx.drawImage(image, 0, 0);
30 t.step(function() {
31 verifyOffscreenCanvasTaintedThenDone(offscreen, t);
32 });
33 }
34 }, "Verify that an OffscreenCanvas tainted with cross-origin content cannot be r ead.");
35
36 async_test(t => {
37 var image = new Image();
38 // Notice that we don't set the image.crossOrigin property.
39 image.src = "http://localhost:8000/security/resources/abe-allow-star.php";
40 image.onload = function() {
41 var offscreen = new OffscreenCanvas(10, 10);
42 var ctx = offscreen.getContext('2d');
43 ctx.drawImage(image, 0, 0);
44 createImageBitmap(offscreen).then(imageBitmap => {
45 var offscreen2 = new OffscreenCanvas(10, 10);
46 var ctx2 = offscreen2.getContext('2d');
47 ctx2.drawImage(imageBitmap, 0, 0);
48 t.step(function() {
49 verifyOffscreenCanvasTaintedThenDone(offscreen, t);
50 });
51 })
52 }
53 }, "Verify that createImageBitmap(OffscreenCanvas) propagates th origin-clean fl ag.");
Stephen White 2016/12/12 19:55:46 Nit: th -> the
54
55
56
57
58
59 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698