Update web-platform-tests to revision e8bfc205e36ad699601212cd50083870bad9a75d

This commit is contained in:
Ms2ger 2016-11-14 11:07:09 +01:00
parent 65dd6d4340
commit ccdb0a3458
1428 changed files with 118036 additions and 9786 deletions

View file

@ -11,3 +11,4 @@ scratch
testharness_runner.html
webdriver/.idea
.vscode/
.DS_Store

View file

@ -1,14 +1,50 @@
sudo: false # cause Travis to start builds much faster
dist: trusty
language: python
python:
- "2.7"
addons:
hosts:
- web-platform.test
- www.web-platform.test
- www1.web-platform.test
- www2.web-platform.test
- xn--n8j6ds53lwwkrqhv28a.web-platform.test
- xn--lve-6lad.web-platform.test
before_install:
- git submodule update --init --recursive
# command to run tests, e.g. python setup.py test
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
install:
- pip install -U setuptools
- pip install -U requests
matrix:
include:
- os: linux
python: "2.7"
env:
- SCRIPT=ci_lint.sh
- os: linux
python: "2.7"
addons:
apt:
packages:
- libnss3-tools
env:
- secure: "YTSXPwI0DyCA1GhYrLT9KMEV6b7QQKuEeaQgeFDP38OTzJ1+cIj3CC4SRNqbnJ/6SJwPGcdqSxLuV8m4e5HFFnyCcQnJe6h8EMsTehZ7W3j/fP9UYrJqYqvGpe3Vj3xblO5pwBYmq7sg3jAmmuCgAgOW6VGf7cRMucrsmFeo7VM="
- SCRIPT=ci_stability.sh
- PRODUCT=firefox
- os: linux
sudo: required
python: "2.7"
addons:
apt:
packages:
- libappindicator1
- fonts-liberation
env:
- secure: "YTSXPwI0DyCA1GhYrLT9KMEV6b7QQKuEeaQgeFDP38OTzJ1+cIj3CC4SRNqbnJ/6SJwPGcdqSxLuV8m4e5HFFnyCcQnJe6h8EMsTehZ7W3j/fP9UYrJqYqvGpe3Vj3xblO5pwBYmq7sg3jAmmuCgAgOW6VGf7cRMucrsmFeo7VM="
- SCRIPT=ci_stability.sh
- PRODUCT=chrome
script:
- ./lint
- ./manifest
- ./diff-manifest.py
- bash $SCRIPT
notifications:
email:
on_success: never

View file

