-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb/HTML: Fix crash calling setTransform on canvas without context
This isn't a full fix, as the paint function does not handle this either. But instead of getting the bitmap from the image source immediately, follow the spec a bit more closely by creating the CanvasPatern object with the ImageSource directly. Fixes a crash for the 5 included WPT tests.
- Loading branch information
1 parent
3261f87
commit 819015d
Showing
13 changed files
with
233 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...cted/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.basic.nocontext.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Harness status: OK | ||
|
||
Found 1 tests | ||
|
||
1 Fail | ||
Fail Canvas test: 2d.pattern.basic.nocontext |
6 changes: 6 additions & 0 deletions
6
...expected/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.repeat.null.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Harness status: OK | ||
|
||
Found 1 tests | ||
|
||
1 Pass | ||
Pass Canvas test: 2d.pattern.repeat.null |
6 changes: 6 additions & 0 deletions
6
...d/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.transform.identity.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Harness status: OK | ||
|
||
Found 1 tests | ||
|
||
1 Fail | ||
Fail Canvas test: 2d.pattern.transform.identity |
6 changes: 6 additions & 0 deletions
6
...d/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.transform.infinity.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Harness status: OK | ||
|
||
Found 1 tests | ||
|
||
1 Fail | ||
Fail Canvas test: 2d.pattern.transform.infinity |
6 changes: 6 additions & 0 deletions
6
...ed/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.transform.invalid.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Harness status: OK | ||
|
||
Found 1 tests | ||
|
||
1 Pass | ||
Pass Canvas test: 2d.pattern.transform.invalid |
41 changes: 41 additions & 0 deletions
41
...put/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.basic.nocontext.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<meta charset="UTF-8"> | ||
<title>Canvas test: 2d.pattern.basic.nocontext</title> | ||
<script src="../../../../resources/testharness.js"></script> | ||
<script src="../../../../resources/testharnessreport.js"></script> | ||
<script src="../../../../html/canvas/resources/canvas-tests.js"></script> | ||
<link rel="stylesheet" href="../../../../html/canvas/resources/canvas-tests.css"> | ||
<body class="show_output"> | ||
|
||
<h1>2d.pattern.basic.nocontext</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 pattern = ctx.createPattern(canvas2, 'no-repeat'); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
ctx.fillStyle = '#f00'; | ||
ctx.fillStyle = pattern; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
_assertPixel(canvas, 1,1, 0,255,0,255); | ||
_assertPixel(canvas, 98,1, 0,255,0,255); | ||
_assertPixel(canvas, 1,48, 0,255,0,255); | ||
_assertPixel(canvas, 98,48, 0,255,0,255); | ||
|
||
}); | ||
</script> | ||
|
27 changes: 27 additions & 0 deletions
27
...t/input/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.repeat.null.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<meta charset="UTF-8"> | ||
<title>Canvas test: 2d.pattern.repeat.null</title> | ||
<script src="../../../../resources/testharness.js"></script> | ||
<script src="../../../../resources/testharnessreport.js"></script> | ||
<script src="../../../../html/canvas/resources/canvas-tests.js"></script> | ||
<link rel="stylesheet" href="../../../../html/canvas/resources/canvas-tests.css"> | ||
<body class="show_output"> | ||
|
||
<h1>2d.pattern.repeat.null</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> | ||
|
||
<ul id="d"></ul> | ||
<script> | ||
var t = async_test(""); | ||
_addTest(function(canvas, ctx) { | ||
|
||
_assert(ctx.createPattern(canvas, null) != null, "ctx.createPattern(canvas, null) != null"); | ||
|
||
}); | ||
</script> | ||
|
42 changes: 42 additions & 0 deletions
42
.../wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.transform.identity.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<meta charset="UTF-8"> | ||
<title>Canvas test: 2d.pattern.transform.identity</title> | ||
<script src="../../../../resources/testharness.js"></script> | ||
<script src="../../../../resources/testharnessreport.js"></script> | ||
<script src="../../../../html/canvas/resources/canvas-tests.js"></script> | ||
<link rel="stylesheet" href="../../../../html/canvas/resources/canvas-tests.css"> | ||
<body class="show_output"> | ||
|
||
<h1>2d.pattern.transform.identity</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 pattern = ctx.createPattern(canvas2, 'no-repeat'); | ||
pattern.setTransform(new DOMMatrix()); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
ctx.fillStyle = '#f00'; | ||
ctx.fillStyle = pattern; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
_assertPixel(canvas, 1,1, 0,255,0,255); | ||
_assertPixel(canvas, 98,1, 0,255,0,255); | ||
_assertPixel(canvas, 1,48, 0,255,0,255); | ||
_assertPixel(canvas, 98,48, 0,255,0,255); | ||
|
||
}); | ||
</script> | ||
|
42 changes: 42 additions & 0 deletions
42
.../wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.transform.infinity.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<meta charset="UTF-8"> | ||
<title>Canvas test: 2d.pattern.transform.infinity</title> | ||
<script src="../../../../resources/testharness.js"></script> | ||
<script src="../../../../resources/testharnessreport.js"></script> | ||
<script src="../../../../html/canvas/resources/canvas-tests.js"></script> | ||
<link rel="stylesheet" href="../../../../html/canvas/resources/canvas-tests.css"> | ||
<body class="show_output"> | ||
|
||
<h1>2d.pattern.transform.infinity</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 pattern = ctx.createPattern(canvas2, 'no-repeat'); | ||
pattern.setTransform({a: Infinity}); | ||
|
||
ctx.fillStyle = '#0f0'; | ||
ctx.fillRect(0, 0, 100, 50); | ||
ctx.fillStyle = '#f00'; | ||
ctx.fillStyle = pattern; | ||
ctx.fillRect(0, 0, 100, 50); | ||
|
||
_assertPixel(canvas, 1,1, 0,255,0,255); | ||
_assertPixel(canvas, 98,1, 0,255,0,255); | ||
_assertPixel(canvas, 1,48, 0,255,0,255); | ||
_assertPixel(canvas, 98,48, 0,255,0,255); | ||
|
||
}); | ||
</script> | ||
|
31 changes: 31 additions & 0 deletions
31
...t/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.pattern.transform.invalid.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> | ||
<meta charset="UTF-8"> | ||
<title>Canvas test: 2d.pattern.transform.invalid</title> | ||
<script src="../../../../resources/testharness.js"></script> | ||
<script src="../../../../resources/testharnessreport.js"></script> | ||
<script src="../../../../html/canvas/resources/canvas-tests.js"></script> | ||
<link rel="stylesheet" href="../../../../html/canvas/resources/canvas-tests.css"> | ||
<body class="show_output"> | ||
|
||
<h1>2d.pattern.transform.invalid</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> | ||
|
||
<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 pattern = ctx.createPattern(canvas2, 'no-repeat'); | ||
assert_throws_js(TypeError, function() { pattern.setTransform({a: 1, m11: 2}); }); | ||
|
||
}); | ||
</script> | ||
|
Binary file added
BIN
+86 Bytes
Tests/LibWeb/Text/input/wpt-import/html/canvas/images/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.