summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/resources
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/canvas/resources
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/canvas/resources')
-rw-r--r--testing/web-platform/tests/html/canvas/resources/2x2.pngbin0 -> 1575 bytes
-rw-r--r--testing/web-platform/tests/html/canvas/resources/canvas-frame.css21
-rw-r--r--testing/web-platform/tests/html/canvas/resources/canvas-frame.css.headers1
-rw-r--r--testing/web-platform/tests/html/canvas/resources/canvas-index.css31
-rw-r--r--testing/web-platform/tests/html/canvas/resources/canvas-index.css.headers1
-rw-r--r--testing/web-platform/tests/html/canvas/resources/canvas-spec.css50
-rw-r--r--testing/web-platform/tests/html/canvas/resources/canvas-spec.css.headers1
-rw-r--r--testing/web-platform/tests/html/canvas/resources/canvas-tests.css134
-rw-r--r--testing/web-platform/tests/html/canvas/resources/canvas-tests.css.headers1
-rw-r--r--testing/web-platform/tests/html/canvas/resources/canvas-tests.js221
-rw-r--r--testing/web-platform/tests/html/canvas/resources/canvas-tests.js.headers1
11 files changed, 462 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/canvas/resources/2x2.png b/testing/web-platform/tests/html/canvas/resources/2x2.png
new file mode 100644
index 0000000000..9be31562b3
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/resources/2x2.png
Binary files differ
diff --git a/testing/web-platform/tests/html/canvas/resources/canvas-frame.css b/testing/web-platform/tests/html/canvas/resources/canvas-frame.css
new file mode 100644
index 0000000000..0c97a680d1
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/resources/canvas-frame.css
@@ -0,0 +1,21 @@
+body {
+ font-size: small;
+ font-family: sans-serif;
+}
+
+p {
+ line-height: 0;
+}
+
+p:first-child {
+ display: inline;
+}
+
+h1 {
+ display: inline;
+}
+
+iframe, object {
+ border: 1px black solid;
+ margin: 2px;
+}
diff --git a/testing/web-platform/tests/html/canvas/resources/canvas-frame.css.headers b/testing/web-platform/tests/html/canvas/resources/canvas-frame.css.headers
new file mode 100644
index 0000000000..e13897f157
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/resources/canvas-frame.css.headers
@@ -0,0 +1 @@
+Content-Type: text/css; charset=utf-8
diff --git a/testing/web-platform/tests/html/canvas/resources/canvas-index.css b/testing/web-platform/tests/html/canvas/resources/canvas-index.css
new file mode 100644
index 0000000000..ef35864bc0
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/resources/canvas-index.css
@@ -0,0 +1,31 @@
+body {
+ font-size: small;
+ font-family: sans-serif;
+}
+
+a {
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+h3 {
+ display: inline;
+ font-size: medium;
+}
+
+h3 + p {
+ display: inline;
+ margin-left: 0.5em;
+}
+
+li {
+ list-style-type: none;
+}
+
+ul {
+ padding-left: 2em;
+ margin-left: 0;
+}
diff --git a/testing/web-platform/tests/html/canvas/resources/canvas-index.css.headers b/testing/web-platform/tests/html/canvas/resources/canvas-index.css.headers
new file mode 100644
index 0000000000..e13897f157
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/resources/canvas-index.css.headers
@@ -0,0 +1 @@
+Content-Type: text/css; charset=utf-8
diff --git a/testing/web-platform/tests/html/canvas/resources/canvas-spec.css b/testing/web-platform/tests/html/canvas/resources/canvas-spec.css
new file mode 100644
index 0000000000..5882acb68e
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/resources/canvas-spec.css
@@ -0,0 +1,50 @@
+.testrefs {
+ font-size: small;
+ margin-left: 0.2em;
+ margin-right: 0.2em;
+ border-bottom: none !important;
+
+ font-weight: normal;
+ font-style: normal;
+ white-space: normal;
+ font-family: sans-serif;
+}
+
+.kw-must, .kw-required {
+ background: #fda;
+}
+
+.kw-should {
+ background: #ffa;
+}
+
+.kw-none {
+ background: #dfa;
+}
+
+
+pre.idl .testrefs :link {
+ color: #00c;
+}
+
+pre.idl .testrefs :visited {
+ color: #609;
+}
+
+.testrefs a:hover {
+ background: transparent;
+ text-decoration: none;
+}
+
+.testrefs:before {
+ content: '[';
+}
+
+.testrefs:after {
+ content: ']';
+}
+
+.testrefs a:first-child {
+ font-weight: bold;
+ text-decoration: none;
+}
diff --git a/testing/web-platform/tests/html/canvas/resources/canvas-spec.css.headers b/testing/web-platform/tests/html/canvas/resources/canvas-spec.css.headers
new file mode 100644
index 0000000000..e13897f157
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/resources/canvas-spec.css.headers
@@ -0,0 +1 @@
+Content-Type: text/css; charset=utf-8
diff --git a/testing/web-platform/tests/html/canvas/resources/canvas-tests.css b/testing/web-platform/tests/html/canvas/resources/canvas-tests.css
new file mode 100644
index 0000000000..e006e812de
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/resources/canvas-tests.css
@@ -0,0 +1,134 @@
+html.fail {
+ background: #f66;
+}
+html.pass {
+ background: #6f6;
+}
+html.needs_check {
+ background: #99f;
+}
+
+body {
+ font-size: small;
+ font-family: sans-serif;
+ color: black;
+}
+
+a:link {
+ color: #00c;
+}
+a:visited {
+ color: #808;
+}
+
+body.framed {
+ font-size: x-small;
+}
+
+h1 {
+ font-size: larger;
+ margin: 0;
+ padding-left: 0.5em;
+ text-indent: -0.5em;
+}
+
+p {
+ margin: 0;
+}
+
+p.notes {
+ margin-bottom: 0.5em;
+ font-style: italic;
+}
+
+ul {
+ margin: 0;
+ margin-bottom: 0.5em;
+ padding: 0;
+ padding-left: 1em;
+}
+
+.refs {
+ font-style: italic;
+ margin-bottom: 0.5em;
+}
+
+.refs ul {
+ display: inline;
+ margin: 0;
+ padding: 0;
+}
+
+.refs li {
+ display: inline;
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+}
+
+canvas {
+ display: none;
+ visibility: hidden;
+ border: 2px #f0f solid;
+ background: url(../images/background.png);
+}
+
+img.expected {
+ display: none;
+ border: 2px #f0f solid;
+ background: url(../images/background.png);
+}
+
+iframe {
+ border: 2px #f0f solid;
+}
+
+.output {
+ display: none;
+}
+
+.show_output .output, .needs_check .output {
+ display: block !important;
+ visibility: visible !important;
+}
+
+.show_output #show_output {
+ display: none;
+}
+
+.resource {
+ visibility: hidden;
+ height: 0;
+}
+
+.fallback {
+ font-size: 2em;
+ font-weight: bold;
+ color: #a00;
+}
+
+
+html.minimal body {
+ color: white;
+}
+html.fail.minimal {
+ background: #f00;
+}
+html.pass.minimal {
+ background: #080;
+}
+html.needs_check.minimal {
+ background: #008;
+}
+.minimal #d {
+ display: none !important;
+}
+.minimal .expectedtext {
+ visibility: hidden !important;
+}
+#passtext, #failtext {
+ display: none;
+}
+.minimal.pass #passtext, .minimal.fail #failtext {
+ display: block;
+}
diff --git a/testing/web-platform/tests/html/canvas/resources/canvas-tests.css.headers b/testing/web-platform/tests/html/canvas/resources/canvas-tests.css.headers
new file mode 100644
index 0000000000..e13897f157
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/resources/canvas-tests.css.headers
@@ -0,0 +1 @@
+Content-Type: text/css; charset=utf-8
diff --git a/testing/web-platform/tests/html/canvas/resources/canvas-tests.js b/testing/web-platform/tests/html/canvas/resources/canvas-tests.js
new file mode 100644
index 0000000000..c6e2873283
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/resources/canvas-tests.js
@@ -0,0 +1,221 @@
+function _valToString(val)
+{
+ if (val === undefined || val === null)
+ return '[' + typeof(val) + ']';
+ return val.toString() + '[' + typeof(val) + ']';
+}
+
+function _assert(cond, text)
+{
+ assert_true(!!cond, text);
+}
+
+function _assertSame(a, b, text_a, text_b)
+{
+ var msg = text_a + ' === ' + text_b + ' (got ' + _valToString(a) +
+ ', expected ' + _valToString(b) + ')';
+ assert_equals(a, b, msg);
+}
+
+function _assertDifferent(a, b, text_a, text_b)
+{
+ var msg = text_a + ' !== ' + text_b + ' (got ' + _valToString(a) +
+ ', expected not ' + _valToString(b) + ')';
+ assert_not_equals(a, b, msg);
+}
+
+
+function _getPixel(canvas, x,y)
+{
+ var ctx = canvas.getContext('2d');
+ var imgdata = ctx.getImageData(x, y, 1, 1);
+ return [ imgdata.data[0], imgdata.data[1], imgdata.data[2], imgdata.data[3] ];
+}
+
+function _assertPixel(canvas, x, y, r, g, b, a)
+{
+ var c = _getPixel(canvas, x,y);
+ assert_equals(c[0], r, 'Red channel of the pixel at (' + x + ', ' + y + ')');
+ assert_equals(c[1], g, 'Green channel of the pixel at (' + x + ', ' + y + ')');
+ assert_equals(c[2], b, 'Blue channel of the pixel at (' + x + ', ' + y + ')');
+ assert_equals(c[3], a, 'Alpha channel of the pixel at (' + x + ', ' + y + ')');
+}
+
+function _assertPixelApprox(canvas, x, y, r, g, b, a, tolerance)
+{
+ var c = _getPixel(canvas, x,y);
+ assert_approx_equals(c[0], r, tolerance, 'Red channel of the pixel at (' + x + ', ' + y + ')');
+ assert_approx_equals(c[1], g, tolerance, 'Green channel of the pixel at (' + x + ', ' + y + ')');
+ assert_approx_equals(c[2], b, tolerance, 'Blue channel of the pixel at (' + x + ', ' + y + ')');
+ assert_approx_equals(c[3], a, tolerance, 'Alpha channel of the pixel at (' + x + ', ' + y + ')');
+}
+
+function _assertMatricesApproxEqual(matA, matB)
+{
+ A = matA.toFloat32Array();
+ B = matB.toFloat32Array();
+ assert_equals(A.length, B.length);
+ for (var i = 0; i < A.length; i++) {
+ assert_approx_equals(A[i], B[i], 10e-6);
+ }
+}
+
+function rad2deg(angle_in_radians) {
+ return angle_in_radians / Math.PI * 180;
+}
+
+function deg2rad(angle_in_degrees) {
+ return angle_in_degrees / 180 * Math.PI;
+}
+
+let _deferred = false;
+
+function deferTest() {
+ _deferred = true;
+}
+
+function _addTest(testFn, attributes={})
+{
+ on_event(window, "load", function()
+ {
+ t.step(function() {
+ var canvas = document.getElementById('c');
+ var ctx = canvas.getContext('2d', attributes);
+ t.step(testFn, window, canvas, ctx);
+ });
+
+ if (!_deferred) {
+ t.done();
+ }
+ });
+}
+
+function _assertGreen(ctx, canvasWidth, canvasHeight)
+{
+ var testColor = function(d, idx, expected) {
+ assert_equals(d[idx], expected, "d[" + idx + "]", String(expected));
+ };
+ var imagedata = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
+ var w = imagedata.width, h = imagedata.height, d = imagedata.data;
+ for (var i = 0; i < h; ++i) {
+ for (var j = 0; j < w; ++j) {
+ testColor(d, 4 * (w * i + j) + 0, 0);
+ testColor(d, 4 * (w * i + j) + 1, 255);
+ testColor(d, 4 * (w * i + j) + 2, 0);
+ testColor(d, 4 * (w * i + j) + 3, 255);
+ }
+ }
+}
+
+function addCrossOriginYellowImage()
+{
+ var img = new Image();
+ img.id = "yellow.png";
+ img.className = "resource";
+ img.src = get_host_info().HTTP_REMOTE_ORIGIN + "/images/yellow.png";
+ document.body.appendChild(img);
+}
+
+function addCrossOriginRedirectYellowImage()
+{
+ var img = new Image();
+ img.id = "yellow.png";
+ img.className = "resource";
+ img.src = get_host_info().HTTP_ORIGIN + "/common/redirect.py?location=" +
+ get_host_info().HTTP_REMOTE_ORIGIN + "/images/yellow.png";
+ document.body.appendChild(img);
+}
+
+function forEachCanvasSource(crossOriginUrl, sameOriginUrl, callback) {
+ function makeImage() {
+ return new Promise((resolve, reject) => {
+ const image = new Image();
+ image.onload = () => resolve(image);
+ image.onerror = reject;
+ image.src = crossOriginUrl + "/images/red.png";
+ });
+ }
+
+ const arguments = [
+ {
+ name: "cross-origin HTMLImageElement",
+ factory: makeImage,
+ },
+
+ {
+ name: "cross-origin SVGImageElement",
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const image = document.createElementNS("http://www.w3.org/2000/svg", "image");
+ image.onload = () => resolve(image);
+ image.onerror = reject;
+ image.setAttribute("externalResourcesRequired", "true");
+ image.setAttributeNS("http://www.w3.org/1999/xlink", 'xlink:href', crossOriginUrl + "/images/red.png");
+ document.body.appendChild(image);
+ });
+ },
+ },
+
+ {
+ name: "cross-origin HTMLVideoElement",
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const video = document.createElement("video");
+ video.oncanplaythrough = () => resolve(video);
+ video.preload = "auto";
+ video.onerror = reject;
+ video.src = getVideoURI(crossOriginUrl + "/media/movie_300");
+ });
+ },
+ },
+
+ {
+ name: "redirected to cross-origin HTMLVideoElement",
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const video = document.createElement("video");
+ video.oncanplaythrough = () => resolve(video);
+ video.preload = "auto";
+ video.onerror = reject;
+ video.src = "/common/redirect.py?location=" + getVideoURI(crossOriginUrl + "/media/movie_300");
+ });
+ },
+ },
+
+ {
+ name: "redirected to same-origin HTMLVideoElement",
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const video = document.createElement("video");
+ video.oncanplaythrough = () => resolve(video);
+ video.preload = "auto";
+ video.onerror = reject;
+ video.src = crossOriginUrl + "/common/redirect.py?location=" + getVideoURI(sameOriginUrl + "/media/movie_300");
+ });
+ },
+ },
+
+ {
+ name: "unclean HTMLCanvasElement",
+ factory: () => {
+ return makeImage().then(image => {
+ const canvas = document.createElement("canvas");
+ const context = canvas.getContext("2d");
+ context.drawImage(image, 0, 0);
+ return canvas;
+ });
+ },
+ },
+
+ {
+ name: "unclean ImageBitmap",
+ factory: () => {
+ return makeImage().then(createImageBitmap);
+ },
+ },
+ ];
+
+ for (let { name, factory } of arguments) {
+ callback(name, factory);
+ }
+}
diff --git a/testing/web-platform/tests/html/canvas/resources/canvas-tests.js.headers b/testing/web-platform/tests/html/canvas/resources/canvas-tests.js.headers
new file mode 100644
index 0000000000..6805c323df
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/resources/canvas-tests.js.headers
@@ -0,0 +1 @@
+Content-Type: text/javascript; charset=utf-8