@ -0,0 +1,40 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.composite.globalAlpha.canvascopy</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.composite.globalAlpha.canvascopy</h1>
<p class="desc"></p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
var canvas2 = document.createElement('canvas');
canvas2.width = 100;
canvas2.height = 50;
var ctx2 = canvas2.getContext('2d');
ctx2.fillStyle = '#0f0';
ctx2.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy'
ctx.globalAlpha = 0.51;
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 0,255,0,130, "50,25", "0,255,0,130", 2);
});
</script>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsl-1</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsl-1</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsl-1.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120 100.0% 50.0%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsl-2</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsl-2</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsl-2.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120 100.0% 50.0% / 0.2)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsl-3</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsl-3</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsl-3.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120.0, 100.0%, 50.0%, 0.2)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsl-4</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsl-4</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsl-4.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120.0, 100.0%, 50.0%, 20%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsl-5</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsl-5</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsl-5.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120deg, 100.0%, 50.0%, 0.2)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsl-6</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsl-6</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsl-6.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120deg, 100.0%, 50.0%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsl-7</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsl-7</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsl-7.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(133.33333333grad, 100.0%, 50.0%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsl-8</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsl-8</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsl-8.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(2.0943951024rad, 100.0%, 50.0%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsl-9</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsl-9</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsl-9.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(0.3333333333turn, 100.0%, 50.0%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsla-1</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsla-1</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsla-1.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120 100.0% 50.0%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsla-2</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsla-2</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsla-2.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120 100.0% 50.0% / 0.2)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsla-3</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsla-3</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsla-3.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120.0, 100.0%, 50.0%, 0.2)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsla-4</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsla-4</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsla-4.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120.0, 100.0%, 50.0%, 20%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsla-5</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsla-5</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsla-5.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120deg, 100.0%, 50.0%, 0.2)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsla-6</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsla-6</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsla-6.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120deg, 100.0%, 50.0%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsla-7</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsla-7</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsla-7.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(133.33333333grad, 100.0%, 50.0%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsla-8</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsla-8</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsla-8.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(2.0943951024rad, 100.0%, 50.0%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-hsla-9</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-hsla-9</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-hsla-9.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(0.3333333333turn, 100.0%, 50.0%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-rgb-1</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-rgb-1</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-rgb-1.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(0, 255.0, 0)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-rgb-2</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-rgb-2</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-rgb-2.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(0, 255, 0, 0.2)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-rgb-3</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-rgb-3</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-rgb-3.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(0, 255, 0, 20%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-rgb-4</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-rgb-4</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-rgb-4.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(0 255 0)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-rgb-5</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-rgb-5</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-rgb-5.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(0 255 0 / 0.2)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-rgb-6</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-rgb-6</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-rgb-6.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(0 255 0 / 20%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-rgba-1</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-rgba-1</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-rgba-1.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba(0, 255.0, 0)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-rgba-2</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-rgba-2</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-rgba-2.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba(0, 255, 0, 0.2)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-rgba-3</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-rgba-3</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-rgba-3.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba(0, 255, 0, 20%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-rgba-4</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-rgba-4</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-rgba-4.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba(0 255 0)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-rgba-5</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-rgba-5</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-rgba-5.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba(0 255 0 / 0.2)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.css-color-4-rgba-6</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.css-color-4-rgba-6</h1>
<p class="desc"></p>
<p class="notes">
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="2d.fillStyle.parse.css-color-4-rgba-6.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba(0 255 0 / 20%)';
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,51, "50,25", "0,255,0,51");
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-hsl-1</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.css-color-4-hsl-1</h1>
<p class="desc"></p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsl(0, 100%, 50% / 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-hsl-2</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.css-color-4-hsl-2</h1>
<p class="desc"></p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsl(0 100% 50%, 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

View file

@ -1,13 +1,13 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.rgba-7</title>
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-hsl-3</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.rgba-7</h1>
<h1>2d.fillStyle.parse.invalid.css-color-4-hsl-3</h1>
<p class="desc"></p>
@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(255, 0, 0, '; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'hsl(0, 100% 50%)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -1,13 +1,13 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.rgb-7</title>
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-hsl-4</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.rgb-7</h1>
<h1>2d.fillStyle.parse.invalid.css-color-4-hsl-4</h1>
<p class="desc"></p>
@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255, 0, 0, 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'hsl(0 100% 50% /)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-hsl-5</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.css-color-4-hsl-5</h1>
<p class="desc"></p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsl(0, 100%, 50% /)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-hsla-1</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.css-color-4-hsla-1</h1>
<p class="desc"></p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsla(0, 100%, 50% / 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-hsla-2</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.css-color-4-hsla-2</h1>
<p class="desc"></p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsla(0 100% 50%, 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-hsla-3</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.css-color-4-hsla-3</h1>
<p class="desc"></p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsla(0, 100% 50%)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-rgb-1</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.css-color-4-rgb-1</h1>
<p class="desc"></p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255, 0, 0 / 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

View file

@ -1,13 +1,13 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.rgb-4</title>
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-rgb-2</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.rgb-4</h1>
<h1>2d.fillStyle.parse.invalid.css-color-4-rgb-2</h1>
<p class="desc"></p>
@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(100%, 0, 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'rgb(255 0 0, 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-rgb-3</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.css-color-4-rgb-3</h1>
<p class="desc"></p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255, 0 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

View file

@ -1,13 +1,13 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.rgb-5</title>
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-rgb-4</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.rgb-5</h1>
<h1>2d.fillStyle.parse.invalid.css-color-4-rgb-4</h1>
<p class="desc"></p>
@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255 0 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'rgb(0 0 0 /)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-rgb-5</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.css-color-4-rgb-5</h1>
<p class="desc"></p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(0, 0, 0 /)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-rgba-1</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.css-color-4-rgba-1</h1>
<p class="desc"></p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(255, 0, 0 / 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

View file

@ -1,13 +1,13 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.rgb-6</title>
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-rgba-2</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.rgb-6</h1>
<h1>2d.fillStyle.parse.invalid.css-color-4-rgba-2</h1>
<p class="desc"></p>
@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255, - 1, 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'rgba(255 0 0, 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.css-color-4-rgba-3</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.css-color-4-rgba-3</h1>
<p class="desc"></p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(255, 0 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
});
</script>

View file

@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsl(0, 100%, 100%, 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'hsl(0, 100.%, 50%)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsl(0, 100.%, 50%)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'hsl(0, 100%, 50%,)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -1,13 +1,13 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.fillStyle.parse.invalid.rgba-6</title>
<title>Canvas test: 2d.fillStyle.parse.invalid.hsla-3</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.fillStyle.parse.invalid.rgba-6</h1>
<h1>2d.fillStyle.parse.invalid.hsla-3</h1>
<p class="desc"></p>
@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(255, 0, 0, 1.)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'hsla(0, 0, 50%, 1,)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255.0, 0, 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'rgb(255.0, 0, 0,)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255, 0.0, 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'rgb(100%, 0, 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255.0, 0, 0,)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'rgb(255, - 1, 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(255, 0, 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'rgba(100%, 0, 0, 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(255.0, 0, 0, 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'rgba(255, 0, 0, 1. 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(100%, 0, 0, 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'rgba(255, 0, 0, 1.)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(255, 0, 0, 100%)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'rgba(255, 0, 0, '; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -21,7 +21,7 @@ _addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(255, 0, 0, 1. 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
try { ctx.fillStyle = 'rgba(255, 0, 0, 1,)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");

View file

@ -0,0 +1,104 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>setLineDash</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<canvas id="canvas"></canvas>
<script>
test(function() {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var initial = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
ctx.setLineDash(initial);
assert_array_equals(ctx.getLineDash(), initial, "line dash sanity");
ctx.setLineDash([Infinity]);
assert_array_equals(ctx.getLineDash(), initial, "Inf doesn't reset line dash");
ctx.setLineDash([NaN]);
assert_array_equals(ctx.getLineDash(), initial, "NaN doesn't reset line dash");
ctx.setLineDash([-1]);
assert_array_equals(ctx.getLineDash(), initial, "Negative doesn't reset line dash");
}, "Invalid arguments to setLineDash()");
test(function() {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
assert_equals(ctx.lineDashOffset, 0);
ctx.setLineDash([15, 10]);
ctx.lineDashOffset = 5;
ctx.strokeRect(10,10,100,100);
var lineDash = ctx.getLineDash();
assert_array_equals(lineDash, [15, 10]);
assert_equals(ctx.lineDashOffset, 5);
ctx.setLineDash([5, 10, 15]);
ctx.strokeRect(20, 20, 120, 120);
lineDash = ctx.getLineDash();
assert_array_equals(lineDash, [5, 10, 15, 5, 10, 15]);
ctx.setLineDash(["1", 2]);
lineDash = ctx.getLineDash();
assert_array_equals(lineDash, [1, 2]);
ctx.clearRect(0, 0, 700, 700);
assert_equals(ctx.lineDashOffset, 5);
ctx.setLineDash([20, 10]);
ctx.lineDashOffset = 0;
// Make the test immune to plaform anti-aliasing discrepancies.
ctx.lineWidth = 4;
ctx.strokeStyle = '#00FF00';
ctx.strokeRect(10.5, 10.5, 30, 30);
_assertPixel(canvas, 25, 10, 0, 255, 0, 255, 0);
_assertPixel(canvas, 35, 10, 0, 0, 0, 0, 0);
_assertPixel(canvas, 40, 25, 0, 255, 0, 255, 0);
_assertPixel(canvas, 40, 35, 0, 0, 0, 0, 0);
_assertPixel(canvas, 25, 40, 0, 255, 0, 255, 0);
_assertPixel(canvas, 15, 40, 0, 0, 0, 0, 0);
_assertPixel(canvas, 10, 25, 0, 255, 0, 255, 0);
_assertPixel(canvas, 10, 15, 0, 0, 0, 0, 0);
// Verify that lineDashOffset works as expected.
ctx.lineDashOffset = 20;
ctx.strokeRect(50.5, 10.5, 30, 30);
_assertPixel(canvas, 55, 10, 0, 0, 0, 0, 0);
_assertPixel(canvas, 65, 10, 0, 255, 0, 255, 0);
_assertPixel(canvas, 80, 15, 0, 0, 0, 0, 0);
_assertPixel(canvas, 80, 25, 0, 255, 0, 255, 0);
_assertPixel(canvas, 75, 40, 0, 0, 0, 0, 0);
_assertPixel(canvas, 65, 40, 0, 255, 0, 255, 0);
_assertPixel(canvas, 50, 35, 0, 0, 0, 0, 0);
_assertPixel(canvas, 50, 25, 0, 255, 0, 255, 0);
// Verify negative lineDashOffset.
ctx.lineDashOffset = -10;
ctx.strokeRect(90.5, 10.5, 30, 30);
_assertPixel(canvas, 95, 10, 0, 0, 0, 0, 0);
_assertPixel(canvas, 105, 10, 0, 255, 0, 255, 0);
_assertPixel(canvas, 120, 15, 0, 0, 0, 0, 0);
_assertPixel(canvas, 120, 25, 0, 255, 0, 255, 0);
_assertPixel(canvas, 115, 40, 0, 0, 0, 0, 0);
_assertPixel(canvas, 105, 40, 0, 255, 0, 255, 0);
_assertPixel(canvas, 90, 35, 0, 0, 0, 0, 0);
_assertPixel(canvas, 90, 25, 0, 255, 0, 255, 0);
// Ensure that all zeros or negative pattern does not cause error state in
// context.
ctx.setLineDash([0, 0]);
ctx.strokeRect(130.5, 10.5, 10, 10);
ctx.setLineDash([-1]);
ctx.strokeRect(130.5, 10.5, 10, 10);
_assertPixel(canvas, 135, 15, 0, 0, 0, 0, 0);
ctx.fillStyle = '#00FF00';
ctx.fillRect(130, 10, 10, 10);
_assertPixel(canvas, 135, 15, 0, 255, 0, 255, 0);
});
</script>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.path.lineTo.nonfinite.details</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">
<h1>2d.path.lineTo.nonfinite.details</h1>
<p class="desc">lineTo() with Infinity/NaN for first arg still converts the second arg</p>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<p class="output expectedtext">Expected output:<p><img src="/images/clear-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("lineTo() with Infinity/NaN for first arg still converts the second arg");
_addTest(function(canvas, ctx) {
for (var arg1 of [Infinity, -Infinity, NaN]) {
var converted = false;
ctx.lineTo(arg1, { valueOf: function() { converted = true; return 0; } });
_assert(converted, "converted");
}
});
</script>

View file

@ -1005,6 +1005,26 @@
@assert pixel 50,25 ==~ 2,253,0,255;
expected: green
- name: 2d.composite.globalAlpha.canvascopy
testing:
- 2d.composite.globalAlpha.image
code: |
var canvas2 = document.createElement('canvas');
canvas2.width = 100;
canvas2.height = 50;
var ctx2 = canvas2.getContext('2d');
ctx2.fillStyle = '#0f0';
ctx2.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy'
ctx.globalAlpha = 0.51;
ctx.drawImage(canvas2, 0, 0);
@assert pixel 50,25 ==~ 0,255,0,130;
expected: green
- meta: |
# Composite operation tests
@ -1372,6 +1392,40 @@
('hsla-clamp-6', 'hsla(120, 100%, 0%, -2)', 0,0,0,0, ""),
('svg-1', 'gray', 128,128,128,255, ""),
('svg-2', 'grey', 128,128,128,255, ""),
# css-color-4 rgb() color function
# https://drafts.csswg.org/css-color/#numeric-rgb
('css-color-4-rgb-1', 'rgb(0, 255.0, 0)', 0,255,0,255, ""),
('css-color-4-rgb-2', 'rgb(0, 255, 0, 0.2)', 0,255,0,51, ""),
('css-color-4-rgb-3', 'rgb(0, 255, 0, 20%)', 0,255,0,51, ""),
('css-color-4-rgb-4', 'rgb(0 255 0)', 0,255,0,255, ""),
('css-color-4-rgb-5', 'rgb(0 255 0 / 0.2)', 0,255,0,51, ""),
('css-color-4-rgb-6', 'rgb(0 255 0 / 20%)', 0,255,0,51, ""),
('css-color-4-rgba-1', 'rgba(0, 255.0, 0)', 0,255,0,255, ""),
('css-color-4-rgba-2', 'rgba(0, 255, 0, 0.2)', 0,255,0,51, ""),
('css-color-4-rgba-3', 'rgba(0, 255, 0, 20%)', 0,255,0,51, ""),
('css-color-4-rgba-4', 'rgba(0 255 0)', 0,255,0,255, ""),
('css-color-4-rgba-5', 'rgba(0 255 0 / 0.2)', 0,255,0,51, ""),
('css-color-4-rgba-6', 'rgba(0 255 0 / 20%)', 0,255,0,51, ""),
# css-color-4 hsl() color function
# https://drafts.csswg.org/css-color/#the-hsl-notation
('css-color-4-hsl-1', 'hsl(120 100.0% 50.0%)', 0,255,0,255, ""),
('css-color-4-hsl-2', 'hsl(120 100.0% 50.0% / 0.2)', 0,255,0,51, ""),
('css-color-4-hsl-3', 'hsl(120.0, 100.0%, 50.0%, 0.2)', 0,255,0,51, ""),
('css-color-4-hsl-4', 'hsl(120.0, 100.0%, 50.0%, 20%)', 0,255,0,51, ""),
('css-color-4-hsl-5', 'hsl(120deg, 100.0%, 50.0%, 0.2)', 0,255,0,51, ""),
('css-color-4-hsl-6', 'hsl(120deg, 100.0%, 50.0%)', 0,255,0,255, ""),
('css-color-4-hsl-7', 'hsl(133.33333333grad, 100.0%, 50.0%)', 0,255,0,255, ""),
('css-color-4-hsl-8', 'hsl(2.0943951024rad, 100.0%, 50.0%)', 0,255,0,255, ""),
('css-color-4-hsl-9', 'hsl(0.3333333333turn, 100.0%, 50.0%)', 0,255,0,255, ""),
('css-color-4-hsla-1', 'hsl(120 100.0% 50.0%)', 0,255,0,255, ""),
('css-color-4-hsla-2', 'hsl(120 100.0% 50.0% / 0.2)', 0,255,0,51, ""),
('css-color-4-hsla-3', 'hsl(120.0, 100.0%, 50.0%, 0.2)', 0,255,0,51, ""),
('css-color-4-hsla-4', 'hsl(120.0, 100.0%, 50.0%, 20%)', 0,255,0,51, ""),
('css-color-4-hsla-5', 'hsl(120deg, 100.0%, 50.0%, 0.2)', 0,255,0,51, ""),
('css-color-4-hsla-6', 'hsl(120deg, 100.0%, 50.0%)', 0,255,0,255, ""),
('css-color-4-hsla-7', 'hsl(133.33333333grad, 100.0%, 50.0%)', 0,255,0,255, ""),
('css-color-4-hsla-8', 'hsl(2.0943951024rad, 100.0%, 50.0%)', 0,255,0,255, ""),
('css-color-4-hsla-9', 'hsl(0.3333333333turn, 100.0%, 50.0%)', 0,255,0,255, ""),
# currentColor is handled later
]:
# TODO: test by retrieving fillStyle, instead of actually drawing?
@ -1404,33 +1458,47 @@
('hex6', '#fg0000'),
('hex7', '#ff0000f'),
('hex8', '#fg0000ff'),
('rgb-1', 'rgb(255.0, 0, 0)'),
('rgb-2', 'rgb(255, 0.0, 0)'),
('rgb-3', 'rgb(255.0, 0, 0,)'),
('rgb-4', 'rgb(100%, 0, 0)'),
('rgb-5', 'rgb(255 0 0)'),
('rgb-6', 'rgb(255, - 1, 0)'),
('rgb-7', 'rgb(255, 0, 0, 1)'),
('rgba-1', 'rgba(255, 0, 0)'),
('rgba-2', 'rgba(255.0, 0, 0, 1)'),
('rgba-3', 'rgba(100%, 0, 0, 1)'),
('rgba-4', 'rgba(255, 0, 0, 100%)'),
('rgba-5', 'rgba(255, 0, 0, 1. 0)'),
('rgba-6', 'rgba(255, 0, 0, 1.)'),
('rgba-7', 'rgba(255, 0, 0, '),
('rgb-1', 'rgb(255.0, 0, 0,)'),
('rgb-2', 'rgb(100%, 0, 0)'),
('rgb-3', 'rgb(255, - 1, 0)'),
('rgba-1', 'rgba(100%, 0, 0, 1)'),
('rgba-2', 'rgba(255, 0, 0, 1. 0)'),
('rgba-3', 'rgba(255, 0, 0, 1.)'),
('rgba-4', 'rgba(255, 0, 0, '),
('rgba-5', 'rgba(255, 0, 0, 1,)'),
('hsl-1', 'hsl(0%, 100%, 50%)'),
('hsl-2', 'hsl(z, 100%, 50%)'),
('hsl-3', 'hsl(0, 0, 50%)'),
('hsl-4', 'hsl(0, 100%, 0)'),
('hsl-5', 'hsl(0, 100%, 100%, 1)'),
('hsl-6', 'hsl(0, 100.%, 50%)'),
('hsl-5', 'hsl(0, 100.%, 50%)'),
('hsl-6', 'hsl(0, 100%, 50%,)'),
('hsla-1', 'hsla(0%, 100%, 50%, 1)'),
('hsla-2', 'hsla(0, 0, 50%, 1)'),
('hsla-3', 'hsla(0, 0, 50%, 1,)'),
('name-1', 'darkbrown'),
('name-2', 'firebrick1'),
('name-3', 'red blue'),
('name-4', '"red"'),
('name-5', '"red'),
# css-color-4 color function
# comma and comma-less expressions should not mix together.
('css-color-4-rgb-1', 'rgb(255, 0, 0 / 1)'),
('css-color-4-rgb-2', 'rgb(255 0 0, 1)'),
('css-color-4-rgb-3', 'rgb(255, 0 0)'),
('css-color-4-rgba-1', 'rgba(255, 0, 0 / 1)'),
('css-color-4-rgba-2', 'rgba(255 0 0, 1)'),
('css-color-4-rgba-3', 'rgba(255, 0 0)'),
('css-color-4-hsl-1', 'hsl(0, 100%, 50% / 1)'),
('css-color-4-hsl-2', 'hsl(0 100% 50%, 1)'),
('css-color-4-hsl-3', 'hsl(0, 100% 50%)'),
('css-color-4-hsla-1', 'hsla(0, 100%, 50% / 1)'),
('css-color-4-hsla-2', 'hsla(0 100% 50%, 1)'),
('css-color-4-hsla-3', 'hsla(0, 100% 50%)'),
# trailing slash
('css-color-4-rgb-4', 'rgb(0 0 0 /)'),
('css-color-4-rgb-5', 'rgb(0, 0, 0 /)'),
('css-color-4-hsl-4', 'hsl(0 100% 50% /)'),
('css-color-4-hsl-5', 'hsl(0, 100%, 50% /)'),
]:
test = {
'name': '2d.fillStyle.parse.invalid.%s' % name,
@ -6197,6 +6265,18 @@
@assert pixel 90,45 == 0,255,0,255;
expected: green
- name: 2d.path.lineTo.nonfinite.details
desc: lineTo() with Infinity/NaN for first arg still converts the second arg
testing:
- 2d.nonfinite
code: |
for (var arg1 of [Infinity, -Infinity, NaN]) {
var converted = false;
ctx.lineTo(arg1, { valueOf: function() { converted = true; return 0; } });
@assert converted;
}
expected: clear
- name: 2d.path.quadraticCurveTo.ensuresubpath.1
desc: If there is no subpath, the first control point is added (and nothing is drawn up to it)
testing:

View file

@ -0,0 +1,382 @@
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="timeout" content="long">
<title>IDBCursor.continuePrimaryKey() - Exception Orders </title>
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="help" href="http://w3c.github.io/IndexedDB/#dom-idbcursor-continueprimarykey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
function setup_test_store(db) {
var records = [ { iKey: "A", pKey: 1 },
{ iKey: "A", pKey: 2 },
{ iKey: "A", pKey: 3 },
{ iKey: "A", pKey: 4 },
{ iKey: "B", pKey: 5 },
{ iKey: "B", pKey: 6 },
{ iKey: "B", pKey: 7 },
{ iKey: "C", pKey: 8 },
{ iKey: "C", pKey: 9 },
{ iKey: "D", pKey: 10 } ];
var store = db.createObjectStore("test", { keyPath: "pKey" });
var index = store.createIndex("idx", "iKey");
for(var i = 0; i < records.length; i++) {
store.add(records[i]);
}
return store;
}
indexeddb_test(
function(t, db, txn) {
var store = setup_test_store(db);
var index = store.index("idx");
var cursor_rq = index.openCursor();
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
cursor = e.target.result;
assert_true(!!cursor, "acquire cursor");
store.deleteIndex("idx");
});
txn.oncomplete = function() {
assert_throws("TransactionInactiveError", function() {
cursor.continuePrimaryKey("A", 4);
}, "transaction-state check should precede deletion check");
t.done();
};
},
null,
"TransactionInactiveError v.s. InvalidStateError(deleted index)"
);
indexeddb_test(
function(t, db, txn) {
var store = setup_test_store(db);
var cursor_rq = store.openCursor();
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
cursor = e.target.result;
assert_true(!!cursor, "acquire cursor");
db.deleteObjectStore("test");
assert_throws("InvalidStateError", function() {
cursor.continuePrimaryKey("A", 4);
}, "deletion check should precede index source check");
t.done();
});
},
null,
"InvalidStateError(deleted source) v.s. InvalidAccessError(incorrect source)"
);
indexeddb_test(
function(t, db, txn) {
var store = setup_test_store(db);
var index = store.index("idx");
var cursor_rq = index.openCursor(null, "nextunique");
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
cursor = e.target.result;
assert_true(!!cursor, "acquire cursor");
store.deleteIndex("idx");
assert_throws("InvalidStateError", function() {
cursor.continuePrimaryKey("A", 4);
}, "deletion check should precede cursor direction check");
t.done();
});
},
null,
"InvalidStateError(deleted source) v.s. InvalidAccessError(incorrect direction)"
);
indexeddb_test(
function(t, db, txn) {
var store = db.createObjectStore("test", {keyPath:"pKey"});
var index = store.createIndex("idx", "iKey");
store.add({ iKey: "A", pKey: 1 });
var cursor_rq = index.openCursor(null, "nextunique");
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
if (e.target.result) {
cursor = e.target.result;
cursor.continue();
return;
}
assert_throws("InvalidAccessError", function() {
cursor.continuePrimaryKey("A", 4);
}, "direction check should precede got_value_flag check");
t.done();
});
},
null,
"InvalidAccessError(incorrect direction) v.s. InvalidStateError(iteration complete)"
);
indexeddb_test(
function(t, db, txn) {
var store = db.createObjectStore("test", {keyPath:"pKey"});
var index = store.createIndex("idx", "iKey");
store.add({ iKey: "A", pKey: 1 });
var cursor_rq = index.openCursor(null, "nextunique");
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
if (!cursor) {
cursor = e.target.result;
assert_true(!!cursor, "acquire cursor");
cursor.continue();
assert_throws("InvalidAccessError", function() {
cursor.continuePrimaryKey("A", 4);
}, "direction check should precede iteration ongoing check");
t.done();
}
});
},
null,
"InvalidAccessError(incorrect direction) v.s. InvalidStateError(iteration ongoing)"
);
indexeddb_test(
function(t, db, txn) {
var store = setup_test_store(db);
var cursor_rq = store.openCursor();
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
if (!cursor) {
cursor = e.target.result;
assert_true(!!cursor, "acquire cursor");
cursor.continue();
assert_throws("InvalidAccessError", function() {
cursor.continuePrimaryKey("A", 4);
}, "index source check should precede iteration ongoing check");
t.done();
}
});
},
null,
"InvalidAccessError(incorrect source) v.s. InvalidStateError(iteration ongoing)"
);
indexeddb_test(
function(t, db, txn) {
var store = db.createObjectStore("test", {keyPath:"pKey"});
store.add({ iKey: "A", pKey: 1 });
var cursor_rq = store.openCursor();
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
if (e.target.result) {
cursor = e.target.result;
cursor.continue();
return;
}
assert_throws("InvalidAccessError", function() {
cursor.continuePrimaryKey("A", 4);
}, "index source check should precede got_value_flag check");
t.done();
});
},
null,
"InvalidAccessError(incorrect source) v.s. InvalidStateError(iteration complete)"
);
indexeddb_test(
function(t, db, txn) {
var store = setup_test_store(db);
var index = store.index("idx");
var cursor_rq = index.openCursor();
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
if (!cursor) {
cursor = e.target.result;
assert_true(!!cursor, "acquire cursor");
cursor.continue();
assert_throws("InvalidStateError", function() {
cursor.continuePrimaryKey(null, 4);
}, "iteration ongoing check should precede unset key check");
t.done();
}
});
},
null,
"InvalidStateError(iteration ongoing) v.s. DataError(unset key)"
);
indexeddb_test(
function(t, db, txn) {
var store = db.createObjectStore("test", {keyPath:"pKey"});
var index = store.createIndex("idx", "iKey");
store.add({ iKey: "A", pKey: 1 });
var cursor_rq = index.openCursor();
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
if (e.target.result) {
cursor = e.target.result;
cursor.continue();
return;
}
assert_throws("InvalidStateError", function() {
cursor.continuePrimaryKey(null, 4);
}, "got_value_flag check should precede unset key check");
t.done();
});
},
null,
"InvalidStateError(iteration complete) v.s. DataError(unset key)"
);
indexeddb_test(
function(t, db, txn) {
var store = setup_test_store(db);
var index = store.index("idx");
var cursor_rq = index.openCursor();
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
cursor = e.target.result;
assert_true(!!cursor, "acquire cursor");
assert_throws("DataError", function() {
cursor.continuePrimaryKey(null, 4);
}, "DataError is expected if key is unset.");
t.done();
});
},
null,
"DataError(unset key)"
);
indexeddb_test(
function(t, db, txn) {
var store = setup_test_store(db);
var index = store.index("idx");
var cursor_rq = index.openCursor();
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
cursor = e.target.result;
assert_true(!!cursor, "acquire cursor");
assert_throws("DataError", function() {
cursor.continuePrimaryKey("A", null);
}, "DataError is expected if primary key is unset.");
t.done();
});
},
null,
"DataError(unset primary key)"
);
indexeddb_test(
function(t, db, txn) {
var store = setup_test_store(db);
var index = store.index("idx");
var cursor_rq = index.openCursor(IDBKeyRange.lowerBound("B"));
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
cursor = e.target.result;
assert_true(!!cursor, "acquire cursor");
assert_equals(cursor.key, "B", "expected key");
assert_equals(cursor.primaryKey, 5, "expected primary key");
assert_throws("DataError", function() {
cursor.continuePrimaryKey("A", 6);
}, "DataError is expected if key is lower then current one.");
assert_throws("DataError", function() {
cursor.continuePrimaryKey("B", 5);
}, "DataError is expected if primary key is equal to current one.");
assert_throws("DataError", function() {
cursor.continuePrimaryKey("B", 4);
}, "DataError is expected if primary key is lower than current one.");
t.done();
});
},
null,
"DataError(keys are lower then current one) in 'next' direction"
);
indexeddb_test(
function(t, db, txn) {
var store = setup_test_store(db);
var index = store.index("idx");
var cursor_rq = index.openCursor(IDBKeyRange.upperBound("B"), "prev");
var cursor;
cursor_rq.onerror = t.unreached_func('openCursor should succeed');
cursor_rq.onsuccess = t.step_func(function(e) {
cursor = e.target.result;
assert_true(!!cursor, "acquire cursor");
assert_equals(cursor.key, "B", "expected key");
assert_equals(cursor.primaryKey, 7, "expected primary key");
assert_throws("DataError", function() {
cursor.continuePrimaryKey("C", 6);
}, "DataError is expected if key is larger then current one.");
assert_throws("DataError", function() {
cursor.continuePrimaryKey("B", 7);
}, "DataError is expected if primary key is equal to current one.");
assert_throws("DataError", function() {
cursor.continuePrimaryKey("B", 8);
}, "DataError is expected if primary key is larger than current one.");
t.done();
});
},
null,
"DataError(keys are larger then current one) in 'prev' direction"
);
</script>
<div id="log"></div>

