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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/offscreen-canvas-worker-read-blocked-by-setting.html

Issue 2171563002: Add WorkerSettings to expose certain flag values in WorkerGlobalScope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added expected 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
Index: third_party/WebKit/LayoutTests/http/tests/security/offscreen-canvas-worker-read-blocked-by-setting.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/offscreen-canvas-worker-read-blocked-by-setting.html b/third_party/WebKit/LayoutTests/http/tests/security/offscreen-canvas-worker-read-blocked-by-setting.html
new file mode 100644
index 0000000000000000000000000000000000000000..687b41119c2cd77b35aa80a89b511528d74c494a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/offscreen-canvas-worker-read-blocked-by-setting.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<title>Block reading offscreen canvas via StrictCanvasTainting setting</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script id='myWorker' type='text/worker'>
+self.onmessage = function(e) {
+ var offCanvas = new OffscreenCanvas(100, 100);
+ var context = offCanvas.getContext('2d');
+
+ var name1 = "";
+ var message1 = message1;
+ try {
+ var imageData = context.getImageData(0, 0, 100, 100);
+ message1 = "getImageData should throw.";
+ } catch (e) {
+ name1 = e.name;
+ message1 = e.message;
+ }
+
+ var name2 = "";
+ var message2;
+ try {
+ context.drawImage(e.data, 0, 0, 100, 100);
+ var imageData = context.getImageData(0, 0, 100, 100);
+ message2 = "getImageData should throw";
+ } catch (e) {
+ name2 = e.name;
+ message2 = e.message;
+ }
+
+ self.postMessage([name1, message1, name2, message2]);
+};
+</script>
+<script>
+if (window.testRunner) {
+ testRunner.overridePreference("WebKitDisableReadingFromCanvas", true);
+ testRunner.waitUntilDone();
+}
+
+
+var htmlCanvas = document.createElement('canvas');
+htmlCanvas.width = 100;
+htmlCanvas.height = 100;
+var htmlCtx = htmlCanvas.getContext('2d');
+htmlCtx.fillStyle = "blue";
+htmlCtx.fillRect(0, 0, 100, 100);
+createImageBitmap(htmlCanvas).then(consumeImageBitmap);
+
+function consumeImageBitmap(htmlImage) {
+ var blob = new Blob([document.getElementById('myWorker').textContent]);
+ var worker = new Worker(URL.createObjectURL(blob));
+ worker.addEventListener('message', msg => {
+ assert_equals(msg.data[0], "SecurityError", msg.data[1]);
+ assert_equals(msg.data[2], "SecurityError", msg.data[3]);
+
+ if (window.testRunner) {
+ testRunner.notifyDone();
+ }
+ });
+ worker.postMessage(htmlImage, [htmlImage]);
+}
+</script>

Powered by Google App Engine
This is Rietveld 408576698