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

Unified 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, 8 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
Index: third_party/WebKit/LayoutTests/http/tests/security/cross-origin-OffscreenCanvas2D-transferToImageBitmap.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/cross-origin-OffscreenCanvas2D-transferToImageBitmap.html b/third_party/WebKit/LayoutTests/http/tests/security/cross-origin-OffscreenCanvas2D-transferToImageBitmap.html
new file mode 100644
index 0000000000000000000000000000000000000000..d99965f55de5da5e6e4bfe2ce9b3b48e01905f00
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/cross-origin-OffscreenCanvas2D-transferToImageBitmap.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+<body>
+<canvas id='output' width='200' height='400'></canvas>
+<script src="/js-test-resources/js-test.js"></script>
+<script id='myWorker' type='text/worker'>
+self.onmessage = function(e) {
+ var aCanvas = new OffscreenCanvas(200, 400);
+ var ctx = aCanvas.getContext('2d');
+
+ // Draw a tainted imagebitmap into OffscreenCanvas 2d
+ ctx.drawImage(e.data, 0, 0, 10, 10);
+
+ var image = aCanvas.transferToImageBitmap();
+ self.postMessage(image, [image]);
+};
+</script>
+<script>
+description("The taintedness of the imagebitmap drawn to OffscrenCanvas must be transfered");
+
+window.jsTestIsAsync = true;
+
+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);
+ try {
+ var imageData = context.getImageData(0, 0, 10, 10);
+ testFailed("ImageBitmap is not tainted.");
+ } catch (e) {
+ testPassed("ImageBitmap is tainted. Threw error: " + e);
+ }
+}
+
+var blob = new Blob([document.getElementById('myWorker').textContent]);
+var worker = new Worker(URL.createObjectURL(blob));
+worker.addEventListener('message', msg => {
+ shouldBeTainted(msg.data);
+ finishJSTest();
+});
+
+var image = document.createElement('img');
+image.src = 'http://localhost:8080/security/resources/abe.png';
+image.addEventListener('load', function() {
+ createImageBitmap(image, 0, 0, 10, 10).then(
+ function(imagebitmap) {
+ // Post the tainted imagebitmap to worker
+ worker.postMessage(imagebitmap, [imagebitmap]);
+ },
+ function(e) {
+ testFailed("Image rejected unexpectedly. ");
+ debug(e);
+ }
+ );
+});
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698