View file

@ -0,0 +1,110 @@
<!DOCTYPE html>
<title>IndexedDB: index renaming support in aborted transactions</title>
<link rel="help"
href="https://w3c.github.io/IndexedDB/#dom-idbindex-name">
<link rel="author" href="pwnall@chromium.org" title="Victor Costan">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support-promises.js"></script>
<script>
promise_test(testCase => {
const dbName = databaseName(testCase);
let authorIndex = null, authorIndex2 = null;
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
authorIndex = store.index('by_author');
authorIndex.name = 'renamed_by_author';
transaction.abort();
assert_equals(
authorIndex.name, 'by_author',
'IDBIndex.name should not reflect the rename any more ' +
'immediately after transaction.abort() returns');
assert_array_equals(
store.indexNames, ['by_author', 'by_title'],
'IDBObjectStore.indexNames should not reflect the rename any ' +
'more immediately after transaction.abort() returns');
})).then(event => {
assert_equals(
authorIndex.name, 'by_author',
'IDBIndex.name should not reflect the rename any more after the ' +
'versionchange transaction is aborted');
const request = indexedDB.open(dbName, 1);
return requestWatcher(testCase, request).wait_for('success');
}).then(event => {
const database = event.target.result;
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
assert_array_equals(
store.indexNames, ['by_author', 'by_title'],
'IDBDatabase.objectStoreNames should not reflect the rename ' +
'after the versionchange transaction is aborted');
authorIndex2 = store.index('by_author');
return checkAuthorIndexContents(
testCase, authorIndex2,
'Aborting an index rename transaction should not change the ' +
"index's records").then(() => database.close());
}).then(() => {
assert_equals(
authorIndex.name, 'by_author',
'IDBIndex used in aborted rename transaction should not reflect ' +
'the rename after the transaction is aborted');
assert_equals(authorIndex2.name, 'by_author',
'IDBIndex obtained after an aborted rename transaction should ' +
'not reflect the rename');
});
}, 'IndexedDB index rename in aborted transaction');
promise_test(testCase => {
const dbName = databaseName(testCase);
let authorIndex = null;
return createDatabase(testCase, (database, transaction) => {
createNotBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('not_books');
authorIndex = store.createIndex('by_author', 'author');
authorIndex.name = 'by_author_renamed';
authorIndex.name = 'by_author_renamed_again';
transaction.abort();
assert_equals(
authorIndex.name, 'by_author_renamed_again',
'IDBIndex.name should reflect the last rename immediately after ' +
'transaction.abort() returns');
assert_array_equals(
store.indexNames, ['not_by_author', 'not_by_title'],
'IDBObjectStore.indexNames should not reflect the creation or ' +
'the rename immediately after transaction.abort() returns');
})).then(event => {
assert_equals(
authorIndex.name, 'by_author_renamed_again',
'IDBIndex.name should reflect the last rename after the ' +
'versionchange transaction is aborted');
const request = indexedDB.open(dbName, 1);
return requestWatcher(testCase, request).wait_for('success');
}).then(event => {
const database = event.target.result;
const transaction = database.transaction('not_books', 'readonly');
const store = transaction.objectStore('not_books');
assert_array_equals(
store.indexNames, ['not_by_author', 'not_by_title'],
'IDBDatabase.objectStoreNames should not reflect the creation or ' +
'the rename after the versionchange transaction is aborted');
database.close();
});
}, 'IndexedDB index creation and rename in an aborted transaction');
</script>

