chromium/third_party/blink/web_tests/http/tests/security/canvas-read-blocked-by-setting.html

<!DOCTYPE html>
<title>Block reading canvas via StrictCanvasTainting setting</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
if (window.testRunner)
    testRunner.overridePreference("WebKitDisableReadingFromCanvas", true);

var image = new Image();
var canvas = document.createElement('canvas');
canvas.width = 100;
canvas.height = 100;
var context = canvas.getContext('2d');

test(function () {
    assert_throws_dom(
        "SecurityError",
        function() {
            var imageData = context.getImageData(0, 0, 100, 100);
            assert_unreached('getImageData should throw');
        });
}, 'getImageData');

test(function () {
    assert_throws_dom(
        "SecurityError",
        function() {
            var data_url = canvas.toDataURL();
            assert_unreached('toDataURL should throw');
        });
}, 'toDataURL');

test(function () {
    assert_throws_dom(
        "SecurityError",
        function() {
            context.drawImage(image, 0, 0, 100, 100);
            var imageData = context.getImageData(0, 0, 100, 100);
            assert_unreached('getImageData should throw');
        });
}, 'getImageData');

test(function () {
    assert_throws_dom(
        "SecurityError",
        function() {
            context.drawImage(image, 0, 0, 100, 100);
            var data_url = canvas.toDataURL();
            assert_unreached('toDataURL should throw');
        });
}, 'toDataURL');

test(function () {
    assert_throws_dom(
        "SecurityError",
        function() {
            context.drawImage(image, 0, 0, 100, 100);
            canvas.toBlob(function(blob){});
            assert_unreached('toBlob should throw');
        });
}, 'toBlob');
</script>