diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element')
103 files changed, 3010 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d-getcontext-options.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d-getcontext-options.html new file mode 100644 index 0000000000..5d35d4108c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/2d-getcontext-options.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<title>Options conversion for getContext("2d")</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(() => { + const expected = [ + "alpha", + "colorSpace", + "colorSpace toString", + "desynchronized", + "willReadFrequently", + ]; + var actual = []; + const options = { + get alpha() { + actual.push("alpha"); + return true; + }, + get willReadFrequently() { + actual.push("willReadFrequently"); + return false; + }, + get desynchronized() { + actual.push("desynchronized"); + return false; + }, + get colorSpace() { + actual.push("colorSpace"); + return { + toString() { + actual.push("colorSpace toString"); + return "srgb"; + } + }; + }, + }; + + const canvas = document.createElement("canvas"); + const context = canvas.getContext('2d', options); + assert_not_equals(context, null, "context"); + assert_array_equals(actual, expected, "order of operations (creation)"); + actual = []; + assert_equals(canvas.getContext('2d', options), context, "cached context"); + assert_array_equals(actual, expected, "order of operations (caching)"); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-001.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-001.html new file mode 100644 index 0000000000..327c9f49d6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-001.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<title>Canvas descendants focusability</title> +<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#being-used-as-relevant-canvas-fallback-content"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#focusable-area"> +<meta name="assert" content="Checks that elements being used as relevant canvas + fallback content can be focusable even if not rendered."> +<div id="log"></div> +<canvas> + <button data-focusable="true"></button> + <section data-focusable="false"> + <div data-focusable="false"></div> + <span data-focusable="false"></span> + <a data-focusable="false"></a> + </section> + <section tabindex="-1" data-focusable="true"> + <div tabindex="-1" data-focusable="true"></div> + <span tabindex="-1" data-focusable="true"></span> + <a href="#" data-focusable="true"></a> + </section> +</canvas> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +for (let element of document.querySelectorAll("[data-focusable]")) { + let title = element.cloneNode(false).outerHTML.toLowerCase(); + title = title.slice(0, title.lastIndexOf("<")); + test(function() { + assert_true(document.activeElement !== element, "Not initially focused"); + element.focus(); + if (JSON.parse(element.dataset.focusable)) { + assert_true(document.activeElement === element, "Should be focused"); + } else { + assert_true(document.activeElement !== element, "Shouldn't be focused"); + } + }, title); +} +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-002.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-002.html new file mode 100644 index 0000000000..aa607365d5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-002.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<title>Canvas descendants focusability</title> +<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#being-used-as-relevant-canvas-fallback-content"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#focusable-area"> +<meta name="assert" content="Checks that descendants of a non-rendered canvas + aren't relevant canvas fallback content, so they aren't focusable."> +<div id="log"></div> +<canvas hidden> + <button data-focusable="false"></button> + <section tabindex="-1" data-focusable="false"> + <div tabindex="-1" data-focusable="false"></div> + <span tabindex="-1" data-focusable="false"></span> + <a href="#" data-focusable="false"></a> + </section> +</canvas> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +setup(() => { + const canvas = document.querySelector("canvas"); + assert_equals(canvas.getClientRects().length, 0, "Canvas not rendered"); +}); +for (let element of document.querySelectorAll("[data-focusable]")) { + let title = element.cloneNode(false).outerHTML.toLowerCase(); + title = title.slice(0, title.lastIndexOf("<")); + test(function() { + assert_equals(element.getClientRects().length, 0, "Not rendered"); + assert_true(document.activeElement !== element, "Not initially focused"); + element.focus(); + if (JSON.parse(element.dataset.focusable)) { + assert_true(document.activeElement === element, "Should be focused"); + } else { + assert_true(document.activeElement !== element, "Shouldn't be focused"); + } + }, title); +} +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-003.tentative.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-003.tentative.html new file mode 100644 index 0000000000..cd42d1e6b7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-003.tentative.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<title>Canvas descendants focusability</title> +<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#being-used-as-relevant-canvas-fallback-content"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#focusable-area"> +<link rel="help" href="https://github.com/whatwg/html/issues/7534"> +<meta name="assert" content="Checks that elements being used as relevant canvas + fallback content can't be focusable if they are not rendered because of an + explicit 'display: none' style, but can if they are not rendered because of + a 'display: contents' style."> +<div id="log"></div> +<canvas> + <button hidden data-focusable="false"></button> + <section hidden tabindex="-1" data-focusable="false"> + <div tabindex="-1" data-focusable="false"></div> + <span tabindex="-1" data-focusable="false"></span> + <a href="#" data-focusable="false"></a> + </section> + <button style="display: contents" data-focusable="true"></button> + <section style="display: contents" tabindex="-1" data-focusable="true"> + <div style="display: contents" tabindex="-1" data-focusable="true"></div> + <span style="display: contents" tabindex="-1" data-focusable="true"></span> + <a style="display: contents" href="#" data-focusable="true"></a> + </section> +</canvas> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +setup(() => { + const canvas = document.querySelector("canvas"); + assert_greater_than(canvas.getClientRects().length, 0, "Canvas is rendered"); +}); +for (let element of document.querySelectorAll("[data-focusable]")) { + let title = element.cloneNode(false).outerHTML.toLowerCase(); + title = title.slice(0, title.lastIndexOf("<")); + test(function() { + assert_equals(element.getClientRects().length, 0, "Not rendered"); + assert_true(document.activeElement !== element, "Not initially focused"); + element.focus(); + if (JSON.parse(element.dataset.focusable)) { + assert_true(document.activeElement === element, "Should be focused"); + } else { + assert_true(document.activeElement !== element, "Shouldn't be focused"); + } + }, title); +} +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-004.tentative.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-004.tentative.html new file mode 100644 index 0000000000..5d8dfcd2f4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-004.tentative.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<title>Canvas descendants focusability</title> +<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#being-used-as-relevant-canvas-fallback-content"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#focusable-area"> +<link rel="help" href="https://github.com/whatwg/html/issues/7534"> +<meta name="assert" content="Checks that elements being used as relevant canvas + fallback content can't be focusable if they are not in the flat tree."> +<div id="log"></div> +<canvas> + <section id="shadow-host"> + <button data-focusable="false"></button> + <section tabindex="-1" data-focusable="false"> + <div tabindex="-1" data-focusable="false"></div> + <span tabindex="-1" data-focusable="false"></span> + <a href="#" data-focusable="false"></a> + </section> + </section> +</canvas> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +setup(() => { + const canvas = document.querySelector("canvas"); + assert_greater_than(canvas.getClientRects().length, 0, "Canvas is rendered"); + const shadowHost = document.getElementById("shadow-host"); + const shadowRoot = shadowHost.attachShadow({ mode: "open" }); + const slot = document.createElement("slot"); + slot.name = "slot"; + shadowRoot.appendChild(slot); +}); +for (let element of document.querySelectorAll("[data-focusable]")) { + let title = element.cloneNode(false).outerHTML.toLowerCase(); + title = title.slice(0, title.lastIndexOf("<")); + test(function() { + assert_equals(element.getClientRects().length, 0, "Not rendered"); + assert_true(document.activeElement !== element, "Not initially focused"); + element.focus(); + if (JSON.parse(element.dataset.focusable)) { + assert_true(document.activeElement === element, "Should be focused"); + } else { + assert_true(document.activeElement !== element, "Shouldn't be focused"); + } + }, title); +} +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-005.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-005.html new file mode 100644 index 0000000000..f3bee6b06b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-005.html @@ -0,0 +1,61 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<title>Canvas descendants focusability</title> +<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#being-used-as-relevant-canvas-fallback-content"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#focusable-area"> +<meta name="assert" content="Checks that descendants of a canvas that represents + fallback content are not focusable if not rendered, as usual."> +<div id="log"></div> +<!-- Use a sandboxed iframe to disable scripting and make the canvas + represent its fallback content instead of embedded content. --> +<iframe sandbox="allow-same-origin" allow="focus-without-user-activation *" + srcdoc=' + <button data-focusable="true" a></button> + <canvas> + <button data-focusable="true"></button> + <section tabindex="-1" data-focusable="true"> + <div tabindex="-1" data-focusable="true"></div> + <span tabindex="-1" data-focusable="true"></span> + <a href="#" data-focusable="true"></a> + </section> + <button hidden data-focusable="false"></button> + <section tabindex="-1" hidden data-focusable="false"> + <div tabindex="-1" data-focusable="false"></div> + <span tabindex="-1" data-focusable="false"></span> + <a href="#" data-focusable="false"></a> + </section> + </canvas> + '></iframe> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +setup({ explicit_done: true }); +setup(async () => { + const iframe = document.querySelector("iframe"); + await new Promise(resolve => { + const win = iframe.contentWindow; + if (win.location.href === "about:blank" || + win.document.readyState !== "complete") { + iframe.addEventListener("load", resolve, {once: true}); + } else { + resolve(); + } + }); + const doc = iframe.contentDocument; + for (let element of doc.querySelectorAll("[data-focusable]")) { + let title = element.cloneNode(false).outerHTML.toLowerCase(); + title = title.slice(0, title.lastIndexOf("<")); + test(function() { + assert_true(doc.activeElement !== element, "Not initially focused"); + element.focus(); + if (JSON.parse(element.dataset.focusable)) { + assert_true(doc.activeElement === element, "Should be focused"); + } else { + assert_true(doc.activeElement !== element, "Shouldn't be focused"); + } + }, title); + } + done(); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.arguments.missing.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.arguments.missing.html new file mode 100644 index 0000000000..eb4d69aed0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.arguments.missing.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: context.arguments.missing</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>context.arguments.missing</h1> +<p class="desc"></p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test(""); +_addTest(function(canvas, ctx) { + +assert_throws_js(TypeError, function() { canvas.getContext(); }); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.casesensitive.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.casesensitive.html new file mode 100644 index 0000000000..8753185449 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.casesensitive.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: context.casesensitive</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>context.casesensitive</h1> +<p class="desc">Context name "2D" is unrecognised; matching is case sensitive</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Context name \"2D\" is unrecognised; matching is case sensitive"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext('2D'), null, "canvas.getContext('2D')", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.emptystring.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.emptystring.html new file mode 100644 index 0000000000..1f27225882 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.emptystring.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: context.emptystring</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>context.emptystring</h1> +<p class="desc">getContext with empty string returns null</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getContext with empty string returns null"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext(""), null, "canvas.getContext(\"\")", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.badname.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.badname.html new file mode 100644 index 0000000000..55d503036b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.badname.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: context.unrecognised.badname</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>context.unrecognised.badname</h1> +<p class="desc">getContext with unrecognised context name returns null</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getContext with unrecognised context name returns null"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext('This is not an implemented context in any real browser'), null, "canvas.getContext('This is not an implemented context in any real browser')", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.badsuffix.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.badsuffix.html new file mode 100644 index 0000000000..ea0a14aaed --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.badsuffix.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: context.unrecognised.badsuffix</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>context.unrecognised.badsuffix</h1> +<p class="desc">Context name "2d" plus a suffix is unrecognised</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Context name \"2d\" plus a suffix is unrecognised"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext("2d#"), null, "canvas.getContext(\"2d#\")", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.nullsuffix.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.nullsuffix.html new file mode 100644 index 0000000000..ea8db36a89 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.nullsuffix.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: context.unrecognised.nullsuffix</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>context.unrecognised.nullsuffix</h1> +<p class="desc">Context name "2d" plus a "\0" suffix is unrecognised</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Context name \"2d\" plus a \"\\0\" suffix is unrecognised"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext("2d\0"), null, "canvas.getContext(\"2d\\0\")", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.unicode.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.unicode.html new file mode 100644 index 0000000000..727ea3584f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/context.unrecognised.unicode.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: context.unrecognised.unicode</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>context.unrecognised.unicode</h1> +<p class="desc">Context name which kind of looks like "2d" is unrecognised</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Context name which kind of looks like \"2d\" is unrecognised"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.getContext("2\uFF44"), null, "canvas.getContext(\"2\\uFF44\")", "null"); // Fullwidth Latin Small Letter D + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.basic.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.basic.html new file mode 100644 index 0000000000..5aaf49adf7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.basic.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: fallback.basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>fallback.basic</h1> +<p class="desc">Fallback content is inserted into the DOM</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Fallback content is inserted into the DOM"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.childNodes.length, 1, "canvas.childNodes.length", "1"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.multiple.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.multiple.html new file mode 100644 index 0000000000..9585b06a4a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.multiple.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: fallback.multiple</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>fallback.multiple</h1> +<p class="desc">Fallback content with multiple elements</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL</p><p class="fallback">FAIL</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Fallback content with multiple elements"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.childNodes.length, 2, "canvas.childNodes.length", "2"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.nested.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.nested.html new file mode 100644 index 0000000000..14b19cd104 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/fallback.nested.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: fallback.nested</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>fallback.nested</h1> +<p class="desc">Fallback content containing another canvas (mostly testing parsers)</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><canvas><p class="fallback">FAIL (fallback content)</p></canvas><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Fallback content containing another canvas (mostly testing parsers)"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.childNodes.length, 2, "canvas.childNodes.length", "2"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/historical.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/historical.html new file mode 100644 index 0000000000..33044ffb1b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/historical.html @@ -0,0 +1,77 @@ +<!doctype html> +<meta charset=utf-8> +<title>Historical canvas features</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +var canvas, context, path2d; +setup(function() { + canvas = document.createElement("canvas"); + context = canvas.getContext('2d'); + path2d = new Path2D(); +}); +function t(member, obj) { + var name = obj === canvas ? "Canvas" : String(obj).match(/\[object (\S+)\]/)[1]; + test(function() { + assert_false(member in obj); + }, name + " support for " + member); +} +// added in https://github.com/whatwg/html/commit/0ecbf0e010df16d9c6d11eef6b2c58419158c4da +// renamed in https://github.com/whatwg/html/commit/2542a12cb25ee93534cbed1f31b5e1bc05fcdd0e +t("supportsContext", canvas); + +// removed in https://github.com/whatwg/html/commit/2cfb8e3f03d3166842d2ad0f661459d26e2a40eb +t("probablySupportsContext", canvas); + +// removed in https://github.com/whatwg/html/commit/ef72f55da4acdf266174225c6ca8bf2a650d0219 +t("width", context); +t("height", context); + +// removed in https://github.com/whatwg/html/commit/740634d0f30a3b76e9da166ac2fa8835fcc073ab +t("setContext", canvas); +t("transferControlToProxy", canvas); +t("CanvasProxy", window); +t("commit", canvas); +test(function() { + assert_throws_js(TypeError, function() { + new CanvasRenderingContext2D(); + }, 'no arguments'); + assert_throws_js(TypeError, function() { + new CanvasRenderingContext2D(1, 1); + }, 'with arguments'); +}, "CanvasRenderingContext2D constructors"); + +// removed in https://github.com/whatwg/html/commit/e1d04f49a38e2254a783c28987457a95a47d9511 +t("addPathByStrokingPath", path2d); +t("addText", path2d); +t("addPathByStrokingText", path2d); + +// renamed in https://github.com/whatwg/html/commit/fcb0756dd94d96df9b8355741d82fcd5ca0a6154 +test(function() { + var canvas = document.createElement('canvas'); + var context = canvas.getContext('bitmaprenderer'); + if (context) { + assert_false('transferImageBitmap' in context); + } +}, 'ImageBitmapRenderingContext support for transferImageBitmap'); + +// renamed in https://github.com/whatwg/html/commit/3aec2a7e04a3402201afd29c224b57fa54497517 +t('Path', window); + +// removed in https://github.com/whatwg/html/commit/d5759b0435091e4858c9bff90319cbe5b040eda2 +t('toDataURLHD', canvas); +t('toBlobHD', canvas); +t('createImageDataHD', context); +t('getImageDataHD', context); +t('putImageDataHD', context); +test(function() { + if ('ImageData' in window) { + assert_false('resolution' in new ImageData(1, 1)); + } +}, 'ImageData support for resolution'); + +// dropped/renamed in https://github.com/whatwg/html/commit/ff07c6d630fb986f6c4f64b2fb87387b4f89647d +t('drawSystemFocusRing', context); +t('drawCustomFocusRing', context); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/imagedata.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/imagedata.html new file mode 100644 index 0000000000..e124f8ff6e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/imagedata.html @@ -0,0 +1,58 @@ +<!doctype html> +<meta charset="utf-8"> +<title>ImageData Tests</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(function() { + assert_throws_dom("IndexSizeError", function() { + new ImageData(0, 1); + }); +}, "ImageData(w, h), width cannot be 0"); + +test(function() { + assert_throws_dom("IndexSizeError", function() { + new ImageData(1, 0); + }); +}, "ImageData(w, h), height cannot be 0"); + +test(function() { + var imageData = new ImageData(2, 3); + assert_equals(imageData.width, 2); + assert_equals(imageData.height, 3); + assert_equals(imageData.data.length, 24); + assert_true(imageData.data instanceof Uint8ClampedArray); +}, "ImageData(w, h), exposed attributes check"); + +test(function() { + assert_throws_dom("InvalidStateError", function() { + new ImageData(new Uint8ClampedArray(3), 1); + }); +}, "ImageData(buffer, w), the buffer size must be a multiple of 4"); + +test(function() { + assert_throws_dom("IndexSizeError", function() { + new ImageData(new Uint8ClampedArray(16), 3); + }); +}, "ImageData(buffer, w), buffer size must be a multiple of the image width"); + +test(function() { + assert_throws_dom("IndexSizeError", function() { + new ImageData(new Uint8ClampedArray(16), 4, 3); + }); +}, "ImageData(buffer, w, h), buffer.length == 4 * w * h must be true"); + +test(function() { + assert_throws_js(TypeError, function() { + new ImageData(new Int8Array(1), 1); + }); +}, "ImageData(buffer, w, opt h), Uint8ClampedArray argument type check"); + +test(function() { + var imageData = new ImageData(new Uint8ClampedArray(24), 2); + assert_equals(imageData.width, 2); + assert_equals(imageData.height, 3); + assert_equals(imageData.data.length, 24); + assert_true(imageData.data instanceof Uint8ClampedArray); +}, "ImageData(buffer, w, opt h), exposed attributes check"); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.colour.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.colour.html new file mode 100644 index 0000000000..166732a57b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.colour.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: initial.colour</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.colour</h1> +<p class="desc">Initial state is transparent black</p> + +<p class="notes">Output should be transparent black (not transparent anything-else), but manual +verification can only confirm that it's transparent - it's not possible to make +the actual blackness visible. + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="initial.colour.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Initial state is transparent black"); +_addTest(function(canvas, ctx) { + +_assertPixel(canvas, 20,20, 0,0,0,0); + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.colour.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.colour.png Binary files differnew file mode 100644 index 0000000000..eeedd0ff05 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.colour.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.clip.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.clip.html new file mode 100644 index 0000000000..ebf52bfa76 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.clip.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: initial.reset.clip</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.clip</h1> +<p class="desc">Resetting the canvas state resets the current clip region</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state resets the current clip region"); +_addTest(function(canvas, ctx) { + +canvas.width = 100; +ctx.rect(0, 0, 1, 1); +ctx.clip(); +canvas.width = 100; +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +_assertPixel(canvas, 20,20, 0,255,0,255); + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.different.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.different.html new file mode 100644 index 0000000000..d55dd250c0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.different.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: initial.reset.different</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.different</h1> +<p class="desc">Changing size resets canvas to transparent black</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="initial.reset.different.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Changing size resets canvas to transparent black"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 50, 50); +_assertPixel(canvas, 20,20, 255,0,0,255); +canvas.width = 50; +_assertPixel(canvas, 20,20, 0,0,0,0); + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.different.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.different.png Binary files differnew file mode 100644 index 0000000000..d83fdd55b1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.different.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.gradient.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.gradient.html new file mode 100644 index 0000000000..31b56ec8e9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.gradient.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: initial.reset.gradient</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.gradient</h1> +<p class="desc">Resetting the canvas state does not invalidate any existing gradients</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state does not invalidate any existing gradients"); +_addTest(function(canvas, ctx) { + +canvas.width = 50; +var g = ctx.createLinearGradient(0, 0, 100, 0); +g.addColorStop(0, '#0f0'); +g.addColorStop(1, '#0f0'); +canvas.width = 100; +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = g; +ctx.fillRect(0, 0, 100, 50); +_assertPixel(canvas, 50,25, 0,255,0,255); + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.path.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.path.html new file mode 100644 index 0000000000..3525377d2d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.path.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: initial.reset.path</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.path</h1> +<p class="desc">Resetting the canvas state resets the current path</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="initial.reset.path.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state resets the current path"); +_addTest(function(canvas, ctx) { + +canvas.width = 100; +ctx.rect(0, 0, 100, 50); +canvas.width = 100; +ctx.fillStyle = '#f00'; +ctx.fill(); +_assertPixel(canvas, 20,20, 0,0,0,0); + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.path.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.path.png Binary files differnew file mode 100644 index 0000000000..eeedd0ff05 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.path.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.pattern.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.pattern.html new file mode 100644 index 0000000000..28f8306d96 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.pattern.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: initial.reset.pattern</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.pattern</h1> +<p class="desc">Resetting the canvas state does not invalidate any existing patterns</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state does not invalidate any existing patterns"); +_addTest(function(canvas, ctx) { + +canvas.width = 30; +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 30, 50); +var p = ctx.createPattern(canvas, 'repeat-x'); +canvas.width = 100; +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = p; +ctx.fillRect(0, 0, 100, 50); +_assertPixel(canvas, 50,25, 0,255,0,255); + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.same.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.same.html new file mode 100644 index 0000000000..1a0872ba2c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.same.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: initial.reset.same</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.same</h1> +<p class="desc">Setting size (not changing the value) resets canvas to transparent black</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="initial.reset.same.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Setting size (not changing the value) resets canvas to transparent black"); +_addTest(function(canvas, ctx) { + +canvas.width = 100; +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 50, 50); +_assertPixel(canvas, 20,20, 255,0,0,255); +canvas.width = 100; +_assertPixel(canvas, 20,20, 0,0,0,0); + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.same.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.same.png Binary files differnew file mode 100644 index 0000000000..eeedd0ff05 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.same.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.transform.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.transform.html new file mode 100644 index 0000000000..36284ba498 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/initial.reset.transform.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: initial.reset.transform</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>initial.reset.transform</h1> +<p class="desc">Resetting the canvas state resets the current transformation matrix</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state resets the current transformation matrix"); +_addTest(function(canvas, ctx) { + +canvas.width = 100; +ctx.scale(0.1, 0.1); +canvas.width = 100; +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +_assertPixel(canvas, 20,20, 0,255,0,255); + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.dataURI.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.dataURI.html new file mode 100644 index 0000000000..93b560e82c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.dataURI.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.dataURI</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.dataURI</h1> +<p class="desc">data: URIs do not count as different-origin, and do not taint the canvas</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("data: URIs do not count as different-origin, and do not taint the canvas"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +var data = canvas.toDataURL(); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var img = new Image(); +deferTest(); +img.onload = t.step_func_done(function () +{ + ctx.drawImage(img, 0, 0); + canvas.toDataURL(); // should be permitted + _assertPixel(canvas, 50,25, 0,255,0,255); +}); +img.src = data; + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.canvas.cross.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.canvas.cross.html new file mode 100644 index 0000000000..3a32cf2c16 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.canvas.cross.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.drawImage.canvas.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.drawImage.canvas.cross</h1> +<p class="desc">drawImage of unclean canvas makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("drawImage of unclean canvas makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +ctx2.drawImage(document.getElementById('yellow.png'), 0, 0); +ctx.drawImage(canvas2, 0, 0); +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.canvas.redirect.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.canvas.redirect.html new file mode 100644 index 0000000000..5545205837 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.canvas.redirect.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.drawImage.canvas.redirect</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.drawImage.canvas.redirect</h1> +<p class="desc">drawImage of unclean canvas makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("drawImage of unclean canvas makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +ctx2.drawImage(document.getElementById('yellow.png'), 0, 0); +ctx.drawImage(canvas2, 0, 0); +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginRedirectYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.image.cross.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.image.cross.html new file mode 100644 index 0000000000..b58177edc5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.image.cross.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.drawImage.image.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.drawImage.image.cross</h1> +<p class="desc">drawImage of different-origin image makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("drawImage of different-origin image makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +ctx.drawImage(document.getElementById('yellow.png'), 0, 0); +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.image.redirect.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.image.redirect.html new file mode 100644 index 0000000000..4661554f9b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.drawImage.image.redirect.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.drawImage.image.redirect</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.drawImage.image.redirect</h1> +<p class="desc">drawImage of different-origin image makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("drawImage of different-origin image makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +ctx.drawImage(document.getElementById('yellow.png'), 0, 0); +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginRedirectYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.fillStyle.cross.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.fillStyle.cross.html new file mode 100644 index 0000000000..35f0c70723 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.fillStyle.cross.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.canvas.fillStyle.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.canvas.fillStyle.cross</h1> +<p class="desc">Setting fillStyle to a pattern of an unclean canvas makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting fillStyle to a pattern of an unclean canvas makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +ctx2.drawImage(document.getElementById('yellow.png'), 0, 0); +var p = ctx.createPattern(canvas2, 'repeat'); +ctx.fillStyle = p; +ctx.fillStyle = 'red'; +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.fillStyle.redirect.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.fillStyle.redirect.html new file mode 100644 index 0000000000..d17be93233 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.fillStyle.redirect.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.canvas.fillStyle.redirect</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.canvas.fillStyle.redirect</h1> +<p class="desc">Setting fillStyle to a pattern of an unclean canvas makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting fillStyle to a pattern of an unclean canvas makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +ctx2.drawImage(document.getElementById('yellow.png'), 0, 0); +var p = ctx.createPattern(canvas2, 'repeat'); +ctx.fillStyle = p; +ctx.fillStyle = 'red'; +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginRedirectYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.strokeStyle.cross.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.strokeStyle.cross.html new file mode 100644 index 0000000000..828becef8c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.strokeStyle.cross.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.canvas.strokeStyle.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.canvas.strokeStyle.cross</h1> +<p class="desc">Setting strokeStyle to a pattern of an unclean canvas makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting strokeStyle to a pattern of an unclean canvas makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +ctx2.drawImage(document.getElementById('yellow.png'), 0, 0); +var p = ctx.createPattern(canvas2, 'repeat'); +ctx.strokeStyle = p; +ctx.strokeStyle = 'red'; +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.strokeStyle.redirect.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.strokeStyle.redirect.html new file mode 100644 index 0000000000..c6e7a64c15 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.strokeStyle.redirect.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.canvas.strokeStyle.redirect</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.canvas.strokeStyle.redirect</h1> +<p class="desc">Setting strokeStyle to a pattern of an unclean canvas makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting strokeStyle to a pattern of an unclean canvas makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +ctx2.drawImage(document.getElementById('yellow.png'), 0, 0); +var p = ctx.createPattern(canvas2, 'repeat'); +ctx.strokeStyle = p; +ctx.strokeStyle = 'red'; +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginRedirectYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.timing.cross.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.timing.cross.html new file mode 100644 index 0000000000..1ae1c4928b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.timing.cross.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.canvas.timing.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.canvas.timing.cross</h1> +<p class="desc">Pattern safety depends on whether the source was origin-clean, not on whether it still is clean</p> + +<p class="notes">Disagrees with spec on "is" vs "was" +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Pattern safety depends on whether the source was origin-clean, not on whether it still is clean"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +ctx2.fillStyle = '#0f0'; +ctx2.fillRect(0, 0, 100, 50); +var p = ctx.createPattern(canvas2, 'repeat'); +ctx2.drawImage(document.getElementById('yellow.png'), 0, 0); // make canvas2 origin-unclean +ctx.fillStyle = p; +ctx.fillRect(0, 0, 100, 50); +canvas.toDataURL(); +ctx.getImageData(0, 0, 1, 1); +_assert(true, "true"); // okay if there was no exception + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.timing.redirect.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.timing.redirect.html new file mode 100644 index 0000000000..f48366cd54 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.canvas.timing.redirect.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.canvas.timing.redirect</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.canvas.timing.redirect</h1> +<p class="desc">Pattern safety depends on whether the source was origin-clean, not on whether it still is clean</p> + +<p class="notes">Disagrees with spec on "is" vs "was" +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Pattern safety depends on whether the source was origin-clean, not on whether it still is clean"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +ctx2.fillStyle = '#0f0'; +ctx2.fillRect(0, 0, 100, 50); +var p = ctx.createPattern(canvas2, 'repeat'); +ctx2.drawImage(document.getElementById('yellow.png'), 0, 0); // make canvas2 origin-unclean +ctx.fillStyle = p; +ctx.fillRect(0, 0, 100, 50); +canvas.toDataURL(); +ctx.getImageData(0, 0, 1, 1); +_assert(true, "true"); // okay if there was no exception + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginRedirectYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.create.cross.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.create.cross.html new file mode 100644 index 0000000000..e0d3d10556 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.create.cross.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.create.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.create.cross</h1> +<p class="desc">Creating an unclean pattern does not make the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Creating an unclean pattern does not make the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var p = ctx.createPattern(document.getElementById('yellow.png'), 'repeat'); +canvas.toDataURL(); +ctx.getImageData(0, 0, 1, 1); +_assert(true, "true"); // okay if there was no exception + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.create.redirect.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.create.redirect.html new file mode 100644 index 0000000000..3fb7cf98b2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.create.redirect.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.create.redirect</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.create.redirect</h1> +<p class="desc">Creating an unclean pattern does not make the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Creating an unclean pattern does not make the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var p = ctx.createPattern(document.getElementById('yellow.png'), 'repeat'); +canvas.toDataURL(); +ctx.getImageData(0, 0, 1, 1); +_assert(true, "true"); // okay if there was no exception + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginRedirectYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.cross.cross.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.cross.cross.html new file mode 100644 index 0000000000..2dd14a87a9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.cross.cross.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.cross.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.cross.cross</h1> +<p class="desc">Using an unclean pattern makes the target canvas origin-unclean, not the pattern canvas</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Using an unclean pattern makes the target canvas origin-unclean, not the pattern canvas"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +var p = ctx2.createPattern(document.getElementById('yellow.png'), 'repeat'); +ctx.fillStyle = p; +ctx.fillRect(0, 0, 100, 50); +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); +canvas2.toDataURL(); +ctx2.getImageData(0, 0, 1, 1); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.cross.redirect.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.cross.redirect.html new file mode 100644 index 0000000000..8d69ea0afc --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.cross.redirect.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.cross.redirect</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.cross.redirect</h1> +<p class="desc">Using an unclean pattern makes the target canvas origin-unclean, not the pattern canvas</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Using an unclean pattern makes the target canvas origin-unclean, not the pattern canvas"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +canvas2.width = 100; +canvas2.height = 50; +var ctx2 = canvas2.getContext('2d'); +var p = ctx2.createPattern(document.getElementById('yellow.png'), 'repeat'); +ctx.fillStyle = p; +ctx.fillRect(0, 0, 100, 50); +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); +canvas2.toDataURL(); +ctx2.getImageData(0, 0, 1, 1); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginRedirectYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.fillStyle.sub.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.fillStyle.sub.html new file mode 100644 index 0000000000..a1053c04a4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.fillStyle.sub.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: security.pattern.canvas.fillStyle.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/get-host-info.sub.js"></script> +<script src="/common/media.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<body> +<p class="desc">Setting fillStyle to a pattern of an unclean canvas makes the canvas origin-unclean</p> + +<script> + +forEachCanvasSource(get_host_info().HTTP_REMOTE_ORIGIN, + get_host_info().HTTP_ORIGIN, + (name, factory) => { + promise_test(_ => { + return factory().then(source => { + const canvas = document.createElement('canvas'); + const ctx = canvas.getContext('2d'); + const pattern = ctx.createPattern(source, 'repeat'); + ctx.fillStyle = pattern; + ctx.fillStyle = 'red'; + assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); + assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + }); + }, `${name}: Setting fillStyle to an origin-unclean pattern makes the canvas origin-unclean`); +}); + +forEachCanvasSource(get_host_info().HTTP_REMOTE_ORIGIN, + get_host_info().HTTP_ORIGIN, + (name, factory) => { + promise_test(_ => { + return factory().then(source => { + const pattern = new OffscreenCanvas(10, 10) + .getContext('2d') + .createPattern(source, 'repeat'); + + const canvas = document.createElement('canvas'); + const ctx = canvas.getContext('2d'); + ctx.fillStyle = pattern; + ctx.fillStyle = 'red'; + assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); + assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + }); + }, `${name}: Setting fillStyle to an origin-unclean offscreen canvas pattern makes the canvas origin-unclean`); +}); + +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.fillStyle.cross.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.fillStyle.cross.html new file mode 100644 index 0000000000..1d7dc1d84f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.fillStyle.cross.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.image.fillStyle.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.image.fillStyle.cross</h1> +<p class="desc">Setting fillStyle to a pattern of a different-origin image makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting fillStyle to a pattern of a different-origin image makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var p = ctx.createPattern(document.getElementById('yellow.png'), 'repeat'); +ctx.fillStyle = p; +ctx.fillStyle = 'red'; +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.fillStyle.redirect.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.fillStyle.redirect.html new file mode 100644 index 0000000000..3af917705b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.fillStyle.redirect.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.image.fillStyle.redirect</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.image.fillStyle.redirect</h1> +<p class="desc">Setting fillStyle to a pattern of a different-origin image makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting fillStyle to a pattern of a different-origin image makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var p = ctx.createPattern(document.getElementById('yellow.png'), 'repeat'); +ctx.fillStyle = p; +ctx.fillStyle = 'red'; +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginRedirectYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.strokeStyle.cross.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.strokeStyle.cross.html new file mode 100644 index 0000000000..e35535af43 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.strokeStyle.cross.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.image.strokeStyle.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.image.strokeStyle.cross</h1> +<p class="desc">Setting strokeStyle to a pattern of a different-origin image makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting strokeStyle to a pattern of a different-origin image makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var p = ctx.createPattern(document.getElementById('yellow.png'), 'repeat'); +ctx.strokeStyle = p; +ctx.strokeStyle = 'red'; +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.strokeStyle.redirect.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.strokeStyle.redirect.html new file mode 100644 index 0000000000..09df15d24f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.pattern.image.strokeStyle.redirect.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.pattern.image.strokeStyle.redirect</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.pattern.image.strokeStyle.redirect</h1> +<p class="desc">Setting strokeStyle to a pattern of a different-origin image makes the canvas origin-unclean</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting strokeStyle to a pattern of a different-origin image makes the canvas origin-unclean"); +_addTest(function(canvas, ctx) { + +var p = ctx.createPattern(document.getElementById('yellow.png'), 'repeat'); +ctx.strokeStyle = p; +ctx.strokeStyle = 'red'; +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +assert_throws_dom("SECURITY_ERR", function() { ctx.getImageData(0, 0, 1, 1); }); + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginRedirectYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.reset.cross.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.reset.cross.html new file mode 100644 index 0000000000..f823bbd8ac --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.reset.cross.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.reset.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.reset.cross</h1> +<p class="desc">Resetting the canvas state resets the origin-clean flag</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state resets the origin-clean flag"); +_addTest(function(canvas, ctx) { + +canvas.width = 50; +ctx.drawImage(document.getElementById('yellow.png'), 0, 0); +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +canvas.width = 100; +canvas.toDataURL(); +ctx.getImageData(0, 0, 1, 1); +_assert(true, "true"); // okay if there was no exception + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.reset.redirect.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.reset.redirect.html new file mode 100644 index 0000000000..af881c5fdc --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/security.reset.redirect.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: security.reset.redirect</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>security.reset.redirect</h1> +<p class="desc">Resetting the canvas state resets the origin-clean flag</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Resetting the canvas state resets the origin-clean flag"); +_addTest(function(canvas, ctx) { + +canvas.width = 50; +ctx.drawImage(document.getElementById('yellow.png'), 0, 0); +assert_throws_dom("SECURITY_ERR", function() { canvas.toDataURL(); }); +canvas.width = 100; +canvas.toDataURL(); +ctx.getImageData(0, 0, 1, 1); +_assert(true, "true"); // okay if there was no exception + + +}); +</script> +<script src="/common/get-host-info.sub.js"></script> +<script src="data:text/javascript,addCrossOriginRedirectYellowImage()"></script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.default.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.default.html new file mode 100644 index 0000000000..ecf35285a1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.default.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: size.attributes.default</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.default</h1> +<p class="desc">Default width/height when attributes are missing</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" ><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.default.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Default width/height when attributes are missing"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 300, "canvas.width", "300"); +_assertSame(canvas.height, 150, "canvas.height", "150"); +_assert(!canvas.hasAttribute('width'), "!canvas.hasAttribute('width')"); +_assert(!canvas.hasAttribute('height'), "!canvas.hasAttribute('height')"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.default.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.default.png Binary files differnew file mode 100644 index 0000000000..a72d047556 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.default.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.get.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.get.png Binary files differnew file mode 100644 index 0000000000..47830c83ea --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.get.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.idl.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.idl.html new file mode 100644 index 0000000000..1594a1c5e5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.idl.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: size.attributes.idl</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.idl</h1> +<p class="desc">Getting/setting width/height IDL attributes</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Getting/setting width/height IDL attributes"); +_addTest(function(canvas, ctx) { + +canvas.width = "100"; +canvas.height = "100"; +_assertSame(canvas.width, 100, "canvas.width", "100"); +_assertSame(canvas.height, 100, "canvas.height", "100"); + +canvas.width = "+1.5e2"; +canvas.height = "0x96"; +_assertSame(canvas.width, 150, "canvas.width", "150"); +_assertSame(canvas.height, 150, "canvas.height", "150"); + +canvas.width = 200 - Math.pow(2, 32); +canvas.height = 200 - Math.pow(2, 32); +_assertSame(canvas.width, 200, "canvas.width", "200"); +_assertSame(canvas.height, 200, "canvas.height", "200"); + +canvas.width = 301.999; +canvas.height = 301.001; +_assertSame(canvas.width, 301, "canvas.width", "301"); +_assertSame(canvas.height, 301, "canvas.height", "301"); + +canvas.width = "400x"; +canvas.height = "foo"; +_assertSame(canvas.width, 0, "canvas.width", "0"); +_assertSame(canvas.height, 0, "canvas.height", "0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.idl.set.zero.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.idl.set.zero.html new file mode 100644 index 0000000000..c09d5cb278 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.idl.set.zero.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: size.attributes.idl.set.zero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.idl.set.zero</h1> +<p class="desc">Setting width/height IDL attributes to 0</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting width/height IDL attributes to 0"); +_addTest(function(canvas, ctx) { + +canvas.width = 0; +canvas.height = 0; +_assertSame(canvas.width, 0, "canvas.width", "0"); +_assertSame(canvas.height, 0, "canvas.height", "0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setcontent.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setcontent.html new file mode 100644 index 0000000000..a25c4b784a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setcontent.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: size.attributes.reflect.setcontent</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.reflect.setcontent</h1> +<p class="desc">Setting content attributes updates IDL and content attributes</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.reflect.setcontent.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Setting content attributes updates IDL and content attributes"); +_addTest(function(canvas, ctx) { + +canvas.setAttribute('width', '120'); +canvas.setAttribute('height', '60'); +_assertSame(canvas.getAttribute('width'), '120', "canvas.getAttribute('width')", "'120'"); +_assertSame(canvas.getAttribute('height'), '60', "canvas.getAttribute('height')", "'60'"); +_assertSame(canvas.width, 120, "canvas.width", "120"); +_assertSame(canvas.height, 60, "canvas.height", "60"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setcontent.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setcontent.png Binary files differnew file mode 100644 index 0000000000..47830c83ea --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setcontent.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidl.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidl.html new file mode 100644 index 0000000000..e228276da7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidl.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: size.attributes.reflect.setidl</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.reflect.setidl</h1> +<p class="desc">Setting IDL attributes updates IDL and content attributes</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.reflect.setidl.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Setting IDL attributes updates IDL and content attributes"); +_addTest(function(canvas, ctx) { + +canvas.width = 120; +canvas.height = 60; +_assertSame(canvas.getAttribute('width'), '120', "canvas.getAttribute('width')", "'120'"); +_assertSame(canvas.getAttribute('height'), '60', "canvas.getAttribute('height')", "'60'"); +_assertSame(canvas.width, 120, "canvas.width", "120"); +_assertSame(canvas.height, 60, "canvas.height", "60"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidl.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidl.png Binary files differnew file mode 100644 index 0000000000..47830c83ea --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidl.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidlzero.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidlzero.html new file mode 100644 index 0000000000..65df3f9f94 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.reflect.setidlzero.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: size.attributes.reflect.setidlzero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.reflect.setidlzero</h1> +<p class="desc">Setting IDL attributes to 0 updates IDL and content attributes</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("Setting IDL attributes to 0 updates IDL and content attributes"); +_addTest(function(canvas, ctx) { + +canvas.width = 0; +canvas.height = 0; +_assertSame(canvas.getAttribute('width'), '0', "canvas.getAttribute('width')", "'0'"); +_assertSame(canvas.getAttribute('height'), '0', "canvas.getAttribute('height')", "'0'"); +_assertSame(canvas.width, 0, "canvas.width", "0"); +_assertSame(canvas.height, 0, "canvas.height", "0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.removed.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.removed.html new file mode 100644 index 0000000000..c96cba7b17 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.removed.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: size.attributes.removed</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.removed</h1> +<p class="desc">Removing content attributes reverts to default size</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="120" height="60"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.removed.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Removing content attributes reverts to default size"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 120, "canvas.width", "120"); +canvas.removeAttribute('width'); +_assertSame(canvas.width, 300, "canvas.width", "300"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.removed.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.removed.png Binary files differnew file mode 100644 index 0000000000..1ebf30d8aa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.removed.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.set.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.set.png Binary files differnew file mode 100644 index 0000000000..47830c83ea --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.set.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.style.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.style.html new file mode 100644 index 0000000000..aeb5c7ecb2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.style.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: size.attributes.style</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>size.attributes.style</h1> +<p class="desc">Canvas size is independent of CSS resizing</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="50" height="30" style="width: 100px; height: 50px"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="size.attributes.style.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("Canvas size is independent of CSS resizing"); +_addTest(function(canvas, ctx) { + +_assertSame(canvas.width, 50, "canvas.width", "50"); +_assertSame(canvas.height, 30, "canvas.height", "30"); + + +}); +</script> + + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.style.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.style.png Binary files differnew file mode 100644 index 0000000000..eeedd0ff05 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/size.attributes.style.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob-cross-realm-callback-report-exception.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob-cross-realm-callback-report-exception.html new file mode 100644 index 0000000000..393170baad --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob-cross-realm-callback-report-exception.html @@ -0,0 +1,29 @@ +<!doctype html> +<meta charset=utf-8> +<title>toBlob() reports the exception from its callback in the callback's global object</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<iframe srcdoc="<canvas></canvas>"></iframe> +<iframe></iframe> +<iframe></iframe> +<script> +setup({ allow_uncaught_exception: true }); + +const onerrorCalls = []; +window.onerror = () => { onerrorCalls.push("top"); }; +frames[0].onerror = () => { onerrorCalls.push("frame0"); }; +frames[1].onerror = () => { onerrorCalls.push("frame1"); }; +frames[2].onerror = () => { onerrorCalls.push("frame2"); }; + +async_test(t => { + window.onload = t.step_func(() => { + const canvas = frames[0].document.querySelector("canvas"); + canvas.toBlob(new frames[1].Function(`throw new parent.frames[2].Error("PASS");`)); + + t.step_timeout(() => { + assert_array_equals(onerrorCalls, ["frame1"]); + t.done(); + }, 25); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.jpeg.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.jpeg.html new file mode 100644 index 0000000000..1a95d4a6dd --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.jpeg.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<title>Canvas test: toBlob.jpeg</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<canvas id="c"></canvas> +<script> +async_test(function() { + on_event(window, "load", this.step_func(function() { + var canvas = document.getElementById('c'); + var ctx = canvas.getContext('2d'); + canvas.toBlob(this.step_func_done(function(data) { + assert_equals(data.type, "image/jpeg"); + }), 'image/jpeg'); + })); +}, "toBlob with image/jpeg returns a JPEG Blob"); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.null.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.null.html new file mode 100644 index 0000000000..11368a169c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.null.html @@ -0,0 +1,33 @@ +<!doctype html> +<meta charset=utf-8> +<title>Canvas test: toBlob.null</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toBlob.null</h1> +<p class="desc">toBlob with zero dimension returns a null Blob</p> + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="0"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +async_test(function() { + on_event(window, "load", this.step_func(function() { + var toBlobCalled = false; + c.toBlob(this.step_func(function(blob) { + toBlobCalled = true; + _assertSame(blob, null, "blob", "null"); + c.width = 0; + c.height = 100; + c.toBlob(this.step_func_done(function(blob) { + _assertSame(blob, null, "blob", "null"); + }), 'image/jpeg'); + }), 'image/jpeg'); + assert_false(toBlobCalled, "toBlob callback shouldn't be called synchronously"); + })); +}, "toBlob with zero dimension returns a null Blob"); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.png.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.png.html new file mode 100644 index 0000000000..1533bfdb6c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toBlob.png.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<title>Canvas test: toBlob.png</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<canvas id="c"></canvas> +<script> +async_test(function() { + on_event(window, "load", this.step_func(function() { + var canvas = document.getElementById('c'); + var ctx = canvas.getContext('2d'); + canvas.toBlob(this.step_func_done(function(data) { + assert_equals(data.type, "image/png"); + }), 'image/png'); + })); +}, "toBlob with image/png returns a PNG Blob"); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.1.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.1.html new file mode 100644 index 0000000000..8ed134c6b9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.1.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.arguments.1</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.arguments.1</h1> +<p class="desc">toDataURL ignores extra arguments</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL ignores extra arguments"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('image/png', 'another argument that should not raise an exception'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.2.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.2.html new file mode 100644 index 0000000000..5226c215f6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.2.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.arguments.2</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.arguments.2</h1> +<p class="desc">toDataURL ignores extra arguments</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL ignores extra arguments"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('image/png', 'another argument that should not raise an exception', 'and another'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.3.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.3.html new file mode 100644 index 0000000000..23b3e33ed8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.arguments.3.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.arguments.3</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.arguments.3</h1> +<p class="desc">toDataURL ignores extra arguments</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL ignores extra arguments"); +_addTest(function(canvas, ctx) { + +// More arguments that should not raise exceptions +var data = canvas.toDataURL('image/png', null, null, null); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.bogustype.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.bogustype.html new file mode 100644 index 0000000000..9b2414fc0b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.bogustype.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.bogustype</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.bogustype</h1> +<p class="desc">toDataURL with a syntactically invalid type returns a PNG</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with a syntactically invalid type returns a PNG"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('bogus'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.default.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.default.html new file mode 100644 index 0000000000..8bae384373 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.default.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.default</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.default</h1> +<p class="desc">toDataURL with no arguments returns a PNG</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with no arguments returns a PNG"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL(); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.alpha.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.alpha.html new file mode 100644 index 0000000000..daf278351d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.alpha.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.jpeg.alpha</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.jpeg.alpha</h1> +<p class="desc">toDataURL with JPEG composites onto black</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="toDataURL.jpeg.alpha.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with JPEG composites onto black"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = 'rgba(128, 255, 128, 0.5)'; +ctx.fillRect(0, 0, 100, 50); +ctx.globalCompositeOperation = 'destination-over'; // should be ignored by toDataURL +var data = canvas.toDataURL('image/jpeg'); +ctx.globalCompositeOperation = 'source-over'; +if (!data.match(/^data:image\/jpeg[;,]/)) { + _assert(true, "true"); +} else { + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + var img = new Image(); + deferTest(); + img.onload = t.step_func_done(function () + { + ctx.drawImage(img, 0, 0); + _assertPixelApprox(canvas, 50,25, 63,127,63,255, 8); + }); + img.src = data; +} + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.alpha.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.alpha.png Binary files differnew file mode 100644 index 0000000000..551871295c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.alpha.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.primarycolours.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.primarycolours.html new file mode 100644 index 0000000000..750487bdea --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.primarycolours.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.jpeg.primarycolours</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.jpeg.primarycolours</h1> +<p class="desc">toDataURL with JPEG handles simple colours correctly</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="toDataURL.jpeg.primarycolours.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with JPEG handles simple colours correctly"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#ff0'; +ctx.fillRect(0, 0, 25, 40); +ctx.fillStyle = '#0ff'; +ctx.fillRect(25, 0, 50, 40); +ctx.fillStyle = '#00f'; +ctx.fillRect(75, 0, 25, 40); +ctx.fillStyle = '#fff'; +ctx.fillRect(0, 40, 100, 10); +var data = canvas.toDataURL('image/jpeg'); // it is okay if this returns a PNG instead +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var img = new Image(); +deferTest(); +img.onload = t.step_func_done(function () +{ + ctx.drawImage(img, 0, 0); + _assertPixelApprox(canvas, 12,20, 255,255,0,255, 8); + _assertPixelApprox(canvas, 50,20, 0,255,255,255, 8); + _assertPixelApprox(canvas, 87,20, 0,0,255,255, 8); + _assertPixelApprox(canvas, 50,45, 255,255,255,255, 8); +}); +img.src = data; + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.primarycolours.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.primarycolours.png Binary files differnew file mode 100644 index 0000000000..cfd1369007 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.primarycolours.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.basic.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.basic.html new file mode 100644 index 0000000000..dc5d814244 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.basic.html @@ -0,0 +1,56 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.jpeg.quality.basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.jpeg.quality.basic</h1> +<p class="desc">toDataURL with JPEG uses the quality parameter</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="toDataURL.jpeg.quality.basic.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with JPEG uses the quality parameter"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#00f'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#0ff'; +ctx.fillRect(0, 3, 100, 1); +// Check for JPEG support first +var data = canvas.toDataURL('image/jpeg'); +if (!data.match(/^data:image\/jpeg[;,]/)) { + _assert(true, "true"); +} else { + var data_hi = canvas.toDataURL('image/jpeg', 0.99); + var data_lo = canvas.toDataURL('image/jpeg', 0.01); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + deferTest(); + var img_hi = new Image(); + img_hi.onload = function () + { + var img_lo = new Image(); + img_lo.onload = t.step_func_done(function () + { + ctx.drawImage(img_hi, 0, 0, 50, 50, 0, 0, 50, 50); + ctx.drawImage(img_lo, 0, 0, 50, 50, 50, 0, 50, 50); + _assert(data_hi.length > data_lo.length, "data_hi.length > data_lo.length"); + _assertPixelApprox(canvas, 25,25, 0,0,255,255, 8); + _assertPixelApprox(canvas, 75,25, 0,0,255,255, 32); + }); + img_lo.src = data_lo; + }; + img_hi.src = data_hi; +} + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.basic.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.basic.png Binary files differnew file mode 100644 index 0000000000..2f8a0bc790 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.basic.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.notnumber.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.notnumber.html new file mode 100644 index 0000000000..aa8066e67f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.notnumber.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.jpeg.quality.notnumber</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.jpeg.quality.notnumber</h1> +<p class="desc">toDataURL with JPEG handles non-numeric quality parameters</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with JPEG handles non-numeric quality parameters"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#00f'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#0ff'; +ctx.fillRect(0, 3, 100, 1); +// Check for JPEG support first +var data = canvas.toDataURL('image/jpeg'); +if (!data.match(/^data:image\/jpeg[;,]/)) { + _assert(true, "true"); +} else { + _assertSame(canvas.toDataURL('image/jpeg', 'bogus'), data, "canvas.toDataURL('image/jpeg', 'bogus')", "data"); + _assertSame(canvas.toDataURL('image/jpeg', {}), data, "canvas.toDataURL('image/jpeg', {})", "data"); + _assertSame(canvas.toDataURL('image/jpeg', null), data, "canvas.toDataURL('image/jpeg', null)", "data"); + _assertSame(canvas.toDataURL('image/jpeg', undefined), data, "canvas.toDataURL('image/jpeg', undefined)", "data"); + _assertSame(canvas.toDataURL('image/jpeg', true), data, "canvas.toDataURL('image/jpeg', true)", "data"); + _assertSame(canvas.toDataURL('image/jpeg', '0.01'), data, "canvas.toDataURL('image/jpeg', '0.01')", "data"); +} + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.outsiderange.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.outsiderange.html new file mode 100644 index 0000000000..9e40fb887b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpeg.quality.outsiderange.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.jpeg.quality.outsiderange</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.jpeg.quality.outsiderange</h1> +<p class="desc">toDataURL with JPEG handles out-of-range quality parameters</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with JPEG handles out-of-range quality parameters"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#00f'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#0ff'; +ctx.fillRect(0, 3, 100, 1); +// Check for JPEG support first +var data = canvas.toDataURL('image/jpeg'); +if (!data.match(/^data:image\/jpeg[;,]/)) { + _assert(true, "true"); +} else { + _assertSame(canvas.toDataURL('image/jpeg', 10), data, "canvas.toDataURL('image/jpeg', 10)", "data"); + _assertSame(canvas.toDataURL('image/jpeg', -10), data, "canvas.toDataURL('image/jpeg', -10)", "data"); + _assertSame(canvas.toDataURL('image/jpeg', 1.01), data, "canvas.toDataURL('image/jpeg', 1.01)", "data"); + _assertSame(canvas.toDataURL('image/jpeg', -0.01), data, "canvas.toDataURL('image/jpeg', -0.01)", "data"); + + _assert(canvas.toDataURL('image/jpeg', 1).length >= canvas.toDataURL('image/jpeg', 0.9).length, "canvas.toDataURL('image/jpeg', 1).length >= canvas.toDataURL('image/jpeg', 0.9).length"); + _assert(canvas.toDataURL('image/jpeg', 0).length <= canvas.toDataURL('image/jpeg', 0.1).length, "canvas.toDataURL('image/jpeg', 0).length <= canvas.toDataURL('image/jpeg', 0.1).length"); +} + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpg.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpg.html new file mode 100644 index 0000000000..e59793db70 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.jpg.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.jpg</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.jpg</h1> +<p class="desc">toDataURL with image/jpg is invalid type hence returns a PNG</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with image/jpg is invalid type hence returns a PNG"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('image/jpg'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.lowercase.ascii.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.lowercase.ascii.html new file mode 100644 index 0000000000..858035cc64 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.lowercase.ascii.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.lowercase.ascii</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.lowercase.ascii</h1> +<p class="desc">toDataURL type is case-insensitive</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL type is case-insensitive"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('ImAgE/PnG'); +assert_regexp_match(data, /^data:image\/png[;,]/); + +// If JPEG is supported at all, it must be supported case-insensitively +data = canvas.toDataURL('image/jpeg'); +if (data.match(/^data:image\/jpeg[;,]/)) { + data = canvas.toDataURL('ImAgE/JpEg'); + assert_regexp_match(data, /^data:image\/jpeg[;,]/); +} + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.lowercase.unicode.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.lowercase.unicode.html new file mode 100644 index 0000000000..123f966ee2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.lowercase.unicode.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.lowercase.unicode</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.lowercase.unicode</h1> +<p class="desc">toDataURL type is ASCII-case-insensitive</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL type is ASCII-case-insensitive"); +_addTest(function(canvas, ctx) { + +// Use LATIN CAPITAL LETTER I WITH DOT ABOVE (Unicode lowercase is "i") +var data = canvas.toDataURL('\u0130mage/png'); +assert_regexp_match(data, /^data:image\/png[;,]/); + +var data = canvas.toDataURL('\u0130mage/jpeg'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.nocontext.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.nocontext.html new file mode 100644 index 0000000000..704dc74fb9 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.nocontext.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.nocontext</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.nocontext</h1> +<p class="desc">toDataURL works before any context has been got</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL works before any context has been got"); +_addTest(function(canvas, ctx) { + +var no_context_data = canvas.toDataURL(); +var ctx = canvas.getContext('2d'); +ctx.rect(0, 0, 100, 50); +ctx.fillStyle = "rgba(0, 0, 0, 0)"; +ctx.fill(); +var data = canvas.toDataURL(); +assert_equals(no_context_data, data); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.complexcolours.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.complexcolours.html new file mode 100644 index 0000000000..dadea7c5b0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.complexcolours.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.png.complexcolours</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.png.complexcolours</h1> +<p class="desc">toDataURL with PNG handles non-primary and non-solid colours correctly</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="toDataURL.png.complexcolours.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with PNG handles non-primary and non-solid colours correctly"); +_addTest(function(canvas, ctx) { + +// (These values are chosen to survive relatively alright through being premultiplied) +ctx.fillStyle = 'rgba(1, 3, 254, 1)'; +ctx.fillRect(0, 0, 25, 25); +ctx.fillStyle = 'rgba(8, 252, 248, 0.75)'; +ctx.fillRect(25, 0, 25, 25); +ctx.fillStyle = 'rgba(6, 10, 250, 0.502)'; +ctx.fillRect(50, 0, 25, 25); +ctx.fillStyle = 'rgba(12, 16, 244, 0.25)'; +ctx.fillRect(75, 0, 25, 25); +var img = new Image(); +deferTest(); +img.onload = t.step_func_done(function () +{ + ctx.drawImage(img, 0, 25); + // (The alpha values do not really survive float->int conversion, so just + // do approximate comparisons) + _assertPixel(canvas, 12,40, 1,3,254,255); + _assertPixelApprox(canvas, 37,40, 8,252,248,191, 2); + _assertPixelApprox(canvas, 62,40, 6,10,250,127, 4); + _assertPixelApprox(canvas, 87,40, 12,16,244,63, 8); +}); +img.src = canvas.toDataURL(); + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.complexcolours.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.complexcolours.png Binary files differnew file mode 100644 index 0000000000..b5f9c118aa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.complexcolours.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.html new file mode 100644 index 0000000000..26c92a45a7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.png</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.png</h1> +<p class="desc">toDataURL with image/png returns a PNG</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with image/png returns a PNG"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('image/png'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.primarycolours.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.primarycolours.html new file mode 100644 index 0000000000..a13850d54e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.primarycolours.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.png.primarycolours</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.png.primarycolours</h1> +<p class="desc">toDataURL with PNG handles simple colours correctly</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="toDataURL.png.primarycolours.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with PNG handles simple colours correctly"); +_addTest(function(canvas, ctx) { + +ctx.fillStyle = '#ff0'; +ctx.fillRect(0, 0, 25, 40); +ctx.fillStyle = '#0ff'; +ctx.fillRect(25, 0, 50, 40); +ctx.fillStyle = '#00f'; +ctx.fillRect(75, 0, 25, 40); +ctx.fillStyle = '#fff'; +ctx.fillRect(0, 40, 100, 10); +var data = canvas.toDataURL(); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var img = new Image(); +deferTest(); +img.onload = t.step_func_done(function () +{ + ctx.drawImage(img, 0, 0); + _assertPixel(canvas, 12,20, 255,255,0,255); + _assertPixel(canvas, 50,20, 0,255,255,255); + _assertPixel(canvas, 87,20, 0,0,255,255); + _assertPixel(canvas, 50,45, 255,255,255,255); +}); +img.src = data; + + +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.primarycolours.png b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.primarycolours.png Binary files differnew file mode 100644 index 0000000000..cfd1369007 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.png.primarycolours.png diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.unrecognised.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.unrecognised.html new file mode 100644 index 0000000000..835a898027 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.unrecognised.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.unrecognised</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.unrecognised</h1> +<p class="desc">toDataURL with an unhandled type returns a PNG</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL with an unhandled type returns a PNG"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL('image/example'); +assert_regexp_match(data, /^data:image\/png[;,]/); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zeroheight.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zeroheight.html new file mode 100644 index 0000000000..9b09beb6d6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zeroheight.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.zeroheight</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.zeroheight</h1> +<p class="desc">toDataURL on zero-size canvas returns 'data:,'</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" height="0"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL on zero-size canvas returns 'data:,'"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL(); +_assertSame(data, 'data:,', "data", "'data:,'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zerosize.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zerosize.html new file mode 100644 index 0000000000..4468104268 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zerosize.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.zerosize</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.zerosize</h1> +<p class="desc">toDataURL on zero-size canvas returns 'data:,'</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="0" height="0"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL on zero-size canvas returns 'data:,'"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL(); +_assertSame(data, 'data:,', "data", "'data:,'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zerowidth.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zerowidth.html new file mode 100644 index 0000000000..9ab3524352 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/toDataURL.zerowidth.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: toDataURL.zerowidth</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>toDataURL.zerowidth</h1> +<p class="desc">toDataURL on zero-size canvas returns 'data:,'</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="0"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("toDataURL on zero-size canvas returns 'data:,'"); +_addTest(function(canvas, ctx) { + +var data = canvas.toDataURL(); +_assertSame(data, 'data:,', "data", "'data:,'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.delete.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.delete.html new file mode 100644 index 0000000000..7fd54b30d5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.delete.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: type.delete</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>type.delete</h1> +<p class="desc">window.HTMLCanvasElement interface object is [[Configurable]]</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("window.HTMLCanvasElement interface object is [[Configurable]]"); +_addTest(function(canvas, ctx) { + +_assertSame(delete window.HTMLCanvasElement, true, "delete window.HTMLCanvasElement", "true"); +_assertSame(window.HTMLCanvasElement, undefined, "window.HTMLCanvasElement", "undefined"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.exists.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.exists.html new file mode 100644 index 0000000000..26f59a1614 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.exists.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: type.exists</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>type.exists</h1> +<p class="desc">HTMLCanvasElement is a property of window</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("HTMLCanvasElement is a property of window"); +_addTest(function(canvas, ctx) { + +_assert(window.HTMLCanvasElement, "window.HTMLCanvasElement"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.extend.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.extend.html new file mode 100644 index 0000000000..e17209f455 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.extend.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: type.extend</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>type.extend</h1> +<p class="desc">HTMLCanvasElement methods can be added, and the new methods used by canvases</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("HTMLCanvasElement methods can be added, and the new methods used by canvases"); +_addTest(function(canvas, ctx) { + +window.HTMLCanvasElement.prototype.getZero = function () { return 0; }; +_assertSame(canvas.getZero(), 0, "canvas.getZero()", "0"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.name.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.name.html new file mode 100644 index 0000000000..fdf1d1d398 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.name.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: type.name</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>type.name</h1> +<p class="desc">HTMLCanvasElement type and toString</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("HTMLCanvasElement type and toString"); +_addTest(function(canvas, ctx) { + +_assertSame(Object.prototype.toString.call(canvas), '[object HTMLCanvasElement]', "Object.prototype.toString.call(canvas)", "'[object HTMLCanvasElement]'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.prototype.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.prototype.html new file mode 100644 index 0000000000..f47f755388 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.prototype.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: type.prototype</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>type.prototype</h1> +<p class="desc">window.HTMLCanvasElement has prototype, which is { ReadOnly, DontDelete }. prototype has getContext, which is not</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("window.HTMLCanvasElement has prototype, which is { ReadOnly, DontDelete }. prototype has getContext, which is not"); +_addTest(function(canvas, ctx) { + +_assert(window.HTMLCanvasElement.prototype, "window.HTMLCanvasElement.prototype"); +_assert(window.HTMLCanvasElement.prototype.getContext, "window.HTMLCanvasElement.prototype.getContext"); +window.HTMLCanvasElement.prototype = null; +_assert(window.HTMLCanvasElement.prototype, "window.HTMLCanvasElement.prototype"); +delete window.HTMLCanvasElement.prototype; +_assert(window.HTMLCanvasElement.prototype, "window.HTMLCanvasElement.prototype"); +window.HTMLCanvasElement.prototype.getContext = 1; +_assertSame(window.HTMLCanvasElement.prototype.getContext, 1, "window.HTMLCanvasElement.prototype.getContext", "1"); +delete window.HTMLCanvasElement.prototype.getContext; +_assertSame(window.HTMLCanvasElement.prototype.getContext, undefined, "window.HTMLCanvasElement.prototype.getContext", "undefined"); + + +}); +</script> + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.replace.html b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.replace.html new file mode 100644 index 0000000000..e67fe7c4a2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-canvas-element/type.replace.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: type.replace</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>type.replace</h1> +<p class="desc">HTMLCanvasElement methods can be replaced, and the replacement methods used by canvases</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("HTMLCanvasElement methods can be replaced, and the replacement methods used by canvases"); +_addTest(function(canvas, ctx) { + +window.HTMLCanvasElement.prototype.getContext = function (name) { return 0; }; +_assertSame(canvas.getContext('2d'), 0, "canvas.getContext('2d')", "0"); + + +}); +</script> + |