View file

@ -0,0 +1,130 @@
<!DOCTYPE html>
<title>IndexedDB: index renaming error handling</title>
<link rel="help"
href="https://w3c.github.io/IndexedDB/#dom-idbindex-name">
<link rel="author" href="pwnall@chromium.org" title="Victor Costan">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support-promises.js"></script>
<script>
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
const index = store.index('by_author');
store.deleteIndex('by_author');
assert_throws(
'InvalidStateError', () => index.name = 'renamed_by_author');
})).then(database => database.close());
}, 'IndexedDB deleted index rename throws');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
const index = store.index('by_author');
assert_throws(
'InvalidStateError', () => index.name = 'renamed_by_author');
database.close();
});
}, 'IndexedDB index rename throws in a readonly transaction');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
const transaction = database.transaction('books', 'readwrite');
const store = transaction.objectStore('books');
const index = store.index('by_author');
assert_throws(
'InvalidStateError', () => index.name = 'renamed_by_author');
database.close();
});
}, 'IndexedDB index rename throws in a readwrite transaction');
promise_test(testCase => {
let authorIndex = null;
return createDatabase(testCase, (database, transaction) => {
const store = createBooksStore(testCase, database);
authorIndex = store.index('by_author');
}).then(database => {
assert_throws(
'TransactionInactiveError',
() => authorIndex.name = 'renamed_by_author');
database.close();
});
}, 'IndexedDB index rename throws in an inactive transaction');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
const index = store.index('by_author');
assert_throws('ConstraintError', () => index.name = 'by_title');
assert_array_equals(
store.indexNames, ['by_author', 'by_title'],
'An index rename that throws an exception should not change the ' +
"index's IDBObjectStore.indexNames");
})).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
assert_array_equals(
store.indexNames, ['by_author', 'by_title'],
'Committing a transaction with a failed store rename attempt ' +
"should not change the index's IDBObjectStore.indexNames");
const index = store.index('by_author');
return checkAuthorIndexContents(
testCase, index,
'Committing a transaction with a failed rename attempt should ' +
"not change the index's contents").then(() => database.close());
});
}, 'IndexedDB index rename to the name of another index throws');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
const index = store.index('by_author');
assert_throws(
{ name: 'Custom stringifying error' },
() => {
index.name = {
toString: () => { throw { name: 'Custom stringifying error'}; }
};
}, 'IDBObjectStore rename should re-raise toString() exception');
assert_array_equals(
store.indexNames, ['by_author', 'by_title'],
'An index rename that throws an exception should not change the ' +
"index's IDBObjectStore.indexNames");
})).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
assert_array_equals(
store.indexNames, ['by_author', 'by_title'],
'Committing a transaction with a failed store rename attempt ' +
"should not change the index's IDBObjectStore.indexNames");
const index = store.index('by_author');
return checkAuthorIndexContents(
testCase, index,
'Committing a transaction with a failed rename attempt should ' +
"not change the index's contents").then(() => database.close());
});
}, 'IndexedDB index rename handles exceptions when stringifying names');
</script>

