mirror of
https://github.com/servo/servo.git
synced 2025-09-17 10:28:22 +01:00
Update web-platform-tests to revision 3137d1d2d7757366a69f8a449b458b5057e0e81e
This commit is contained in:
parent
81ca858678
commit
d6ba94ca28
2339 changed files with 89274 additions and 9328 deletions
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.canvas.readonly</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.canvas.readonly</h1>
|
||||
<p class="desc">canvas is readonly</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("canvas is readonly");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
var d = ctx.canvas;
|
||||
_assertDifferent(offscreenCanvas2, d, "offscreenCanvas2", "d");
|
||||
ctx.canvas = offscreenCanvas2;
|
||||
_assertSame(ctx.canvas, d, "ctx.canvas", "d");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,24 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.canvas.readonly
|
||||
// Description:canvas is readonly
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("canvas is readonly");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
var d = ctx.canvas;
|
||||
_assertDifferent(offscreenCanvas2, d, "offscreenCanvas2", "d");
|
||||
ctx.canvas = offscreenCanvas2;
|
||||
_assertSame(ctx.canvas, d, "ctx.canvas", "d");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.canvas.reference</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.canvas.reference</h1>
|
||||
<p class="desc">canvas refers back to its canvas</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("canvas refers back to its canvas");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
_assertSame(ctx.canvas, offscreenCanvas, "ctx.canvas", "offscreenCanvas");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.canvas.reference
|
||||
// Description:canvas refers back to its canvas
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("canvas refers back to its canvas");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
_assertSame(ctx.canvas, offscreenCanvas, "ctx.canvas", "offscreenCanvas");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.getcontext.exists</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.getcontext.exists</h1>
|
||||
<p class="desc">The 2D context is implemented</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("The 2D context is implemented");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
_assertDifferent(offscreenCanvas2.getContext('2d'), null, "offscreenCanvas2.getContext('2d')", "null");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.getcontext.exists
|
||||
// Description:The 2D context is implemented
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("The 2D context is implemented");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
_assertDifferent(offscreenCanvas2.getContext('2d'), null, "offscreenCanvas2.getContext('2d')", "null");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.getcontext.extraargs</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.getcontext.extraargs</h1>
|
||||
<p class="desc">The 2D context ignores extra getContext arguments</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("The 2D context ignores extra getContext arguments");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
_assertDifferent(offscreenCanvas2.getContext('2d', false, {}, [], 1, "2"), null, "offscreenCanvas2.getContext('2d', false, {}, [], 1, \"2\")", "null");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.getcontext.extraargs
|
||||
// Description:The 2D context ignores extra getContext arguments
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("The 2D context ignores extra getContext arguments");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
_assertDifferent(offscreenCanvas2.getContext('2d', false, {}, [], 1, "2"), null, "offscreenCanvas2.getContext('2d', false, {}, [], 1, \"2\")", "null");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.getcontext.shared</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.getcontext.shared</h1>
|
||||
<p class="desc">getContext('2d') returns objects which share canvas state</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("getContext('2d') returns objects which share canvas state");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var ctx2 = offscreenCanvas.getContext('2d');
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx2.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
_assertPixel(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,24 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.getcontext.shared
|
||||
// Description:getContext('2d') returns objects which share canvas state
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("getContext('2d') returns objects which share canvas state");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var ctx2 = offscreenCanvas.getContext('2d');
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx2.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
_assertPixel(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.getcontext.unique</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.getcontext.unique</h1>
|
||||
<p class="desc">getContext('2d') returns the same object</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("getContext('2d') returns the same object");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
_assertSame(offscreenCanvas2.getContext('2d'), offscreenCanvas2.getContext('2d'), "offscreenCanvas2.getContext('2d')", "offscreenCanvas2.getContext('2d')");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.getcontext.unique
|
||||
// Description:getContext('2d') returns the same object
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("getContext('2d') returns the same object");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
_assertSame(offscreenCanvas2.getContext('2d'), offscreenCanvas2.getContext('2d'), "offscreenCanvas2.getContext('2d')", "offscreenCanvas2.getContext('2d')");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: context.arguments.missing</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>context.arguments.missing</h1>
|
||||
<p class="desc"></p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext(); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:context.arguments.missing
|
||||
// Description:
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext(); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: context.casesensitive</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>context.casesensitive</h1>
|
||||
<p class="desc">Context name "2D" is unrecognised; matching is case sensitive</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Context name \"2D\" is unrecognised; matching is case sensitive");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext('2D'); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:context.casesensitive
|
||||
// Description:Context name "2D" is unrecognised; matching is case sensitive
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Context name \"2D\" is unrecognised; matching is case sensitive");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext('2D'); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: context.emptystring</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>context.emptystring</h1>
|
||||
<p class="desc">getContext with empty string returns null</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("getContext with empty string returns null");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext(""); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:context.emptystring
|
||||
// Description:getContext with empty string returns null
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("getContext with empty string returns null");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext(""); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: context.unrecognised.badname</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>context.unrecognised.badname</h1>
|
||||
<p class="desc">getContext with unrecognised context name returns null</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("getContext with unrecognised context name returns null");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext('This is not an implemented context in any real browser'); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:context.unrecognised.badname
|
||||
// Description:getContext with unrecognised context name returns null
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("getContext with unrecognised context name returns null");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext('This is not an implemented context in any real browser'); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: context.unrecognised.badsuffix</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>context.unrecognised.badsuffix</h1>
|
||||
<p class="desc">Context name "2d" plus a suffix is unrecognised</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Context name \"2d\" plus a suffix is unrecognised");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext("2d#"); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:context.unrecognised.badsuffix
|
||||
// Description:Context name "2d" plus a suffix is unrecognised
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Context name \"2d\" plus a suffix is unrecognised");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext("2d#"); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: context.unrecognised.nullsuffix</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>context.unrecognised.nullsuffix</h1>
|
||||
<p class="desc">Context name "2d" plus a "\0" suffix is unrecognised</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Context name \"2d\" plus a \"\\0\" suffix is unrecognised");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext("2d\0"); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:context.unrecognised.nullsuffix
|
||||
// Description:Context name "2d" plus a "\0" suffix is unrecognised
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Context name \"2d\" plus a \"\\0\" suffix is unrecognised");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext("2d\0"); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: context.unrecognised.unicode</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>context.unrecognised.unicode</h1>
|
||||
<p class="desc">Context name which kind of looks like "2d" is unrecognised</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Context name which kind of looks like \"2d\" is unrecognised");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext("2\uFF44"); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:context.unrecognised.unicode
|
||||
// Description:Context name which kind of looks like "2d" is unrecognised
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Context name which kind of looks like \"2d\" is unrecognised");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.getContext("2\uFF44"); });
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: initial.colour</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>initial.colour</h1>
|
||||
<p class="desc">Initial state is transparent black</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Initial state is transparent black");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
_assertPixel(offscreenCanvas, 20,20, 0,0,0,0, "20,20", "0,0,0,0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:initial.colour
|
||||
// Description:Initial state is transparent black
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Initial state is transparent black");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
_assertPixel(offscreenCanvas, 20,20, 0,0,0,0, "20,20", "0,0,0,0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,85 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: initial.reset.2dstate</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>initial.reset.2dstate</h1>
|
||||
<p class="desc">Resetting the canvas state resets 2D state variables</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Resetting the canvas state resets 2D state variables");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 100;
|
||||
var default_val;
|
||||
|
||||
default_val = ctx.strokeStyle;
|
||||
ctx.strokeStyle = "#ff0000";
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.strokeStyle, default_val, "ctx.strokeStyle", "default_val");
|
||||
|
||||
default_val = ctx.fillStyle;
|
||||
ctx.fillStyle = "#ff0000";
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.fillStyle, default_val, "ctx.fillStyle", "default_val");
|
||||
|
||||
default_val = ctx.globalAlpha;
|
||||
ctx.globalAlpha = 0.5;
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.globalAlpha, default_val, "ctx.globalAlpha", "default_val");
|
||||
|
||||
default_val = ctx.lineWidth;
|
||||
ctx.lineWidth = 0.5;
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.lineWidth, default_val, "ctx.lineWidth", "default_val");
|
||||
|
||||
default_val = ctx.lineCap;
|
||||
ctx.lineCap = "round";
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.lineCap, default_val, "ctx.lineCap", "default_val");
|
||||
|
||||
default_val = ctx.lineJoin;
|
||||
ctx.lineJoin = "round";
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.lineJoin, default_val, "ctx.lineJoin", "default_val");
|
||||
|
||||
default_val = ctx.miterLimit;
|
||||
ctx.miterLimit = 0.5;
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.miterLimit, default_val, "ctx.miterLimit", "default_val");
|
||||
|
||||
default_val = ctx.shadowOffsetX;
|
||||
ctx.shadowOffsetX = 5;
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.shadowOffsetX, default_val, "ctx.shadowOffsetX", "default_val");
|
||||
|
||||
default_val = ctx.shadowOffsetY;
|
||||
ctx.shadowOffsetY = 5;
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.shadowOffsetY, default_val, "ctx.shadowOffsetY", "default_val");
|
||||
|
||||
default_val = ctx.shadowBlur;
|
||||
ctx.shadowBlur = 5;
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.shadowBlur, default_val, "ctx.shadowBlur", "default_val");
|
||||
|
||||
default_val = ctx.shadowColor;
|
||||
ctx.shadowColor = "#ff0000";
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.shadowColor, default_val, "ctx.shadowColor", "default_val");
|
||||
|
||||
default_val = ctx.globalCompositeOperation;
|
||||
ctx.globalCompositeOperation = "copy";
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.globalCompositeOperation, default_val, "ctx.globalCompositeOperation", "default_val");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,81 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:initial.reset.2dstate
|
||||
// Description:Resetting the canvas state resets 2D state variables
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Resetting the canvas state resets 2D state variables");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 100;
|
||||
var default_val;
|
||||
|
||||
default_val = ctx.strokeStyle;
|
||||
ctx.strokeStyle = "#ff0000";
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.strokeStyle, default_val, "ctx.strokeStyle", "default_val");
|
||||
|
||||
default_val = ctx.fillStyle;
|
||||
ctx.fillStyle = "#ff0000";
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.fillStyle, default_val, "ctx.fillStyle", "default_val");
|
||||
|
||||
default_val = ctx.globalAlpha;
|
||||
ctx.globalAlpha = 0.5;
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.globalAlpha, default_val, "ctx.globalAlpha", "default_val");
|
||||
|
||||
default_val = ctx.lineWidth;
|
||||
ctx.lineWidth = 0.5;
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.lineWidth, default_val, "ctx.lineWidth", "default_val");
|
||||
|
||||
default_val = ctx.lineCap;
|
||||
ctx.lineCap = "round";
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.lineCap, default_val, "ctx.lineCap", "default_val");
|
||||
|
||||
default_val = ctx.lineJoin;
|
||||
ctx.lineJoin = "round";
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.lineJoin, default_val, "ctx.lineJoin", "default_val");
|
||||
|
||||
default_val = ctx.miterLimit;
|
||||
ctx.miterLimit = 0.5;
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.miterLimit, default_val, "ctx.miterLimit", "default_val");
|
||||
|
||||
default_val = ctx.shadowOffsetX;
|
||||
ctx.shadowOffsetX = 5;
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.shadowOffsetX, default_val, "ctx.shadowOffsetX", "default_val");
|
||||
|
||||
default_val = ctx.shadowOffsetY;
|
||||
ctx.shadowOffsetY = 5;
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.shadowOffsetY, default_val, "ctx.shadowOffsetY", "default_val");
|
||||
|
||||
default_val = ctx.shadowBlur;
|
||||
ctx.shadowBlur = 5;
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.shadowBlur, default_val, "ctx.shadowBlur", "default_val");
|
||||
|
||||
default_val = ctx.shadowColor;
|
||||
ctx.shadowColor = "#ff0000";
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.shadowColor, default_val, "ctx.shadowColor", "default_val");
|
||||
|
||||
default_val = ctx.globalCompositeOperation;
|
||||
ctx.globalCompositeOperation = "copy";
|
||||
offscreenCanvas.width = 100;
|
||||
_assertSame(ctx.globalCompositeOperation, default_val, "ctx.globalCompositeOperation", "default_val");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: initial.reset.clip</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>initial.reset.clip</h1>
|
||||
<p class="desc">Resetting the canvas state resets the current clip region</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Resetting the canvas state resets the current clip region");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.rect(0, 0, 1, 1);
|
||||
ctx.clip();
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
_assertPixel(offscreenCanvas, 20,20, 0,255,0,255, "20,20", "0,255,0,255");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,26 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:initial.reset.clip
|
||||
// Description:Resetting the canvas state resets the current clip region
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Resetting the canvas state resets the current clip region");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.rect(0, 0, 1, 1);
|
||||
ctx.clip();
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
_assertPixel(offscreenCanvas, 20,20, 0,255,0,255, "20,20", "0,255,0,255");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: initial.reset.different</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>initial.reset.different</h1>
|
||||
<p class="desc">Changing size resets canvas to transparent black</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Changing size resets canvas to transparent black");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 50, 50);
|
||||
_assertPixel(offscreenCanvas, 20,20, 255,0,0,255, "20,20", "255,0,0,255");
|
||||
offscreenCanvas.width = 50;
|
||||
_assertPixel(offscreenCanvas, 20,20, 0,0,0,0, "20,20", "0,0,0,0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,24 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:initial.reset.different
|
||||
// Description:Changing size resets canvas to transparent black
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Changing size resets canvas to transparent black");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 50, 50);
|
||||
_assertPixel(offscreenCanvas, 20,20, 255,0,0,255, "20,20", "255,0,0,255");
|
||||
offscreenCanvas.width = 50;
|
||||
_assertPixel(offscreenCanvas, 20,20, 0,0,0,0, "20,20", "0,0,0,0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: initial.reset.gradient</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>initial.reset.gradient</h1>
|
||||
<p class="desc">Resetting the canvas state does not invalidate any existing gradients</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Resetting the canvas state does not invalidate any existing gradients");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 50;
|
||||
var g = ctx.createLinearGradient(0, 0, 100, 0);
|
||||
g.addColorStop(0, '#0f0');
|
||||
g.addColorStop(1, '#0f0');
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
ctx.fillStyle = g;
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
_assertPixel(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,29 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:initial.reset.gradient
|
||||
// Description:Resetting the canvas state does not invalidate any existing gradients
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Resetting the canvas state does not invalidate any existing gradients");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 50;
|
||||
var g = ctx.createLinearGradient(0, 0, 100, 0);
|
||||
g.addColorStop(0, '#0f0');
|
||||
g.addColorStop(1, '#0f0');
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
ctx.fillStyle = g;
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
_assertPixel(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: initial.reset.path</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>initial.reset.path</h1>
|
||||
<p class="desc">Resetting the canvas state resets the current path</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Resetting the canvas state resets the current path");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.rect(0, 0, 100, 50);
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fill();
|
||||
_assertPixel(offscreenCanvas, 20,20, 0,0,0,0, "20,20", "0,0,0,0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,25 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:initial.reset.path
|
||||
// Description:Resetting the canvas state resets the current path
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Resetting the canvas state resets the current path");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.rect(0, 0, 100, 50);
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fill();
|
||||
_assertPixel(offscreenCanvas, 20,20, 0,0,0,0, "20,20", "0,0,0,0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: initial.reset.pattern</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>initial.reset.pattern</h1>
|
||||
<p class="desc">Resetting the canvas state does not invalidate any existing patterns</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Resetting the canvas state does not invalidate any existing patterns");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 30;
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 30, 50);
|
||||
var p = ctx.createPattern(offscreenCanvas, 'repeat-x');
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
ctx.fillStyle = p;
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
_assertPixel(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,29 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:initial.reset.pattern
|
||||
// Description:Resetting the canvas state does not invalidate any existing patterns
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Resetting the canvas state does not invalidate any existing patterns");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 30;
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 30, 50);
|
||||
var p = ctx.createPattern(offscreenCanvas, 'repeat-x');
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
ctx.fillStyle = p;
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
_assertPixel(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: initial.reset.same</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>initial.reset.same</h1>
|
||||
<p class="desc">Setting size (not changing the value) resets canvas to transparent black</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Setting size (not changing the value) resets canvas to transparent black");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 50, 50);
|
||||
_assertPixel(offscreenCanvas, 20,20, 255,0,0,255, "20,20", "255,0,0,255");
|
||||
offscreenCanvas.width = 100;
|
||||
_assertPixel(offscreenCanvas, 20,20, 0,0,0,0, "20,20", "0,0,0,0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,25 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:initial.reset.same
|
||||
// Description:Setting size (not changing the value) resets canvas to transparent black
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Setting size (not changing the value) resets canvas to transparent black");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 50, 50);
|
||||
_assertPixel(offscreenCanvas, 20,20, 255,0,0,255, "20,20", "255,0,0,255");
|
||||
offscreenCanvas.width = 100;
|
||||
_assertPixel(offscreenCanvas, 20,20, 0,0,0,0, "20,20", "0,0,0,0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: initial.reset.transform</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>initial.reset.transform</h1>
|
||||
<p class="desc">Resetting the canvas state resets the current transformation matrix</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Resetting the canvas state resets the current transformation matrix");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.scale(0.1, 0.1);
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
_assertPixel(offscreenCanvas, 20,20, 0,255,0,255, "20,20", "0,255,0,255");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,25 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:initial.reset.transform
|
||||
// Description:Resetting the canvas state resets the current transformation matrix
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Resetting the canvas state resets the current transformation matrix");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.scale(0.1, 0.1);
|
||||
offscreenCanvas.width = 100;
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
_assertPixel(offscreenCanvas, 20,20, 0,255,0,255, "20,20", "0,255,0,255");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#offscreencontext2d-commit">
|
||||
<script>
|
||||
|
||||
function verifyPlaceholder(placeholder, expectedR, expectedG, expectedB, expectedA, expectedClrStr)
|
||||
{
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = canvas.height = 10;
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(placeholder, 0, 0);
|
||||
_assertPixel(canvas, 5,5, expectedR, expectedG, expectedB, expectedA, "5,5", expectedClrStr);
|
||||
}
|
||||
|
||||
test(function() {
|
||||
var placeholder = document.createElement('canvas');
|
||||
placeholder.width = placeholder.height = 10;
|
||||
var offscreenCanvas = placeholder.transferControlToOffscreen();
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
ctx.fillStyle = "#0f0";
|
||||
ctx.fillRect(0, 0, 10, 10);
|
||||
ctx.commit();
|
||||
// commit() propagation is taken care of by an async task, which means the
|
||||
// place holder contents should still be transparent black at this moment.
|
||||
verifyPlaceholder(placeholder, 0,0,0,0, "0,0,0,0");
|
||||
// Set timeout acts as a sync barrier to allow commit to propagate
|
||||
setTimeout(function() {
|
||||
verifyPlaceholder(placeholder, 0,255,0,255, "0,255,0,255");
|
||||
}, 0);
|
||||
}, "Test that calling OffscreenCanvas's commit pushes its contents to its placeholder.");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
ctx.fillStyle = "#0f0";
|
||||
ctx.fillRect(0, 0, 10, 10);
|
||||
assert_throws("InvalidStateError", function() { ctx.commit(); });
|
||||
}, "Test that calling commit on an OffscreenCanvas that is not transferred from a HTMLCanvasElement throws an exception.");
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#offscreencontext2d-commit">
|
||||
|
||||
<script id="myWorker" type="text/worker">
|
||||
|
||||
function testCommitPushesContents(offscreenCanvas)
|
||||
{
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
ctx.fillStyle = "#0f0";
|
||||
ctx.fillRect(0, 0, 10, 10);
|
||||
ctx.commit();
|
||||
}
|
||||
|
||||
function isInvalidStateError(funcStr, ctx)
|
||||
{
|
||||
try {
|
||||
eval(funcStr);
|
||||
} catch (e) {
|
||||
if (e instanceof DOMException && e.name == "InvalidStateError")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function testCommitException()
|
||||
{
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
ctx.fillStyle = "#0f0";
|
||||
ctx.fillRect(0, 0, 10, 10);
|
||||
return isInvalidStateError("ctx.commit()", ctx);
|
||||
}
|
||||
|
||||
self.onmessage = function(e) {
|
||||
switch (e.data.msg) {
|
||||
case 'test1':
|
||||
testCommitPushesContents(e.data.data);
|
||||
self.postMessage('worker finished');
|
||||
break;
|
||||
case 'test2':
|
||||
self.postMessage(testCommitException());
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
function verifyPlaceholder(placeholder)
|
||||
{
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = canvas.height = 10;
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(placeholder, 0, 0);
|
||||
_assertPixel(canvas, 5,5, 0,255,0,255, "5,5", "0,255,0,255");
|
||||
}
|
||||
|
||||
function makeWorker(script)
|
||||
{
|
||||
var blob = new Blob([script]);
|
||||
return new Worker(URL.createObjectURL(blob));
|
||||
}
|
||||
|
||||
async_test(function(t) {
|
||||
var placeholder = document.createElement('canvas');
|
||||
placeholder.width = placeholder.height = 10;
|
||||
var offscreenCanvas = placeholder.transferControlToOffscreen();
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
verifyPlaceholder(placeholder);
|
||||
}));
|
||||
worker.postMessage({msg: 'test1', data: offscreenCanvas}, [offscreenCanvas]);
|
||||
}, "Test that calling OffscreenCanvas's commit pushes its contents to its placeholder.");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage({msg: 'test2'});
|
||||
}, "Test that calling commit on an OffscreenCanvas that is not transferred from a HTMLCanvasElement throws an exception in a worker.");
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#dom-offscreencanvas">
|
||||
<script>
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
assert_equals(offscreenCanvas.width, 100);
|
||||
assert_equals(offscreenCanvas.height, 50);
|
||||
|
||||
offscreenCanvas.width = 50;
|
||||
offscreenCanvas.height = 100;
|
||||
assert_equals(offscreenCanvas.width, 50);
|
||||
assert_equals(offscreenCanvas.height, 100);
|
||||
}, "Test that calling OffscreenCanvas's constructor generates correct width and height.");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas1 = new OffscreenCanvas(1, 1);
|
||||
|
||||
offscreenCanvas1.width = null;
|
||||
offscreenCanvas1.height = null;
|
||||
assert_equals(offscreenCanvas1.width, 0);
|
||||
assert_equals(offscreenCanvas1.height, 0);
|
||||
|
||||
assert_throws(new TypeError(), function() { new OffscreenCanvas(-1, -1); });
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(null, null);
|
||||
assert_equals(offscreenCanvas2.width, 0);
|
||||
assert_equals(offscreenCanvas2.height, 0);
|
||||
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.width = -1; });
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.height = -1; });
|
||||
|
||||
var obj = {Name: "John Doe", Age: 30};
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.width = obj; });
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.height = obj; });
|
||||
assert_throws(new TypeError(), function() { new OffscreenCanvas(obj, obj); });
|
||||
}, "Test that OffscreenCanvas constructor handles invalid arguments correctly");
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
// spec link: https://html.spec.whatwg.org/#dom-offscreencanvas
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t1 = async_test("Test that calling OffscreenCanvas's constructor generates correct width and height.");
|
||||
t1.step(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
assert_equals(offscreenCanvas.width, 100);
|
||||
assert_equals(offscreenCanvas.height, 50);
|
||||
|
||||
offscreenCanvas.width = 50;
|
||||
offscreenCanvas.height = 100;
|
||||
assert_equals(offscreenCanvas.width, 50);
|
||||
assert_equals(offscreenCanvas.height, 100);
|
||||
t1.done();
|
||||
});
|
||||
|
||||
var t2 = async_test("Test that OffscreenCanvas constructor handles invalid arguments correctly in a worker");
|
||||
t2.step(function() {
|
||||
var offscreenCanvas1 = new OffscreenCanvas(1, 1);
|
||||
|
||||
offscreenCanvas1.width = null;
|
||||
offscreenCanvas1.height = null;
|
||||
assert_equals(offscreenCanvas1.width, 0);
|
||||
assert_equals(offscreenCanvas1.height, 0);
|
||||
|
||||
assert_throws(new TypeError(), function() { new OffscreenCanvas(-1, -1); });
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(null, null);
|
||||
assert_equals(offscreenCanvas2.width, 0);
|
||||
assert_equals(offscreenCanvas2.height, 0);
|
||||
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.width = -1; });
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.height = -1; });
|
||||
|
||||
var obj = {Name: "John Doe", Age: 30};
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.width = obj; });
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas2.height = obj; });
|
||||
assert_throws(new TypeError(), function() { new OffscreenCanvas(obj, obj); });
|
||||
t2.done();
|
||||
});
|
||||
|
||||
done();
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#dom-offscreencanvas-converttoblob">
|
||||
<script id="myWorker" type="text/worker">
|
||||
self.onmessage = function(e) {
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
function makeWorker(script)
|
||||
{
|
||||
var blob = new Blob([script]);
|
||||
return new Worker(URL.createObjectURL(blob));
|
||||
}
|
||||
|
||||
function drawCanvas(ctx)
|
||||
{
|
||||
ctx.fillStyle = "red";
|
||||
ctx.fillRect(0, 0, 5, 5);
|
||||
ctx.fillStyle = "green";
|
||||
ctx.fillRect(5, 0, 5, 5);
|
||||
ctx.fillStyle = "blue";
|
||||
ctx.fillRect(0, 5, 5, 5);
|
||||
ctx.fillStyle = "black";
|
||||
ctx.fillRect(5, 5, 5, 5);
|
||||
}
|
||||
|
||||
function compareImages(image1, image2)
|
||||
{
|
||||
var canvas1 = document.createElement('canvas');
|
||||
var canvas2 = document.createElement('canvas');
|
||||
canvas1.width = canvas1.height = 10;
|
||||
canvas2.width = canvas2.height = 10;
|
||||
var ctx1 = canvas1.getContext('2d');
|
||||
var ctx2 = canvas1.getContext('2d');
|
||||
ctx1.drawImage(image1, 0, 0);
|
||||
ctx2.drawImage(image2, 0, 0);
|
||||
var data1 = ctx1.getImageData(0, 0, 10, 10).data;
|
||||
var data2 = ctx2.getImageData(0, 0, 10, 10).data;
|
||||
assert_equals(data1.length, data2.length);
|
||||
var imageMatched = true;
|
||||
for (var i = 0; i < data1.length; i++) {
|
||||
if (data1[i] != data2[i]) {
|
||||
imageMatched = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert_true(imageMatched);
|
||||
}
|
||||
|
||||
function testConvertToBlob(t, typeVal, qualityVal) {
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var oCtx = offscreenCanvas.getContext('2d');
|
||||
drawCanvas(oCtx);
|
||||
var canvas = document.createElement('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
drawCanvas(ctx);
|
||||
var imageLoadedCounter = 0;
|
||||
|
||||
var image1 = new Image();
|
||||
var image2 = new Image();
|
||||
var promise;
|
||||
if (typeVal == "empty" && qualityVal == "empty")
|
||||
promise = offscreenCanvas.convertToBlob();
|
||||
else if (typeVal == "empty" && qualityVal != "empty")
|
||||
promise = offscreenCanvas.convertToBlob({quality: qualityVal});
|
||||
else if (typeVal != "empty" && qualityVal == "empty")
|
||||
promise = offscreenCanvas.convertToBlob({type: typeVal});
|
||||
else
|
||||
promise = offscreenCanvas.convertToBlob({type: typeVal, quality: qualityVal});
|
||||
promise.then(function(blob2) {
|
||||
image2.src = URL.createObjectURL(blob2);
|
||||
if (typeVal == "empty" && qualityVal == "empty") {
|
||||
canvas.toBlob(function(blob1) {
|
||||
image1.src = URL.createObjectURL(blob1);
|
||||
});
|
||||
} else if (typeVal == "empty" && qualityVal != "empty") {
|
||||
canvas.toBlob(function(blob1) {
|
||||
image1.src = URL.createObjectURL(blob1);
|
||||
}, "image/png", qualityVal);
|
||||
} else if (typeVal != "empty" && qualityVal == "empty") {
|
||||
canvas.toBlob(function(blob1) {
|
||||
image1.src = URL.createObjectURL(blob1);
|
||||
}, typeVal, 1.0);
|
||||
} else {
|
||||
canvas.toBlob(function(blob1) {
|
||||
image1.src = URL.createObjectURL(blob1);
|
||||
}, typeVal, qualityVal);
|
||||
}
|
||||
image1.onload = image2.onload = t.step_func(function() {
|
||||
imageLoadedCounter++;
|
||||
if (imageLoadedCounter == 2) {
|
||||
compareImages(image1, image2);
|
||||
t.done();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async_test(function(t) {
|
||||
testConvertToBlob(t, "empty", "empty");
|
||||
testConvertToBlob(t, "empty", 1.0);
|
||||
testConvertToBlob(t, "empty", 0.2);
|
||||
}, "Test that convertToBlob with default type produces correct result");
|
||||
|
||||
async_test(function(t) {
|
||||
testConvertToBlob(t, "image/png", "empty");
|
||||
testConvertToBlob(t, "image/png", 1.0);
|
||||
testConvertToBlob(t, "image/png", 0.2);
|
||||
}, "Test that convertToBlob with png produces correct result");
|
||||
|
||||
async_test(function(t) {
|
||||
testConvertToBlob(t, "image/jpeg", "empty");
|
||||
testConvertToBlob(t, "image/jpeg", 1.0);
|
||||
testConvertToBlob(t, "image/jpeg", 0.2);
|
||||
}, "Test that convertToBlob with jpge produces correct result");
|
||||
|
||||
async_test(function(t) {
|
||||
testConvertToBlob(t, "image/webp", "empty");
|
||||
testConvertToBlob(t, "image/webp", 1.0);
|
||||
testConvertToBlob(t, "image/webp", 0.2);
|
||||
}, "Test that convertToBlob with webp produces correct result");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
worker.postMessage({offscreenCanvas}, [offscreenCanvas]);
|
||||
offscreenCanvas.convertToBlob().then(t.step_func_done(function() {
|
||||
assert_false("convertToBlob didn't throw, but should be");
|
||||
}), t.step_func_done(function(e) {
|
||||
assert_true(e instanceof DOMException);
|
||||
assert_equals(e.name, "InvalidStateError");
|
||||
}));
|
||||
}, "Test that call convertToBlob on a detached OffscreenCanvas throws exception");
|
||||
|
||||
async_test(function(t) {
|
||||
var offscreenCanvas = new OffscreenCanvas(0, 0);
|
||||
offscreenCanvas.convertToBlob().then(t.step_func_done(function() {
|
||||
assert_false("convertToBlob didn't throw, but should be");
|
||||
}), t.step_func_done(function(e) {
|
||||
assert_true(e instanceof DOMException);
|
||||
assert_equals(e.name, "IndexSizeError");
|
||||
}));
|
||||
}, "Test that call convertToBlob on a OffscreenCanvas with size 0 throws exception");
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,307 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#dom-offscreencanvas-converttoblob">
|
||||
<script id="myWorker" type="text/worker">
|
||||
function drawCanvas(ctx)
|
||||
{
|
||||
ctx.fillStyle = "red";
|
||||
ctx.fillRect(0, 0, 5, 5);
|
||||
ctx.fillStyle = "green";
|
||||
ctx.fillRect(5, 0, 5, 5);
|
||||
ctx.fillStyle = "blue";
|
||||
ctx.fillRect(0, 5, 5, 5);
|
||||
ctx.fillStyle = "black";
|
||||
ctx.fillRect(5, 5, 5, 5);
|
||||
}
|
||||
|
||||
function testConvertToBlob(typeVal, qualityVal) {
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var oCtx = offscreenCanvas.getContext('2d');
|
||||
drawCanvas(oCtx);
|
||||
|
||||
var promise;
|
||||
if (typeVal == "empty" && qualityVal == "empty")
|
||||
promise = offscreenCanvas.convertToBlob();
|
||||
else if (typeVal == "empty" && qualityVal != "empty")
|
||||
promise = offscreenCanvas.convertToBlob({quality: qualityVal});
|
||||
else if (typeVal != "empty" && qualityVal == "empty")
|
||||
promise = offscreenCanvas.convertToBlob({type: typeVal});
|
||||
else
|
||||
promise = offscreenCanvas.convertToBlob({type: typeVal, quality: qualityVal});
|
||||
promise.then(function(blob) {
|
||||
self.postMessage(blob);
|
||||
});
|
||||
}
|
||||
|
||||
function testConvertToBlobException1()
|
||||
{
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
self.postMessage({offscreenCanvas}, [offscreenCanvas]);
|
||||
offscreenCanvas.convertToBlob().then(function() {
|
||||
return false;
|
||||
}, function(e) {
|
||||
if (e instanceof DOMException && e.name == "InvalidStateError")
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function testConvertToBlobException2()
|
||||
{
|
||||
var offscreenCanvas = new OffscreenCanvas(0, 0);
|
||||
offscreenCanvas.convertToBlob().then(function() {
|
||||
return false;
|
||||
}, function(e) {
|
||||
if (e instanceof DOMException && e.name == "IndexSizeError")
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
self.onmessage = function(e) {
|
||||
switch(e.data) {
|
||||
case 'test1':
|
||||
testConvertToBlob("empty", "empty");
|
||||
break;
|
||||
case 'test2':
|
||||
testConvertToBlob("empty", 1.0);
|
||||
break;
|
||||
case 'test3':
|
||||
testConvertToBlob("empty", 0.2);
|
||||
break;
|
||||
case 'test4':
|
||||
testConvertToBlob("image/png", "empty");
|
||||
break;
|
||||
case 'test5':
|
||||
testConvertToBlob("image/png", 1.0);
|
||||
break;
|
||||
case 'test6':
|
||||
testConvertToBlob("image/png", 0.2);
|
||||
break;
|
||||
case 'test7':
|
||||
testConvertToBlob("image/jpeg", "empty");
|
||||
break;
|
||||
case 'test8':
|
||||
testConvertToBlob("image/jpeg", 1.0);
|
||||
break;
|
||||
case 'test9':
|
||||
testConvertToBlob("image/jpeg", 0.2);
|
||||
break;
|
||||
case 'test10':
|
||||
testConvertToBlob("image/webp", "empty");
|
||||
break;
|
||||
case 'test11':
|
||||
testConvertToBlob("image/webp", 1.0);
|
||||
break;
|
||||
case 'test12':
|
||||
testConvertToBlob("image/webp", 0.2);
|
||||
break;
|
||||
case 'test13':
|
||||
self.postMessage(testConvertToBlobException1());
|
||||
break;
|
||||
case 'test14':
|
||||
self.postMessage(testConvertToBlobException2());
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function makeWorker(script)
|
||||
{
|
||||
var blob = new Blob([script]);
|
||||
return new Worker(URL.createObjectURL(blob));
|
||||
}
|
||||
|
||||
function drawCanvas(ctx)
|
||||
{
|
||||
ctx.fillStyle = "red";
|
||||
ctx.fillRect(0, 0, 5, 5);
|
||||
ctx.fillStyle = "green";
|
||||
ctx.fillRect(5, 0, 5, 5);
|
||||
ctx.fillStyle = "blue";
|
||||
ctx.fillRect(0, 5, 5, 5);
|
||||
ctx.fillStyle = "black";
|
||||
ctx.fillRect(5, 5, 5, 5);
|
||||
}
|
||||
|
||||
function compareImages(image1, image2)
|
||||
{
|
||||
var canvas1 = document.createElement('canvas');
|
||||
var canvas2 = document.createElement('canvas');
|
||||
canvas1.width = canvas1.height = 10;
|
||||
canvas2.width = canvas2.height = 10;
|
||||
var ctx1 = canvas1.getContext('2d');
|
||||
var ctx2 = canvas1.getContext('2d');
|
||||
ctx1.drawImage(image1, 0, 0);
|
||||
ctx2.drawImage(image2, 0, 0);
|
||||
var data1 = ctx1.getImageData(0, 0, 10, 10).data;
|
||||
var data2 = ctx2.getImageData(0, 0, 10, 10).data;
|
||||
assert_equals(data1.length, data2.length);
|
||||
var imageMatched = true;
|
||||
for (var i = 0; i < data1.length; i++) {
|
||||
if (data1[i] != data2[i]) {
|
||||
imageMatched = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert_true(imageMatched);
|
||||
}
|
||||
|
||||
function compareWithToBlob(t, typeVal, qualityVal, blob2)
|
||||
{
|
||||
var image1 = new Image();
|
||||
var image2 = new Image();
|
||||
var canvas = document.createElement('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
drawCanvas(ctx);
|
||||
var imageLoadedCounter = 0;
|
||||
|
||||
if (typeVal == "empty" && qualityVal == "empty") {
|
||||
canvas.toBlob(function(blob1) {
|
||||
image1.src = URL.createObjectURL(blob1);
|
||||
});
|
||||
} else if (typeVal == "empty" && qualityVal != "empty") {
|
||||
canvas.toBlob(function(blob1) {
|
||||
image1.src = URL.createObjectURL(blob1);
|
||||
}, "image/png", qualityVal);
|
||||
} else if (typeVal != "empty" && qualityVal == "empty") {
|
||||
canvas.toBlob(function(blob1) {
|
||||
image1.src = URL.createObjectURL(blob1);
|
||||
}, typeVal, 1.0);
|
||||
} else {
|
||||
canvas.toBlob(function(blob1) {
|
||||
image1.src = URL.createObjectURL(blob1);
|
||||
}, typeVal, qualityVal);
|
||||
}
|
||||
image2.src = URL.createObjectURL(blob2);
|
||||
image1.onload = image2.onload = t.step_func(function() {
|
||||
imageLoadedCounter++;
|
||||
if (imageLoadedCounter == 2) {
|
||||
compareImages(image1, image2);
|
||||
t.done();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func(function(msg) {
|
||||
compareWithToBlob(t, "empty", "empty", msg.data);
|
||||
}));
|
||||
worker.postMessage('test1');
|
||||
}, "Test that convertToBlob with default arguments produces correct result in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func(function(msg) {
|
||||
compareWithToBlob(t, "empty", 1.0, msg.data);
|
||||
}));
|
||||
worker.postMessage('test2');
|
||||
}, "Test that convertToBlob with default type/1.0 quality produces correct result in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func(function(msg) {
|
||||
compareWithToBlob(t, "empty", 0.2, msg.data);
|
||||
}));
|
||||
worker.postMessage('test3');
|
||||
}, "Test that convertToBlob with default type/0.2 quality produces correct result in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func(function(msg) {
|
||||
compareWithToBlob(t, "image/png", "empty", msg.data);
|
||||
}));
|
||||
worker.postMessage('test4');
|
||||
}, "Test that convertToBlob with png/default quality produces correct result in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func(function(msg) {
|
||||
compareWithToBlob(t, "image/png", 1.0, msg.data);
|
||||
}));
|
||||
worker.postMessage('test5');
|
||||
}, "Test that convertToBlob with png/1.0 quality produces correct result in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func(function(msg) {
|
||||
compareWithToBlob(t, "image/png", 0.2, msg.data);
|
||||
}));
|
||||
worker.postMessage('test6');
|
||||
}, "Test that convertToBlob with png/0.2 quality produces correct result in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func(function(msg) {
|
||||
compareWithToBlob(t, "image/jpeg", "empty", msg.data);
|
||||
}));
|
||||
worker.postMessage('test7');
|
||||
}, "Test that convertToBlob with jpeg/default quality produces correct result in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func(function(msg) {
|
||||
compareWithToBlob(t, "image/jpeg", 1.0, msg.data);
|
||||
}));
|
||||
worker.postMessage('test8');
|
||||
}, "Test that convertToBlob with jpeg/1.0 quality produces correct result in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func(function(msg) {
|
||||
compareWithToBlob(t, "image/jpeg", 0.2, msg.data);
|
||||
}));
|
||||
worker.postMessage('test9');
|
||||
}, "Test that convertToBlob with jpeg/0.2 quality produces correct result in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func(function(msg) {
|
||||
compareWithToBlob(t, "image/webp", "empty", msg.data);
|
||||
}));
|
||||
worker.postMessage('test10');
|
||||
}, "Test that convertToBlob with webp/default quality produces correct result in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func(function(msg) {
|
||||
compareWithToBlob(t, "image/webp", 1.0, msg.data);
|
||||
}));
|
||||
worker.postMessage('test11');
|
||||
}, "Test that convertToBlob with webp/1.0 quality produces correct result in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func(function(msg) {
|
||||
compareWithToBlob(t, "image/webp", 0.2, msg.data);
|
||||
}));
|
||||
worker.postMessage('test12');
|
||||
}, "Test that convertToBlob with webp/0.2 quality produces correct result in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
if (msg.data == true || msg.data == false)
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage('test13');
|
||||
}, "Test that call convertToBlob on a detached OffscreenCanvas throws exception in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
if (msg.data == true || msg.data == false)
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage('test14');
|
||||
}, "Test that call convertToBlob on a OffscreenCanvas with size 0 throws exception in a worker");
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#dom-offscreencanvas-getcontext">
|
||||
<script>
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(1, 1);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas.getContext('3d'); });
|
||||
}, "Test that getContext with un-supported string throws a TypeError.");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas1 = new OffscreenCanvas(1, 1);
|
||||
var ctx1 = offscreenCanvas1.getContext('2d');
|
||||
assert_true(ctx1 instanceof OffscreenCanvasRenderingContext2D);
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(1, 1);
|
||||
var ctx2 = offscreenCanvas2.getContext('webgl');
|
||||
assert_true(ctx2 instanceof WebGLRenderingContext);
|
||||
|
||||
var offscreenCanvas3 = new OffscreenCanvas(1, 1);
|
||||
var ctx3 = offscreenCanvas3.getContext('webgl2');
|
||||
assert_true(ctx3 instanceof WebGL2RenderingContext);
|
||||
}, "Test that getContext with supported string returns correct results");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas1 = new OffscreenCanvas(1, 1);
|
||||
var ctx1 = offscreenCanvas1.getContext('2d');
|
||||
var ctx2 = offscreenCanvas1.getContext('webgl');
|
||||
assert_equals(ctx2, null);
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(1, 1);
|
||||
var ctx3 = offscreenCanvas2.getContext('webgl');
|
||||
var ctx4 = offscreenCanvas2.getContext('2d');
|
||||
assert_equals(ctx4, null);
|
||||
}, "Test that getContext twice with different context type returns null the second time");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(1, 2);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
var dstCanvas = ctx.canvas;
|
||||
assert_equals(dstCanvas.width, 1);
|
||||
assert_equals(dstCanvas.height, 2);
|
||||
}, "Test that 2dcontext.canvas should return the original OffscreenCanvas");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(1, 2);
|
||||
var ctx = offscreenCanvas.getContext('webgl');
|
||||
var dstCanvas = ctx.canvas;
|
||||
assert_equals(dstCanvas.width, 1);
|
||||
assert_equals(dstCanvas.height, 2);
|
||||
}, "Test that webglcontext.canvas should return the original OffscreenCanvas");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var ctx = offscreenCanvas.getContext('2d', {alpha: false});
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
|
||||
ctx.fillRect(0, 0, 10, 10);
|
||||
_assertPixelApprox(offscreenCanvas, 5,5, 0,127,0,255, "5,5", "0,127,0,255", 2);
|
||||
}, "Test that OffscreenCanvasRenderingContext2D with alpha disabled makes the OffscreenCanvas opaque");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var ctx = offscreenCanvas.getContext('2d', {alpha: true});
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
|
||||
ctx.fillRect(0, 0, 10, 10);
|
||||
_assertPixelApprox(offscreenCanvas, 5,5, 0,255,0,127, "5,5", "0,255,0,127", 2);
|
||||
}, "Test that OffscreenCanvasRenderingContext2D with alpha enabled preserves the alpha");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
|
||||
ctx.fillRect(0, 0, 10, 10);
|
||||
_assertPixelApprox(offscreenCanvas, 5,5, 0,255,0,127, "5,5", "0,255,0,127", 2);
|
||||
}, "Test that 'alpha' context creation attribute is true by default");
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
// spec link: https://html.spec.whatwg.org/#dom-offscreencanvas-getcontext
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(1, 1);
|
||||
assert_throws(new TypeError(), function() { offscreenCanvas.getContext('3d'); });
|
||||
}, "Test that getContext with un-supported string throws a TypeError.");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas1 = new OffscreenCanvas(1, 1);
|
||||
var ctx1 = offscreenCanvas1.getContext('2d');
|
||||
assert_true(ctx1 instanceof OffscreenCanvasRenderingContext2D);
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(1, 1);
|
||||
var ctx2 = offscreenCanvas2.getContext('webgl');
|
||||
assert_true(ctx2 instanceof WebGLRenderingContext);
|
||||
|
||||
var offscreenCanvas3 = new OffscreenCanvas(1, 1);
|
||||
var ctx3 = offscreenCanvas3.getContext('webgl2');
|
||||
assert_true(ctx3 instanceof WebGL2RenderingContext);
|
||||
}, "Test that getContext with supported string returns correct results");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas1 = new OffscreenCanvas(1, 1);
|
||||
var ctx1 = offscreenCanvas1.getContext('2d');
|
||||
var ctx2 = offscreenCanvas1.getContext('webgl');
|
||||
assert_equals(ctx2, null);
|
||||
|
||||
var offscreenCanvas2 = new OffscreenCanvas(1, 1);
|
||||
var ctx3 = offscreenCanvas2.getContext('webgl');
|
||||
var ctx4 = offscreenCanvas2.getContext('2d');
|
||||
assert_equals(ctx4, null);
|
||||
}, "Test that getContext twice with different context type returns null the second time");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(1, 2);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
var dstCanvas = ctx.canvas;
|
||||
assert_equals(dstCanvas.width, 1);
|
||||
assert_equals(dstCanvas.height, 2);
|
||||
}, "Test that 2dcontext.canvas should return the original OffscreenCanvas");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(1, 2);
|
||||
var ctx = offscreenCanvas.getContext('webgl');
|
||||
var dstCanvas = ctx.canvas;
|
||||
assert_equals(dstCanvas.width, 1);
|
||||
assert_equals(dstCanvas.height, 2);
|
||||
}, "Test that webglcontext.canvas should return the original OffscreenCanvas");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var ctx = offscreenCanvas.getContext('2d', {alpha: false});
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
|
||||
ctx.fillRect(0, 0, 10, 10);
|
||||
_assertPixelApprox(offscreenCanvas, 5,5, 0,127,0,255, "5,5", "0,127,0,255", 2);
|
||||
}, "Test that OffscreenCanvasRenderingContext2D with alpha disabled makes the OffscreenCanvas opaque");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var ctx = offscreenCanvas.getContext('2d', {alpha: true});
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
|
||||
ctx.fillRect(0, 0, 10, 10);
|
||||
_assertPixelApprox(offscreenCanvas, 5,5, 0,255,0,127, "5,5", "0,255,0,127", 2);
|
||||
}, "Test that OffscreenCanvasRenderingContext2D with alpha enabled preserves the alpha");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
|
||||
ctx.fillRect(0, 0, 10, 10);
|
||||
_assertPixelApprox(offscreenCanvas, 5,5, 0,255,0,127, "5,5", "0,255,0,127", 2);
|
||||
}, "Test that 'alpha' context creation attribute is true by default");
|
||||
|
||||
done();
|
|
@ -0,0 +1,112 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#dom-offscreencanvas-transfertoimagebitmap">
|
||||
|
||||
<script id="myWorker" type="text/worker">
|
||||
|
||||
self.onmessage = function(e) {
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function makeWorker(script)
|
||||
{
|
||||
var blob = new Blob([script]);
|
||||
return new Worker(URL.createObjectURL(blob));
|
||||
}
|
||||
|
||||
test(function() {
|
||||
function testSize(contextType) {
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext(contextType);
|
||||
var image = offscreenCanvas.transferToImageBitmap();
|
||||
assert_equals(image.width, 100);
|
||||
assert_equals(image.height, 50);
|
||||
}
|
||||
|
||||
testSize('2d');
|
||||
testSize('webgl');
|
||||
}, "Test that transferToImageBitmap returns an ImageBitmap with correct width and height");
|
||||
|
||||
test(function() {
|
||||
function testImageBitmapClr(shouldCallTwice, alphaVal) {
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d', {alpha: alphaVal});
|
||||
ctx.fillStyle = "#0f0";
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
var image = offscreenCanvas.transferToImageBitmap();
|
||||
|
||||
if (shouldCallTwice)
|
||||
image = offscreenCanvas.transferToImageBitmap();
|
||||
|
||||
var drawCanvas = document.createElement('canvas');
|
||||
drawCanvas.width = 100;
|
||||
drawCanvas.height = 50;
|
||||
var dCtx = drawCanvas.getContext('2d');
|
||||
dCtx.drawImage(image, 0, 0);
|
||||
|
||||
if (shouldCallTwice) {
|
||||
if (alphaVal)
|
||||
_assertPixel(drawCanvas, 50,25, 0,0,0,0, "50,25", "0,0,0,0");
|
||||
else
|
||||
_assertPixel(drawCanvas, 50,25, 0,0,0,255, "50,25", "0,0,0,255");
|
||||
} else {
|
||||
_assertPixel(drawCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
|
||||
}
|
||||
}
|
||||
|
||||
testImageBitmapClr(false, true);
|
||||
testImageBitmapClr(true, true);
|
||||
testImageBitmapClr(true, false);
|
||||
}, "Test that transferToImageBitmap returns an ImageBitmap with correct color");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
ctx.lineWidth = 10;
|
||||
var image = offscreenCanvas.transferToImageBitmap();
|
||||
assert_equals(ctx.lineWidth, 10);
|
||||
}, "Test that transferToImageBitmap won't change context's property");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
ctx.rect(0, 0, 25, 50);
|
||||
ctx.clip();
|
||||
ctx.translate(20, 20);
|
||||
|
||||
ctx.fillStyle = '#0f0';
|
||||
var image1 = offscreenCanvas.transferToImageBitmap();
|
||||
// trasnform should be preserved
|
||||
ctx.fillRect(0, 0, 10, 10);
|
||||
var image2 = offscreenCanvas.transferToImageBitmap();
|
||||
|
||||
var drawCanvas = document.createElement('canvas');
|
||||
drawCanvas.width = 100;
|
||||
drawCanvas.height = 50;
|
||||
var dCtx = drawCanvas.getContext('2d');
|
||||
dCtx.drawImage(image2, 0, 0);
|
||||
// Verify that transform was carried over.
|
||||
_assertPixel(drawCanvas, 23,25, 0,255,0,255, "23,25", "0,255,0,255");
|
||||
// Verify that clip was carried over.
|
||||
_assertPixel(drawCanvas, 27,25, 0,0,0,0, "27,25", "0,0,0,0");
|
||||
}, "Test that transferToImageBitmap preserves transform");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
worker.postMessage(offscreenCanvas, [offscreenCanvas]);
|
||||
assert_throws("InvalidStateError", function() { offscreenCanvas.transferToImageBitmap(); });
|
||||
t.done();
|
||||
}, "Test that call transferToImageBitmap on a detached OffscreenCanvas throws an exception");
|
||||
|
||||
test(function() {
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
assert_throws("InvalidStateError", function() { offscreenCanvas.transferToImageBitmap(); });
|
||||
}, "Test that transferToImageBitmap without a context throws an exception");
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#dom-offscreencanvas-transfertoimagebitmap">
|
||||
|
||||
<script id="myWorker" type="text/worker">
|
||||
|
||||
function testSize(contextType)
|
||||
{
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext(contextType);
|
||||
var image = offscreenCanvas.transferToImageBitmap();
|
||||
if (image.width == 100 && image.height == 50)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function testImageBitmapClr(shouldCallTwice, alphaVal) {
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d', {alpha: alphaVal});
|
||||
ctx.fillStyle = "#0f0";
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
var image = offscreenCanvas.transferToImageBitmap();
|
||||
|
||||
if (shouldCallTwice)
|
||||
image = offscreenCanvas.transferToImageBitmap();
|
||||
return image;
|
||||
}
|
||||
|
||||
function isInvalidStateError(funcStr, offscreenCanvas)
|
||||
{
|
||||
try {
|
||||
eval(funcStr);
|
||||
} catch (e) {
|
||||
if (e instanceof DOMException && e.name == "InvalidStateError")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function testImageBitmapSize()
|
||||
{
|
||||
return testSize('2d') && testSize('webgl');
|
||||
}
|
||||
|
||||
function testLineWidthNotAltered()
|
||||
{
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
ctx.lineWidth = 10;
|
||||
var image = offscreenCanvas.transferToImageBitmap();
|
||||
return ctx.lineWidth == 10;
|
||||
}
|
||||
|
||||
function testTransformPreserved()
|
||||
{
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
ctx.rect(0, 0, 25, 50);
|
||||
ctx.clip();
|
||||
ctx.translate(20, 20);
|
||||
|
||||
ctx.fillStyle = '#0f0';
|
||||
var image1 = offscreenCanvas.transferToImageBitmap();
|
||||
// trasnform should be preserved
|
||||
ctx.fillRect(0, 0, 10, 10);
|
||||
var image2 = offscreenCanvas.transferToImageBitmap();
|
||||
return image2;
|
||||
}
|
||||
|
||||
function testException()
|
||||
{
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
return isInvalidStateError("offscreenCanvas.transferToImageBitmap()", offscreenCanvas);
|
||||
}
|
||||
|
||||
self.onmessage = function(e) {
|
||||
switch (e.data) {
|
||||
case 'test1':
|
||||
self.postMessage(testImageBitmapSize());
|
||||
break;
|
||||
case 'test2':
|
||||
self.postMessage(testImageBitmapClr(false, true));
|
||||
break;
|
||||
case 'test3':
|
||||
self.postMessage(testImageBitmapClr(true, true));
|
||||
break;
|
||||
case 'test4':
|
||||
self.postMessage(testImageBitmapClr(true, false));
|
||||
break;
|
||||
case 'test5':
|
||||
self.postMessage(testLineWidthNotAltered());
|
||||
break;
|
||||
case 'test6':
|
||||
self.postMessage(testTransformPreserved());
|
||||
break;
|
||||
case 'test7':
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
self.postMessage({offscreenCanvas: offscreenCanvas}, [offscreenCanvas]);
|
||||
self.postMessage(isInvalidStateError("offscreenCanvas.transferToImageBitmap()", offscreenCanvas));
|
||||
break;
|
||||
case 'test8':
|
||||
self.postMessage(testException());
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function makeWorker(script)
|
||||
{
|
||||
var blob = new Blob([script]);
|
||||
return new Worker(URL.createObjectURL(blob));
|
||||
}
|
||||
|
||||
function drawImageBitmap(image, x, y)
|
||||
{
|
||||
var drawCanvas = document.createElement('canvas');
|
||||
drawCanvas.width = 100;
|
||||
drawCanvas.height = 50;
|
||||
var dCtx = drawCanvas.getContext('2d');
|
||||
dCtx.drawImage(image, 0, 0);
|
||||
return dCtx.getImageData(x, y, 1, 1).data;
|
||||
}
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage('test1');
|
||||
}, "Test that transferToImageBitmap returns an ImageBitmap with correct width and height in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
var clr = drawImageBitmap(msg.data, 50, 25);
|
||||
assert_array_equals(clr, [0, 255, 0, 255]);
|
||||
}));
|
||||
worker.postMessage('test2');
|
||||
}, "Test that transferToImageBitmap returns an ImageBitmap with correct color in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
var clr = drawImageBitmap(msg.data, 50, 25);
|
||||
assert_array_equals(clr, [0, 0, 0, 0]);
|
||||
}));
|
||||
worker.postMessage('test3');
|
||||
}, "Test that call transferToImageBitmap twice returns an ImageBitmap with correct color in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
var clr = drawImageBitmap(msg.data, 50, 25);
|
||||
assert_array_equals(clr, [0, 0, 0, 255]);
|
||||
}));
|
||||
worker.postMessage('test4');
|
||||
}, "Test that call transferToImageBitmap twice on a alpha-disabled context returns an ImageBitmap with correct color in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage('test5');
|
||||
}, "Test that transferToImageBitmap won't change context's property in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
var clr1 = drawImageBitmap(msg.data, 23, 25);
|
||||
assert_array_equals(clr1, [0, 255, 0, 255]);
|
||||
var clr2 = drawImageBitmap(msg.data, 27, 25);
|
||||
assert_array_equals(clr2, [0, 0, 0, 0]);
|
||||
}));
|
||||
worker.postMessage('test6');
|
||||
}, "Test that call transferToImageBitmap preserves transform in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
if (msg.data == true || msg.data == false)
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage('test7');
|
||||
}, "Test that call transferToImageBitmap on a detached OffscreenCanvas throws an exception in a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage('test8');
|
||||
}, "Test that call transferToImageBitmap without a context throws an exception in a worker");
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#dom-canvas-transfercontroltooffscreen">
|
||||
<script>
|
||||
|
||||
test(function() {
|
||||
var placeholder = document.createElement('canvas');
|
||||
placeholder.width = 100;
|
||||
placeholder.height = 50;
|
||||
var offscreenCanvas = placeholder.transferControlToOffscreen();
|
||||
assert_equals(offscreenCanvas.width, 100);
|
||||
assert_equals(offscreenCanvas.height, 50);
|
||||
}, "Test that an OffscreenCanvas generated by transferControlToOffscreen gets correct width and height");
|
||||
|
||||
test(function() {
|
||||
var placeholder = document.createElement('canvas');
|
||||
placeholder.width = 100;
|
||||
placeholder.height = 50;
|
||||
var offscreenCanvas = placeholder.transferControlToOffscreen();
|
||||
assert_throws("InvalidStateError", function() { placeholder.getContext('2d'); });
|
||||
}, "Test that calling getContext on a placeholder canvas that has already transferred its control throws an exception");
|
||||
|
||||
test(function() {
|
||||
var placeholder = document.createElement('canvas');
|
||||
placeholder.width = 100;
|
||||
placeholder.height = 50;
|
||||
var offscreenCanvas = placeholder.transferControlToOffscreen();
|
||||
assert_throws("InvalidStateError", function() { placeholder.transferControlToOffscreen(); });
|
||||
}, "Test that calling transferControlToOffscreen twice throws an exception");
|
||||
|
||||
async_test(function(t) {
|
||||
var placeholder = document.createElement('canvas');
|
||||
placeholder.width = 10;
|
||||
placeholder.height = 20;
|
||||
var offscreenCanvas = placeholder.transferControlToOffscreen();
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
t.step(function() {
|
||||
offscreenCanvas.width = 30;
|
||||
offscreenCanvas.height = 40;
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 30, 40);
|
||||
assert_equals(offscreenCanvas.width, 30);
|
||||
assert_equals(offscreenCanvas.height, 40);
|
||||
var image = offscreenCanvas.transferToImageBitmap();
|
||||
assert_equals(image.width, 30);
|
||||
assert_equals(image.height, 40);
|
||||
});
|
||||
t.step(function() {
|
||||
// Setting the size of an OffscreenCanvas does not directly update the size of its placeholder canvas.
|
||||
assert_equals(placeholder.width, 10);
|
||||
assert_equals(placeholder.height, 20);
|
||||
});
|
||||
ctx.commit();
|
||||
t.step(function() {
|
||||
// commit() doesnt't synchronously update the size of its placeholder canvas
|
||||
assert_equals(placeholder.width, 10);
|
||||
assert_equals(placeholder.height, 20);
|
||||
});
|
||||
// Set timeout acts as a sync barrier to allow commit to propagate
|
||||
setTimeout(function() {
|
||||
t.step(function() {
|
||||
// commit() asynchronously updates the size of its placeholder canvas
|
||||
assert_equals(placeholder.width, 30);
|
||||
assert_equals(placeholder.height, 40);
|
||||
});
|
||||
createImageBitmap(placeholder).then(image => {
|
||||
t.step(function() {
|
||||
assert_equals(image.width, 30);
|
||||
assert_equals(image.height, 40);
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = canvas.height = 50;
|
||||
var context = canvas.getContext('2d');
|
||||
context.drawImage(image, 0, 0);
|
||||
_assertPixel(canvas, 15,20, 0,255,0,255, "15,20", "0,255,0,255");
|
||||
t.done();
|
||||
});
|
||||
});
|
||||
}, 0);
|
||||
}, "Verify that resizing an OffscreenCanvas with a 2d context propagates the new size to its placeholder canvas asynchronously, upon commit.");
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#dom-canvas-transfercontroltooffscreen">
|
||||
|
||||
<script id="myWorker" type="text/worker">
|
||||
|
||||
function testSize(offscreenCanvas)
|
||||
{
|
||||
if (offscreenCanvas.width == 100 && offscreenCanvas.height == 50)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
self.onmessage = function(e) {
|
||||
switch (e.data.msg) {
|
||||
case 'test1':
|
||||
self.postMessage(testSize(e.data.data));
|
||||
break;
|
||||
case 'test2':
|
||||
self.postMessage("");
|
||||
break;
|
||||
case 'test3':
|
||||
self.postMessage("");
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function makeWorker(script)
|
||||
{
|
||||
var blob = new Blob([script]);
|
||||
return new Worker(URL.createObjectURL(blob));
|
||||
}
|
||||
|
||||
async_test(function(t) {
|
||||
var placeholder = document.createElement('canvas');
|
||||
placeholder.width = 100;
|
||||
placeholder.height = 50;
|
||||
var offscreenCanvas = placeholder.transferControlToOffscreen();
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage({msg: 'test1', data: offscreenCanvas}, [offscreenCanvas]);
|
||||
}, "Test that an OffscreenCanvas generated by transferControlToOffscreen gets correct width and height when it is transferred to a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var placeholder = document.createElement('canvas');
|
||||
placeholder.width = 100;
|
||||
placeholder.height = 50;
|
||||
var offscreenCanvas = placeholder.transferControlToOffscreen();
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
assert_throws("InvalidStateError", function() { placeholder.getContext('2d'); });
|
||||
}));
|
||||
worker.postMessage({msg: 'test2', data: offscreenCanvas}, [offscreenCanvas]);
|
||||
}, "Test that calling getContext on a placeholder canvas that is transferred its control to an OffscreenCanvas throws an exception, when the OffscreenCanvas is transferred to a worker");
|
||||
|
||||
async_test(function(t) {
|
||||
var placeholder = document.createElement('canvas');
|
||||
placeholder.width = 100;
|
||||
placeholder.height = 50;
|
||||
var offscreenCanvas = placeholder.transferControlToOffscreen();
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
assert_throws("InvalidStateError", function() { placeholder.transferControlToOffscreen(); });
|
||||
}));
|
||||
worker.postMessage({msg: 'test3', data: offscreenCanvas}, [offscreenCanvas]);
|
||||
}, "Test that calling transferControlToOffscreen twice throws an exception, when its associated OffscreenCanvas is transferred to a worker");
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#offscreencanvas">
|
||||
|
||||
<script id="myWorker" type="text/worker">
|
||||
|
||||
function test1(offscreenCanvas)
|
||||
{
|
||||
return offscreenCanvas.width == 10 && offscreenCanvas.height == 10;
|
||||
}
|
||||
|
||||
self.onmessage = function(e) {
|
||||
switch(e.data.msg) {
|
||||
case 'test1':
|
||||
self.postMessage(test1(e.data.data));
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function makeWorker(script)
|
||||
{
|
||||
var blob = new Blob([script]);
|
||||
return new Worker(URL.createObjectURL(blob));
|
||||
}
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
worker.postMessage({msg: 'test1', data: offscreenCanvas}, [offscreenCanvas]);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
assert_equals(offscreenCanvas.width, 0);
|
||||
assert_equals(offscreenCanvas.height, 0);
|
||||
}, "Test that offscreenCanvas's size is correct after being transferred to a worker.");
|
||||
|
||||
test(function() {
|
||||
function testException(contextType) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var ctx = offscreenCanvas.getContext(contextType);
|
||||
assert_throws("InvalidStateError", function() {
|
||||
worker.postMessage({offscreenCanvas}, [offscreenCanvas]);
|
||||
});
|
||||
}
|
||||
testException('2d');
|
||||
testException('webgl');
|
||||
}, "Test that transfer an OffscreenCanvas that has a context throws exception.");
|
||||
|
||||
test(function() {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
worker.postMessage({offscreenCanvas}, [offscreenCanvas]);
|
||||
assert_throws("InvalidStateError", function() {
|
||||
worker.postMessage({offscreenCanvas}, [offscreenCanvas]);
|
||||
});
|
||||
}, "Test that transfer an OffscreenCanvas twice throws exception.");
|
||||
|
||||
test(function() {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
worker.postMessage({offscreenCanvas}, [offscreenCanvas]);
|
||||
assert_throws("InvalidStateError", function() {
|
||||
offscreenCanvas.getContext('2d');
|
||||
});
|
||||
}, "Test that calling getContext('2d') on a detached OffscreenCanvas throws exception.");
|
||||
|
||||
test(function() {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
worker.postMessage({offscreenCanvas}, [offscreenCanvas]);
|
||||
assert_throws("InvalidStateError", function() {
|
||||
offscreenCanvas.getContext('webgl');
|
||||
});
|
||||
}, "Test that calling getContext('webgl') on a detached OffscreenCanvas throws exception.");
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#offscreencanvas">
|
||||
|
||||
<script id="myWorker" type="text/worker">
|
||||
|
||||
function isInvalidStateError(funcStr, offscreenCanvas)
|
||||
{
|
||||
try {
|
||||
eval(funcStr);
|
||||
} catch (e) {
|
||||
if (e instanceof DOMException && e.name == "InvalidStateError")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function testExceptionWith2DContext()
|
||||
{
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
return isInvalidStateError("self.postMessage(offscreenCanvas, [offscreenCanvas])", offscreenCanvas);
|
||||
}
|
||||
|
||||
function testExceptionWithWebGLContext()
|
||||
{
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
var ctx = offscreenCanvas.getContext('webgl');
|
||||
return isInvalidStateError("self.postMessage(offscreenCanvas, [offscreenCanvas])", offscreenCanvas);
|
||||
}
|
||||
|
||||
function testExceptionWithDetachedOffscreenCanvas1()
|
||||
{
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
self.postMessage(offscreenCanvas, [offscreenCanvas]);
|
||||
return isInvalidStateError("self.postMessage(offscreenCanvas, [offscreenCanvas])", offscreenCanvas);
|
||||
}
|
||||
|
||||
function testExceptionWithDetachedOffscreenCanvas2()
|
||||
{
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
self.postMessage(offscreenCanvas, [offscreenCanvas]);
|
||||
return isInvalidStateError("offscreenCanvas.getContext('2d')", offscreenCanvas);
|
||||
}
|
||||
|
||||
function testExceptionWithDetachedOffscreenCanvas3()
|
||||
{
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
self.postMessage(offscreenCanvas, [offscreenCanvas]);
|
||||
return isInvalidStateError("offscreenCanvas.getContext('webgl')", offscreenCanvas);
|
||||
}
|
||||
|
||||
self.onmessage = function(e) {
|
||||
switch(e.data) {
|
||||
case 'test1':
|
||||
var offscreenCanvas = new OffscreenCanvas(10, 10);
|
||||
self.postMessage(offscreenCanvas, [offscreenCanvas]);
|
||||
break;
|
||||
case 'test2':
|
||||
self.postMessage(testExceptionWith2DContext());
|
||||
break;
|
||||
case 'test3':
|
||||
self.postMessage(testExceptionWithWebGLContext());
|
||||
break;
|
||||
case 'test4':
|
||||
self.postMessage(testExceptionWithDetachedOffscreenCanvas1());
|
||||
break;
|
||||
case 'test5':
|
||||
self.postMessage(testExceptionWithDetachedOffscreenCanvas2());
|
||||
break;
|
||||
case 'test6':
|
||||
self.postMessage(testExceptionWithDetachedOffscreenCanvas3());
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function makeWorker(script)
|
||||
{
|
||||
var blob = new Blob([script]);
|
||||
return new Worker(URL.createObjectURL(blob));
|
||||
}
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
assert_equals(msg.data.width, 10);
|
||||
assert_equals(msg.data.height, 10);
|
||||
}));
|
||||
worker.postMessage('test1');
|
||||
}, "Test that OffscreenCanvas's size is correct after being transferred from a worker.");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage('test2');
|
||||
}, "Test that transfer an OffscreenCanvas that has a 2d context throws exception in a worker.");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage('test3');
|
||||
}, "Test that transfer an OffscreenCanvas that has a webgl context throws exception in a worker.");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
if (msg.data == true || msg.data == false)
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage('test4');
|
||||
}, "Test that transfer an OffscreenCanvas twice throws exception in a worker.");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
if (msg.data == true || msg.data == false)
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage('test5');
|
||||
}, "Test that calling getContext('2d') on a detached OffscreenCanvas throws exception in a worker.");
|
||||
|
||||
async_test(function(t) {
|
||||
var worker = makeWorker(document.getElementById("myWorker").textContent);
|
||||
worker.addEventListener('message', t.step_func_done(function(msg) {
|
||||
if (msg.data == true || msg.data == false)
|
||||
assert_true(msg.data);
|
||||
}));
|
||||
worker.postMessage('test6');
|
||||
}, "Test that calling getContext('webgl') on a detached OffscreenCanvas throws exception in a worker.");
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.default</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.default</h1>
|
||||
<p class="desc">Default width/height when attributes are missing</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Default width/height when attributes are missing");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 50, "offscreenCanvas.height", "50");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.default
|
||||
// Description:Default width/height when attributes are missing
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Default width/height when attributes are missing");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 50, "offscreenCanvas.height", "50");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.idl</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.idl</h1>
|
||||
<p class="desc">Getting/setting width/height IDL attributes</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Getting/setting width/height IDL attributes");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = "100";
|
||||
offscreenCanvas.height = "100";
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
offscreenCanvas.width = "+1.5e2";
|
||||
offscreenCanvas.height = "0x96";
|
||||
_assertSame(offscreenCanvas.width, 150, "offscreenCanvas.width", "150");
|
||||
_assertSame(offscreenCanvas.height, 150, "offscreenCanvas.height", "150");
|
||||
offscreenCanvas.width = 301.999;
|
||||
offscreenCanvas.height = 301.001;
|
||||
_assertSame(offscreenCanvas.width, 301, "offscreenCanvas.width", "301");
|
||||
_assertSame(offscreenCanvas.height, 301, "offscreenCanvas.height", "301");
|
||||
offscreenCanvas.width = "400x";
|
||||
offscreenCanvas.height = "foo";
|
||||
_assertSame(offscreenCanvas.width, 0, "offscreenCanvas.width", "0");
|
||||
_assertSame(offscreenCanvas.height, 0, "offscreenCanvas.height", "0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.idl.set.zero</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.idl.set.zero</h1>
|
||||
<p class="desc">Setting width/height IDL attributes to 0</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Setting width/height IDL attributes to 0");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 0;
|
||||
offscreenCanvas.height = 0;
|
||||
_assertSame(offscreenCanvas.width, 0, "offscreenCanvas.width", "0");
|
||||
_assertSame(offscreenCanvas.height, 0, "offscreenCanvas.height", "0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.idl.set.zero
|
||||
// Description:Setting width/height IDL attributes to 0
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Setting width/height IDL attributes to 0");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 0;
|
||||
offscreenCanvas.height = 0;
|
||||
_assertSame(offscreenCanvas.width, 0, "offscreenCanvas.width", "0");
|
||||
_assertSame(offscreenCanvas.height, 0, "offscreenCanvas.height", "0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,35 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.idl
|
||||
// Description:Getting/setting width/height IDL attributes
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Getting/setting width/height IDL attributes");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = "100";
|
||||
offscreenCanvas.height = "100";
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
offscreenCanvas.width = "+1.5e2";
|
||||
offscreenCanvas.height = "0x96";
|
||||
_assertSame(offscreenCanvas.width, 150, "offscreenCanvas.width", "150");
|
||||
_assertSame(offscreenCanvas.height, 150, "offscreenCanvas.height", "150");
|
||||
offscreenCanvas.width = 301.999;
|
||||
offscreenCanvas.height = 301.001;
|
||||
_assertSame(offscreenCanvas.width, 301, "offscreenCanvas.width", "301");
|
||||
_assertSame(offscreenCanvas.height, 301, "offscreenCanvas.height", "301");
|
||||
offscreenCanvas.width = "400x";
|
||||
offscreenCanvas.height = "foo";
|
||||
_assertSame(offscreenCanvas.width, 0, "offscreenCanvas.width", "0");
|
||||
_assertSame(offscreenCanvas.height, 0, "offscreenCanvas.height", "0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.decimal</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.decimal</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '100.999';
|
||||
offscreenCanvas.height = '100.999';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.decimal
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '100.999';
|
||||
offscreenCanvas.height = '100.999';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.em</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.em</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '100em';
|
||||
offscreenCanvas.height = '100em';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.em
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '100em';
|
||||
offscreenCanvas.height = '100em';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.empty</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.empty</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '';
|
||||
offscreenCanvas.height = '';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 50, "offscreenCanvas.height", "50");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.empty
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '';
|
||||
offscreenCanvas.height = '';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 50, "offscreenCanvas.height", "50");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.exp</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.exp</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '100e1';
|
||||
offscreenCanvas.height = '100e1';
|
||||
_assertSame(offscreenCanvas.width, 1000.0, "offscreenCanvas.width", "1000.0");
|
||||
_assertSame(offscreenCanvas.height, 1000.0, "offscreenCanvas.height", "1000.0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.exp
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '100e1';
|
||||
offscreenCanvas.height = '100e1';
|
||||
_assertSame(offscreenCanvas.width, 1000.0, "offscreenCanvas.width", "1000.0");
|
||||
_assertSame(offscreenCanvas.height, 1000.0, "offscreenCanvas.height", "1000.0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.hex</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.hex</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '0x100';
|
||||
offscreenCanvas.height = '0x100';
|
||||
_assertSame(offscreenCanvas.width, 256, "offscreenCanvas.width", "256");
|
||||
_assertSame(offscreenCanvas.height, 256, "offscreenCanvas.height", "256");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.hex
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '0x100';
|
||||
offscreenCanvas.height = '0x100';
|
||||
_assertSame(offscreenCanvas.width, 256, "offscreenCanvas.width", "256");
|
||||
_assertSame(offscreenCanvas.height, 256, "offscreenCanvas.height", "256");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.junk</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.junk</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '#!?';
|
||||
offscreenCanvas.height = '#!?';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 50, "offscreenCanvas.height", "50");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.junk
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '#!?';
|
||||
offscreenCanvas.height = '#!?';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 50, "offscreenCanvas.height", "50");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.minus</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.minus</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '-100';
|
||||
offscreenCanvas.height = '-100';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 50, "offscreenCanvas.height", "50");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.minus
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '-100';
|
||||
offscreenCanvas.height = '-100';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 50, "offscreenCanvas.height", "50");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.octal</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.octal</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '0100';
|
||||
offscreenCanvas.height = '0100';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.octal
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '0100';
|
||||
offscreenCanvas.height = '0100';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.onlyspace</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.onlyspace</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = ' ';
|
||||
offscreenCanvas.height = ' ';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 50, "offscreenCanvas.height", "50");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.onlyspace
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = ' ';
|
||||
offscreenCanvas.height = ' ';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 50, "offscreenCanvas.height", "50");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.percent</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.percent</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '100%';
|
||||
offscreenCanvas.height = '100%';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.percent
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '100%';
|
||||
offscreenCanvas.height = '100%';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.plus</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.plus</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '+100';
|
||||
offscreenCanvas.height = '+100';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.plus
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '+100';
|
||||
offscreenCanvas.height = '+100';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.space</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.space</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = ' 100';
|
||||
offscreenCanvas.height = ' 100';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.space
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = ' 100';
|
||||
offscreenCanvas.height = ' 100';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.trailingjunk</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.trailingjunk</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '100#!?';
|
||||
offscreenCanvas.height = '100#!?';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.trailingjunk
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '100#!?';
|
||||
offscreenCanvas.height = '100#!?';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.whitespace</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.whitespace</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = ' 100';
|
||||
offscreenCanvas.height = ' 100';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.whitespace
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = ' 100';
|
||||
offscreenCanvas.height = ' 100';
|
||||
_assertSame(offscreenCanvas.width, 100, "offscreenCanvas.width", "100");
|
||||
_assertSame(offscreenCanvas.height, 100, "offscreenCanvas.height", "100");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.parse.zero</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.parse.zero</h1>
|
||||
<p class="desc">Parsing of non-negative integers</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '0';
|
||||
offscreenCanvas.height = '0';
|
||||
_assertSame(offscreenCanvas.width, 0, "offscreenCanvas.width", "0");
|
||||
_assertSame(offscreenCanvas.height, 0, "offscreenCanvas.height", "0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.parse.zero
|
||||
// Description:Parsing of non-negative integers
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Parsing of non-negative integers");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = '0';
|
||||
offscreenCanvas.height = '0';
|
||||
_assertSame(offscreenCanvas.width, 0, "offscreenCanvas.width", "0");
|
||||
_assertSame(offscreenCanvas.height, 0, "offscreenCanvas.height", "0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.reflect.setidl</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.reflect.setidl</h1>
|
||||
<p class="desc">Setting IDL attributes updates IDL and content attributes</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Setting IDL attributes updates IDL and content attributes");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 120;
|
||||
offscreenCanvas.height = 60;
|
||||
_assertSame(offscreenCanvas.width, 120, "offscreenCanvas.width", "120");
|
||||
_assertSame(offscreenCanvas.height, 60, "offscreenCanvas.height", "60");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.reflect.setidl
|
||||
// Description:Setting IDL attributes updates IDL and content attributes
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Setting IDL attributes updates IDL and content attributes");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 120;
|
||||
offscreenCanvas.height = 60;
|
||||
_assertSame(offscreenCanvas.width, 120, "offscreenCanvas.width", "120");
|
||||
_assertSame(offscreenCanvas.height, 60, "offscreenCanvas.height", "60");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.attributes.reflect.setidlzero</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.attributes.reflect.setidlzero</h1>
|
||||
<p class="desc">Setting IDL attributes to 0 updates IDL and content attributes</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Setting IDL attributes to 0 updates IDL and content attributes");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 0;
|
||||
offscreenCanvas.height = 0;
|
||||
_assertSame(offscreenCanvas.width, 0, "offscreenCanvas.width", "0");
|
||||
_assertSame(offscreenCanvas.height, 0, "offscreenCanvas.height", "0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.attributes.reflect.setidlzero
|
||||
// Description:Setting IDL attributes to 0 updates IDL and content attributes
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("Setting IDL attributes to 0 updates IDL and content attributes");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
offscreenCanvas.width = 0;
|
||||
offscreenCanvas.height = 0;
|
||||
_assertSame(offscreenCanvas.width, 0, "offscreenCanvas.width", "0");
|
||||
_assertSame(offscreenCanvas.height, 0, "offscreenCanvas.height", "0");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: size.large</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/canvas-tests.js"></script>
|
||||
|
||||
<h1>size.large</h1>
|
||||
<p class="desc"></p>
|
||||
|
||||
<p class="notes">Not sure how reasonable this is, but the spec doesn't say there's an upper limit on the size.
|
||||
<script>
|
||||
var t = async_test("");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var n = 2147483647; // 2^31 - 1, which should be supported by any sensible definition of "long"
|
||||
offscreenCanvas.width = n;
|
||||
offscreenCanvas.height = n;
|
||||
_assertSame(offscreenCanvas.width, n, "offscreenCanvas.width", "n");
|
||||
_assertSame(offscreenCanvas.height, n, "offscreenCanvas.height", "n");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,24 @@
|
|||
// DO NOT EDIT! This test has been generated by tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:size.large
|
||||
// Description:
|
||||
// Note:<p class="notes">Not sure how reasonable this is, but the spec doesn't say there's an upper limit on the size.
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/common/canvas-tests.js");
|
||||
|
||||
var t = async_test("");
|
||||
t.step(function() {
|
||||
|
||||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
var n = 2147483647; // 2^31 - 1, which should be supported by any sensible definition of "long"
|
||||
offscreenCanvas.width = n;
|
||||
offscreenCanvas.height = n;
|
||||
_assertSame(offscreenCanvas.width, n, "offscreenCanvas.width", "n");
|
||||
_assertSame(offscreenCanvas.height, n, "offscreenCanvas.height", "n");
|
||||
|
||||
t.done();
|
||||
|
||||
});
|
||||
done();
|
Loading…
Add table
Add a link
Reference in a new issue