diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/webmessaging/postMessage_cross_domain_image_transfer_2d.sub.htm | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webmessaging/postMessage_cross_domain_image_transfer_2d.sub.htm')
-rw-r--r-- | testing/web-platform/tests/webmessaging/postMessage_cross_domain_image_transfer_2d.sub.htm | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webmessaging/postMessage_cross_domain_image_transfer_2d.sub.htm b/testing/web-platform/tests/webmessaging/postMessage_cross_domain_image_transfer_2d.sub.htm new file mode 100644 index 0000000000..4faf979274 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/postMessage_cross_domain_image_transfer_2d.sub.htm @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/get-host-info.sub.js"></script> +<body> +<script> +// Create a 2D canvas filled in solid gray. +var size = 4; +var sourceCanvas = document.createElement('canvas'); +sourceCanvas.width = sourceCanvas.height = size; +var ctx = sourceCanvas.getContext('2d'); +ctx.fillStyle = "gray"; +ctx.fillRect(0, 0, size, size); +const expectedPixels = "{\"0\":128,\"1\":128,\"2\":128,\"3\":255,\"4\":128,\"5\":128,\"6\":128,\"7\":255,\"8\":128,\"9\":128,\"10\":128,\"11\":255,\"12\":128,\"13\":128,\"14\":128,\"15\":255,\"16\":128,\"17\":128,\"18\":128,\"19\":255,\"20\":128,\"21\":128,\"22\":128,\"23\":255,\"24\":128,\"25\":128,\"26\":128,\"27\":255,\"28\":128,\"29\":128,\"30\":128,\"31\":255,\"32\":128,\"33\":128,\"34\":128,\"35\":255,\"36\":128,\"37\":128,\"38\":128,\"39\":255,\"40\":128,\"41\":128,\"42\":128,\"43\":255,\"44\":128,\"45\":128,\"46\":128,\"47\":255,\"48\":128,\"49\":128,\"50\":128,\"51\":255,\"52\":128,\"53\":128,\"54\":128,\"55\":255,\"56\":128,\"57\":128,\"58\":128,\"59\":255,\"60\":128,\"61\":128,\"62\":128,\"63\":255}"; + +const {ORIGIN, REMOTE_ORIGIN, HTTP_NOTSAMESITE_ORIGIN} = get_host_info(); +for (let origin of [ORIGIN, REMOTE_ORIGIN, HTTP_NOTSAMESITE_ORIGIN]) { + promise_test(async t => { + let imageBitmap = await createImageBitmap(sourceCanvas); + + let frame = document.createElement('iframe'); + frame.src = origin + '/webmessaging/support/cross-domain-image-receive.htm'; + document.body.appendChild(frame); + await new Promise(resolve => { frame.onload = e => resolve(); }); + + frame.contentWindow.postMessage({image: imageBitmap}, "*", [imageBitmap]); + let reply = await new Promise(resolve => { + window.addEventListener('message', e => resolve(e.data), {once: true}); + }); + assert_equals(reply, expectedPixels); + }, `sending 2D canvas ImageBitmap to ${origin}`); +} +</script> +</body> |