View file

@ -0,0 +1,298 @@
<!DOCTYPE html>
<title>IndexedDB: index renaming support</title>
<link rel="help"
href="https://w3c.github.io/IndexedDB/#dom-idbindex-name">
<link rel="author" href="pwnall@chromium.org" title="Victor Costan">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support-promises.js"></script>
<script>
promise_test(testCase => {
let authorIndex = null, authorIndex2 = null;
let renamedAuthorIndex = null, renamedAuthorIndex2 = null;
return createDatabase(testCase, (database, transaction) => {
const store = createBooksStore(testCase, database);
authorIndex = store.index('by_author');
}).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
assert_array_equals(
store.indexNames, ['by_author', 'by_title'],
'Test setup should have created two indexes');
authorIndex2 = store.index('by_author');
return checkAuthorIndexContents(
testCase, authorIndex2,
'The index should have the expected contents before any renaming').
then(() => database.close());
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
renamedAuthorIndex = store.index('by_author');
renamedAuthorIndex.name = 'renamed_by_author';
assert_equals(
renamedAuthorIndex.name, 'renamed_by_author',
'IDBIndex name should change immediately after a rename');
assert_array_equals(
store.indexNames, ['by_title', 'renamed_by_author'],
'IDBObjectStore.indexNames should immediately reflect the rename');
assert_equals(
store.index('renamed_by_author'), renamedAuthorIndex,
'IDBObjectStore.index should return the renamed index store when ' +
'queried using the new name immediately after the rename');
assert_throws(
'NotFoundError', () => store.index('by_author'),
'IDBObjectStore.index should throw when queried using the ' +
"renamed index's old name immediately after the rename");
})).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
assert_array_equals(
store.indexNames, ['by_title', 'renamed_by_author'],
'IDBObjectStore.indexNames should still reflect the rename after ' +
'the versionchange transaction commits');
renamedAuthorIndex2 = store.index('renamed_by_author');
return checkAuthorIndexContents(
testCase, renamedAuthorIndex2,
'Renaming an index should not change its contents').then(
() => database.close());
}).then(() => {
assert_equals(
authorIndex.name, 'by_author',
'IDBIndex obtained before the rename transaction should not ' +
'reflect the rename');
assert_equals(
authorIndex2.name, 'by_author',
'IDBIndex obtained before the rename transaction should not ' +
'reflect the rename');
assert_equals(
renamedAuthorIndex.name, 'renamed_by_author',
'IDBIndex used in the rename transaction should keep reflecting ' +
'the new name after the transaction is committed');
assert_equals(
renamedAuthorIndex2.name, 'renamed_by_author',
'IDBIndex obtained after the rename transaction should reflect ' +
'the new name');
});
}, 'IndexedDB index rename in new transaction');
promise_test(testCase => {
let renamedAuthorIndex = null, renamedAuthorIndex2 = null;
return createDatabase(testCase, (database, transaction) => {
const store = createBooksStore(testCase, database);
renamedAuthorIndex = store.index('by_author');
renamedAuthorIndex.name = 'renamed_by_author';
assert_equals(
renamedAuthorIndex.name, 'renamed_by_author',
'IDBIndex name should change immediately after a rename');
assert_array_equals(
store.indexNames, ['by_title', 'renamed_by_author'],
'IDBObjectStore.indexNames should immediately reflect the rename');
assert_equals(
store.index('renamed_by_author'), renamedAuthorIndex,
'IDBObjectStore.index should return the renamed index store when ' +
'queried using the new name immediately after the rename');
assert_throws(
'NotFoundError', () => store.index('by_author'),
'IDBObjectStore.index should throw when queried using the ' +
"renamed index's old name immediately after the rename");
}).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
assert_array_equals(
store.indexNames, ['by_title', 'renamed_by_author'],
'IDBObjectStore.indexNames should still reflect the rename after ' +
'the versionchange transaction commits');
renamedAuthorIndex2 = store.index('renamed_by_author');
return checkAuthorIndexContents(
testCase, renamedAuthorIndex2,
'Renaming an index should not change its contents').then(
() => database.close());
}).then(() => {
assert_equals(
renamedAuthorIndex.name, 'renamed_by_author',
'IDBIndex used in the rename transaction should keep reflecting ' +
'the new name after the transaction is committed');
assert_equals(
renamedAuthorIndex2.name, 'renamed_by_author',
'IDBIndex obtained after the rename transaction should reflect ' +
'the new name');
});
}, 'IndexedDB index rename in the transaction where it is created');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
const index = store.index('by_author');
index.name = 'by_author';
assert_array_equals(
store.indexNames, ['by_author', 'by_title'],
'Renaming an index to the same name should not change the ' +
"index's IDBObjectStore.indexNames");
})).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
assert_array_equals(
store.indexNames, ['by_author', 'by_title'],
'Committing a transaction that renames a store to the same name ' +
"should not change the index's IDBObjectStore.indexNames");
const index = store.index('by_author');
return checkAuthorIndexContents(
testCase, index,
'Committing a transaction that renames an index to the same name ' +
"should not change the index's contents").then(
() => database.close());
});
}, 'IndexedDB index rename to the same name succeeds');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
const index = store.index('by_author');
store.deleteIndex('by_title');
index.name = 'by_title';
assert_array_equals(
store.indexNames, ['by_title'],
'IDBObjectStore.indexNames should immediately reflect the rename');
})).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
assert_array_equals(
store.indexNames, ['by_title'],
'IDBObjectStore.indexNames should still reflect the rename after ' +
'the versionchange transaction commits');
const index = store.index('by_title');
return checkAuthorIndexContents(
testCase, index,
'Renaming an index should not change its contents').then(
() => database.close());
});
}, 'IndexedDB index rename to the name of a deleted index succeeds');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
store.index('by_author').name = 'tmp';
store.index('by_title').name = 'by_author';
store.index('tmp').name = 'by_title';
assert_array_equals(
store.indexNames, ['by_author', 'by_title'],
'IDBObjectStore.indexNames should reflect the swap immediately ' +
'after the renames');
return checkTitleIndexContents(
testCase, store.index('by_author'),
'Renaming an index should not change its contents');
})).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
assert_array_equals(
store.indexNames, ['by_author', 'by_title'],
'IDBObjectStore.indexNames should still reflect the swap after ' +
'the versionchange transaction commits');
const index = store.index('by_title');
return checkAuthorIndexContents(
testCase, index,
'Renaming an index should not change its contents').then(
() => database.close());
});
}, 'IndexedDB index swapping via renames succeeds');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
const index = store.index('by_author');
index.name = 42;
assert_equals(index.name, '42',
'IDBIndex name should change immediately after a rename to a ' +
'number');
assert_array_equals(
store.indexNames, ['42', 'by_title'],
'IDBObjectStore.indexNames should immediately reflect the ' +
'stringifying rename');
index.name = true;
assert_equals(index.name, 'true',
'IDBIndex name should change immediately after a rename to a ' +
'boolean');
index.name = {};
assert_equals(index.name, '[object Object]',
'IDBIndex name should change immediately after a rename to an ' +
'object');
index.name = () => null;
assert_equals(index.name, '() => null',
'IDBIndex name should change immediately after a rename to a ' +
'function');
index.name = undefined;
assert_equals(index.name, 'undefined',
'IDBIndex name should change immediately after a rename to ' +
'undefined');
})).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
assert_array_equals(
store.indexNames, ['by_title', 'undefined'],
'IDBObjectStore.indexNames should reflect the last rename ' +
'after the versionchange transaction commits');
const index = store.index('undefined');
return checkAuthorIndexContents(
testCase, index,
'Renaming an index should not change its contents').then(
() => database.close());
});
}, 'IndexedDB index rename stringifies non-string names');
for (let escapedName of ['', '\\u0000', '\\uDC00\\uD800']) ((escapedName) => {
const name = JSON.parse('"' + escapedName + '"');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
const index = store.index('by_author');
index.name = name;
assert_equals(index.name, name,
'IDBIndex name should change immediately after the rename');
assert_array_equals(
store.indexNames, [name, 'by_title'].sort(),
'IDBObjectStore.indexNames should immediately reflect the rename');
})).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
assert_array_equals(
store.indexNames, [name, 'by_title'].sort(),
'IDBObjectStore.indexNames should reflect the rename ' +
'after the versionchange transaction commits');
const index = store.index(name);
return checkAuthorIndexContents(
testCase, index,
'Renaming an index should not change its contents').then(
() => database.close());
});
}, 'IndexedDB index can be renamed to "' + escapedName + '"');
})(escapedName);
</script>

View file

@ -0,0 +1,120 @@
<!DOCTYPE html>
<title>IndexedDB: object store renaming support in aborted transactions</title>
<link rel="help"
href="https://w3c.github.io/IndexedDB/#dom-idbobjectstore-name">
<link rel="author" href="pwnall@chromium.org" title="Victor Costan">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support-promises.js"></script>
<script>
promise_test(testCase => {
const dbName = databaseName(testCase);
let bookStore = null, bookStore2 = null;
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
bookStore = transaction.objectStore('books');
bookStore.name = 'renamed_books';
transaction.abort();
assert_equals(
bookStore.name, 'books',
'IDBObjectStore.name should not reflect the rename any more ' +
'immediately after transaction.abort() returns');
assert_array_equals(
database.objectStoreNames, ['books'],
'IDBDatabase.objectStoreNames should not reflect the rename ' +
'any more immediately after transaction.abort() returns');
assert_array_equals(
transaction.objectStoreNames, ['books'],
'IDBTransaction.objectStoreNames should not reflect the ' +
'rename any more immediately after transaction.abort() returns');
})).then(event => {
assert_equals(bookStore.name, 'books',
'IDBObjectStore.name should not reflect the rename any more ' +
'after the versionchange transaction is aborted');
const request = indexedDB.open(dbName, 1);
return requestWatcher(testCase, request).wait_for('success');
}).then(event => {
const database = event.target.result;
assert_array_equals(
database.objectStoreNames, ['books'],
'IDBDatabase.objectStoreNames should not reflect the rename ' +
'after the versionchange transaction is aborted');
const transaction = database.transaction('books', 'readonly');
bookStore2 = transaction.objectStore('books');
return checkStoreContents(
testCase, bookStore2,
'Aborting an object store rename transaction should not change ' +
"the store's records").then(() => database.close());
}).then(() => {
assert_equals(
bookStore.name, 'books',
'IDBObjectStore used in aborted rename transaction should not ' +
'reflect the rename after the transaction is aborted');
assert_equals(
bookStore2.name, 'books',
'IDBObjectStore obtained after an aborted rename transaction ' +
'should not reflect the rename');
});
}, 'IndexedDB object store rename in aborted transaction');
promise_test(testCase => {
const dbName = databaseName(testCase);
let notBookStore = null;
return createDatabase(testCase, (database, transaction) => {
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
notBookStore = createNotBooksStore(testCase, database);
notBookStore.name = 'not_books_renamed';
notBookStore.name = 'not_books_renamed_again';
transaction.abort();
assert_equals(
notBookStore.name, 'not_books_renamed_again',
'IDBObjectStore.name should reflect the last rename ' +
'immediately after transaction.abort() returns');
assert_array_equals(
database.objectStoreNames, [],
'IDBDatabase.objectStoreNames should not reflect the creation ' +
'or the rename any more immediately after transaction.abort() ' +
'returns');
assert_array_equals(
transaction.objectStoreNames, [],
'IDBTransaction.objectStoreNames should not reflect the ' +
'creation or the rename any more immediately after ' +
'transaction.abort() returns');
assert_array_equals(notBookStore.indexNames, [],
'IDBObjectStore.indexNames for the newly created store ' +
'should be empty immediately after transaction.abort() ' +
'returns');
})).then(event => {
assert_equals(
notBookStore.name, 'not_books_renamed_again',
'IDBObjectStore.name should reflect the last rename after the ' +
'versionchange transaction is aborted');
assert_array_equals(notBookStore.indexNames, [],
'IDBObjectStore.indexNames for the newly created store ' +
'should be empty after the versionchange transaction is aborted ' +
'returns');
const request = indexedDB.open(dbName, 1);
return requestWatcher(testCase, request).wait_for('success');
}).then(event => {
const database = event.target.result;
assert_array_equals(
database.objectStoreNames, [],
'IDBDatabase.objectStoreNames should not reflect the creation or ' +
'the rename after the versionchange transaction is aborted');
database.close();
});
}, 'IndexedDB object store creation and rename in an aborted transaction');
</script>

View file

@ -0,0 +1,118 @@
<!DOCTYPE html>
<title>IndexedDB: object store renaming error handling</title>
<link rel="help"
href="https://w3c.github.io/IndexedDB/#dom-idbobjectstore-name">
<link rel="author" href="pwnall@chromium.org" title="Victor Costan">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support-promises.js"></script>
<script>
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
database.deleteObjectStore('books');
assert_throws('InvalidStateError', () => store.name = 'renamed_books');
})).then(database => {
database.close();
});
}, 'IndexedDB deleted object store rename throws');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
assert_throws('InvalidStateError', () => store.name = 'renamed_books');
database.close();
});
}, 'IndexedDB object store rename throws in a readonly transaction');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
const transaction = database.transaction('books', 'readwrite');
const store = transaction.objectStore('books');
assert_throws('InvalidStateError', () => store.name = 'renamed_books');
database.close();
});
}, 'IndexedDB object store rename throws in a readwrite transaction');
promise_test(testCase => {
let bookStore = null;
return createDatabase(testCase, (database, transaction) => {
bookStore = createBooksStore(testCase, database);
}).then(database => {
assert_throws('TransactionInactiveError',
() => { bookStore.name = 'renamed_books'; });
database.close();
});
}, 'IndexedDB object store rename throws in an inactive transaction');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
createNotBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
assert_throws('ConstraintError', () => store.name = 'not_books');
assert_array_equals(
database.objectStoreNames, ['books', 'not_books'],
'A store rename that throws an exception should not change the ' +
"store's IDBDatabase.objectStoreNames");
})).then(database => {
assert_array_equals(
database.objectStoreNames, ['books', 'not_books'],
'Committing a transaction with a failed store rename attempt ' +
"should not change the store's IDBDatabase.objectStoreNames");
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
return checkStoreContents(
testCase, store,
'Committing a transaction with a failed rename attempt should ' +
"not change the store's contents").then(() => database.close());
});
}, 'IndexedDB object store rename to the name of another store throws');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
assert_throws(
{ name: 'Custom stringifying error' },
() => {
store.name = {
toString: () => { throw { name: 'Custom stringifying error'}; }
};
}, 'IDBObjectStore rename should re-raise toString() exception');
assert_array_equals(
database.objectStoreNames, ['books'],
'A store rename that throws an exception should not change the ' +
"store's IDBDatabase.objectStoreNames");
})).then(database => {
assert_array_equals(
database.objectStoreNames, ['books'],
'Committing a transaction with a failed store rename attempt ' +
"should not change the store's IDBDatabase.objectStoreNames");
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
return checkStoreContents(
testCase, store,
'Committing a transaction with a failed rename attempt should ' +
"not change the store's contents").then(() => database.close());
});
}, 'IndexedDB object store rename handles exceptions when stringifying names');
</script>

View file

@ -0,0 +1,366 @@
<!DOCTYPE html>
<title>IndexedDB: object store renaming support</title>
<link rel="help"
href="https://w3c.github.io/IndexedDB/#dom-idbobjectstore-name">
<link rel="author" href="pwnall@chromium.org" title="Victor Costan">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support-promises.js"></script>
<script>
// Renames the 'books' store to 'renamed_books'.
//
// Returns a promise that resolves to an IndexedDB database. The caller must
// close the database.
const renameBooksStore = (testCase) => {
return migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
store.name = 'renamed_books';
});
};
promise_test(testCase => {
let bookStore = null, bookStore2 = null;
let renamedBookStore = null, renamedBookStore2 = null;
return createDatabase(testCase, (database, transaction) => {
bookStore = createBooksStore(testCase, database);
}).then(database => {
assert_array_equals(
database.objectStoreNames, ['books'],
'Test setup should have created a "books" object store');
const transaction = database.transaction('books', 'readonly');
bookStore2 = transaction.objectStore('books');
return checkStoreContents(
testCase, bookStore2,
'The store should have the expected contents before any renaming').
then(() => database.close());
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
renamedBookStore = transaction.objectStore('books');
renamedBookStore.name = 'renamed_books';
assert_equals(
renamedBookStore.name, 'renamed_books',
'IDBObjectStore name should change immediately after a rename');
assert_array_equals(
database.objectStoreNames, ['renamed_books'],
'IDBDatabase.objectStoreNames should immediately reflect the ' +
'rename');
assert_array_equals(
transaction.objectStoreNames, ['renamed_books'],
'IDBTransaction.objectStoreNames should immediately reflect the ' +
'rename');
assert_equals(
transaction.objectStore('renamed_books'), renamedBookStore,
'IDBTransaction.objectStore should return the renamed object ' +
'store when queried using the new name immediately after the ' +
'rename');
assert_throws(
'NotFoundError', () => transaction.objectStore('books'),
'IDBTransaction.objectStore should throw when queried using the ' +
"renamed object store's old name immediately after the rename");
})).then(database => {
assert_array_equals(
database.objectStoreNames, ['renamed_books'],
'IDBDatabase.objectStoreNames should still reflect the rename ' +
'after the versionchange transaction commits');
const transaction = database.transaction('renamed_books', 'readonly');
renamedBookStore2 = transaction.objectStore('renamed_books');
return checkStoreContents(
testCase, renamedBookStore2,
'Renaming an object store should not change its records').then(
() => database.close());
}).then(() => {
assert_equals(
bookStore.name, 'books',
'IDBObjectStore obtained before the rename transaction should ' +
'not reflect the rename');
assert_equals(
bookStore2.name, 'books',
'IDBObjectStore obtained before the rename transaction should ' +
'not reflect the rename');
assert_equals(
renamedBookStore.name, 'renamed_books',
'IDBObjectStore used in the rename transaction should keep ' +
'reflecting the new name after the transaction is committed');
assert_equals(
renamedBookStore2.name, 'renamed_books',
'IDBObjectStore obtained after the rename transaction should ' +
'reflect the new name');
});
}, 'IndexedDB object store rename in new transaction');
promise_test(testCase => {
let renamedBookStore = null, renamedBookStore2 = null;
return createDatabase(testCase, (database, transaction) => {
renamedBookStore = createBooksStore(testCase, database);
renamedBookStore.name = 'renamed_books';
assert_equals(
renamedBookStore.name, 'renamed_books',
'IDBObjectStore name should change immediately after a rename');
assert_array_equals(
database.objectStoreNames, ['renamed_books'],
'IDBDatabase.objectStoreNames should immediately reflect the ' +
'rename');
assert_array_equals(
transaction.objectStoreNames, ['renamed_books'],
'IDBTransaction.objectStoreNames should immediately reflect the ' +
'rename');
assert_equals(
transaction.objectStore('renamed_books'), renamedBookStore,
'IDBTransaction.objectStore should return the renamed object ' +
'store when queried using the new name immediately after the ' +
'rename');
assert_throws(
'NotFoundError', () => transaction.objectStore('books'),
'IDBTransaction.objectStore should throw when queried using the ' +
"renamed object store's old name immediately after the rename");
}).then(database => {
assert_array_equals(
database.objectStoreNames, ['renamed_books'],
'IDBDatabase.objectStoreNames should still reflect the rename ' +
'after the versionchange transaction commits');
const transaction = database.transaction('renamed_books', 'readonly');
renamedBookStore2 = transaction.objectStore('renamed_books');
return checkStoreContents(
testCase, renamedBookStore2,
'Renaming an object store should not change its records').then(
() => database.close());
}).then(() => {
assert_equals(
renamedBookStore.name, 'renamed_books',
'IDBObjectStore used in the rename transaction should keep ' +
'reflecting the new name after the transaction is committed');
assert_equals(
renamedBookStore2.name, 'renamed_books',
'IDBObjectStore obtained after the rename transaction should ' +
'reflect the new name');
});
}, 'IndexedDB object store rename in the transaction where it is created');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
return checkStoreIndexes(
testCase, store,
'The object store index should have the expected contens before ' +
'any renaming').then(
() => database.close());
}).then(() => renameBooksStore(testCase)
).then(database => {
const transaction = database.transaction('renamed_books', 'readonly');
const store = transaction.objectStore('renamed_books');
return checkStoreIndexes(
testCase, store,
'Renaming an object store should not change its indexes').then(
() => database.close());
});
}, 'IndexedDB object store rename covers index');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
const transaction = database.transaction('books', 'readwrite');
const store = transaction.objectStore('books');
return checkStoreGenerator(
testCase, store, 345679,
'The object store key generator should have the expected state ' +
'before any renaming').then(() => database.close());
}).then(() => renameBooksStore(testCase)
).then(database => {
const transaction = database.transaction('renamed_books', 'readwrite');
const store = transaction.objectStore('renamed_books');
return checkStoreGenerator(
testCase, store, 345680,
'Renaming an object store should not change the state of its key ' +
'generator').then(() => database.close());
});
}, 'IndexedDB object store rename covers key generator');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
store.name = 'books';
assert_array_equals(
database.objectStoreNames, ['books'],
'Renaming a store to the same name should not change ' +
"the store's IDBDatabase.objectStoreNames");
})).then(database => {
assert_array_equals(
database.objectStoreNames, ['books'],
'Committing a transaction that renames a store to the same name ' +
"should not change the store's IDBDatabase.objectStoreNames");
const transaction = database.transaction('books', 'readonly');
const store = transaction.objectStore('books');
return checkStoreContents(
testCase, store,
'Committing a transaction that renames a store to the same name ' +
"should not change the store's contents").then(
() => database.close());
});
}, 'IndexedDB object store rename to the same name succeeds');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
createNotBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
database.deleteObjectStore('not_books');
store.name = 'not_books';
assert_array_equals(
database.objectStoreNames, ['not_books'],
'IDBDatabase.objectStoreNames should immediately reflect the ' +
'rename');
})).then(database => {
assert_array_equals(
database.objectStoreNames, ['not_books'],
'IDBDatabase.objectStoreNames should still reflect the rename ' +
'after the versionchange transaction commits');
const transaction = database.transaction('not_books', 'readonly');
const store = transaction.objectStore('not_books');
return checkStoreContents(
testCase, store,
'Renaming an object store should not change its records').then(
() => database.close());
});
}, 'IndexedDB object store rename to the name of a deleted store succeeds');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
createNotBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const bookStore = transaction.objectStore('books');
const notBookStore = transaction.objectStore('not_books');
transaction.objectStore('books').name = 'tmp';
transaction.objectStore('not_books').name = 'books';
transaction.objectStore('tmp').name = 'not_books';
assert_array_equals(
database.objectStoreNames, ['books', 'not_books'],
'IDBDatabase.objectStoreNames should immediately reflect the swap');
assert_equals(
transaction.objectStore('books'), notBookStore,
'IDBTransaction.objectStore should return the original "books" ' +
'store when queried with "not_books" after the swap');
assert_equals(
transaction.objectStore('not_books'), bookStore,
'IDBTransaction.objectStore should return the original ' +
'"not_books" store when queried with "books" after the swap');
})).then(database => {
assert_array_equals(
database.objectStoreNames, ['books', 'not_books'],
'IDBDatabase.objectStoreNames should still reflect the swap ' +
'after the versionchange transaction commits');
const transaction = database.transaction('not_books', 'readonly');
const store = transaction.objectStore('not_books');
assert_array_equals(
store.indexNames, ['by_author', 'by_title'],
'"not_books" index names should still reflect the swap after the ' +
'versionchange transaction commits');
return checkStoreContents(
testCase, store,
'Swapping two object stores should not change their records').then(
() => database.close());
});
}, 'IndexedDB object store swapping via renames succeeds');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
store.name = 42;
assert_equals(store.name, '42',
'IDBObjectStore name should change immediately after a ' +
'rename to a number');
assert_array_equals(
database.objectStoreNames, ['42'],
'IDBDatabase.objectStoreNames should immediately reflect the ' +
'stringifying rename');
store.name = true;
assert_equals(store.name, 'true',
'IDBObjectStore name should change immediately after a ' +
'rename to a boolean');
store.name = {};
assert_equals(store.name, '[object Object]',
'IDBObjectStore name should change immediately after a ' +
'rename to an object');
store.name = () => null;
assert_equals(store.name, '() => null',
'IDBObjectStore name should change immediately after a ' +
'rename to a function');
store.name = undefined;
assert_equals(store.name, 'undefined',
'IDBObjectStore name should change immediately after a ' +
'rename to undefined');
})).then(database => {
assert_array_equals(
database.objectStoreNames, ['undefined'],
'IDBDatabase.objectStoreNames should reflect the last rename ' +
'after the versionchange transaction commits');
const transaction = database.transaction('undefined', 'readonly');
const store = transaction.objectStore('undefined');
return checkStoreContents(
testCase, store,
'Renaming an object store should not change its records').then(
() => database.close());
});
}, 'IndexedDB object store rename stringifies non-string names');
for (let escapedName of ['', '\\u0000', '\\uDC00\\uD800']) ((escapedName) => {
const name = JSON.parse('"' + escapedName + '"');
promise_test(testCase => {
return createDatabase(testCase, (database, transaction) => {
createBooksStore(testCase, database);
}).then(database => {
database.close();
}).then(() => migrateDatabase(testCase, 2, (database, transaction) => {
const store = transaction.objectStore('books');
store.name = name;
assert_equals(store.name, name,
'IDBObjectStore name should change immediately after the ' +
'rename');
assert_array_equals(
database.objectStoreNames, [name],
'IDBDatabase.objectStoreNames should immediately reflect the ' +
'rename');
})).then(database => {
assert_array_equals(
database.objectStoreNames, [name],
'IDBDatabase.objectStoreNames should reflect the rename ' +
'after the versionchange transaction commits');
const transaction = database.transaction(name, 'readonly');
const store = transaction.objectStore(name);
return checkStoreContents(
testCase, store,
'Renaming an object store should not change its records').then(
() => database.close());
});
}, 'IndexedDB object store can be renamed to "' + escapedName + '"');
})(escapedName);
</script>

Some files were not shown because too many files have changed in this diff Show more