From 3ec848f4a81b9162e74a7d4fe662b3a701fbe3ad Mon Sep 17 00:00:00 2001 From: pylbrecht Date: Tue, 10 Mar 2020 19:48:46 +0100 Subject: [PATCH] Handle nonexistent images in CanvasRenderingContext2D.createPattern() --- Cargo.lock | 2 +- components/script/dom/htmlimageelement.rs | 11 ++++------- .../2d.drawImage.broken.html.ini | 4 ++++ .../2d.pattern.image.broken.html.ini | 4 ++++ .../2d.pattern.image.nonexistent.html.ini | 4 ---- .../2d.pattern.image.zeroheight.html.ini | 4 ++++ .../2d.pattern.image.zerowidth.html.ini | 4 ++++ .../2d.drawImage.broken.html.ini | 4 ++++ .../2d.pattern.image.broken.html.ini | 4 ++++ .../2d.pattern.image.nonexistent.html.ini | 4 ---- .../2d.pattern.image.zeroheight.html.ini | 4 ++++ .../2d.pattern.image.zerowidth.html.ini | 4 ++++ 12 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 tests/wpt/metadata-layout-2020/2dcontext/drawing-images-to-the-canvas/2d.drawImage.broken.html.ini create mode 100644 tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.broken.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.nonexistent.html.ini create mode 100644 tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.zeroheight.html.ini create mode 100644 tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.zerowidth.html.ini create mode 100644 tests/wpt/metadata/2dcontext/drawing-images-to-the-canvas/2d.drawImage.broken.html.ini create mode 100644 tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.broken.html.ini delete mode 100644 tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.nonexistent.html.ini create mode 100644 tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.zeroheight.html.ini create mode 100644 tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.zerowidth.html.ini diff --git a/Cargo.lock b/Cargo.lock index f8ea31cf9073..8e1cb57b1e31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5754,7 +5754,7 @@ dependencies = [ [[package]] name = "surfman-chains" version = "0.3.0" -source = "git+https://github.com/asajeffrey/surfman-chains?branch=multi#80a71b1a2df71ae70c3c194d0af40b8ebf72968a" +source = "git+https://github.com/asajeffrey/surfman-chains?branch=multi#e775b8c7807659958a4f20cf8e6eca4290f35124" dependencies = [ "euclid", "fnv", diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index a18eedebfb86..95e5c43af668 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -167,13 +167,10 @@ impl HTMLImageElement { // https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument pub fn is_usable(&self) -> Fallible { // If image has an intrinsic width or intrinsic height (or both) equal to zero, then return bad. - match &self.current_request.borrow().image { - Some(image) => { - if image.width == 0 || image.height == 0 { - return Ok(false); - } - }, - None => return Ok(false), + if let Some(image) = &self.current_request.borrow().image { + if image.width == 0 || image.height == 0 { + return Ok(false); + } } match self.current_request.borrow().state { diff --git a/tests/wpt/metadata-layout-2020/2dcontext/drawing-images-to-the-canvas/2d.drawImage.broken.html.ini b/tests/wpt/metadata-layout-2020/2dcontext/drawing-images-to-the-canvas/2d.drawImage.broken.html.ini new file mode 100644 index 000000000000..12725358b605 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/2dcontext/drawing-images-to-the-canvas/2d.drawImage.broken.html.ini @@ -0,0 +1,4 @@ +[2d.drawImage.broken.html] + [Canvas test: 2d.drawImage.broken] + expected: FAIL + diff --git a/tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.broken.html.ini b/tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.broken.html.ini new file mode 100644 index 000000000000..ff269ceac8cd --- /dev/null +++ b/tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.broken.html.ini @@ -0,0 +1,4 @@ +[2d.pattern.image.broken.html] + [Canvas test: 2d.pattern.image.broken] + expected: FAIL + diff --git a/tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.nonexistent.html.ini b/tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.nonexistent.html.ini deleted file mode 100644 index d1cbf15e5978..000000000000 --- a/tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.nonexistent.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[2d.pattern.image.nonexistent.html] - [Canvas test: 2d.pattern.image.nonexistent] - expected: FAIL - diff --git a/tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.zeroheight.html.ini b/tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.zeroheight.html.ini new file mode 100644 index 000000000000..06e296d0b50c --- /dev/null +++ b/tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.zeroheight.html.ini @@ -0,0 +1,4 @@ +[2d.pattern.image.zeroheight.html] + [Canvas test: 2d.pattern.image.zeroheight] + expected: FAIL + diff --git a/tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.zerowidth.html.ini b/tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.zerowidth.html.ini new file mode 100644 index 000000000000..2c8d1ad8ffe1 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/2dcontext/fill-and-stroke-styles/2d.pattern.image.zerowidth.html.ini @@ -0,0 +1,4 @@ +[2d.pattern.image.zerowidth.html] + [Canvas test: 2d.pattern.image.zerowidth] + expected: FAIL + diff --git a/tests/wpt/metadata/2dcontext/drawing-images-to-the-canvas/2d.drawImage.broken.html.ini b/tests/wpt/metadata/2dcontext/drawing-images-to-the-canvas/2d.drawImage.broken.html.ini new file mode 100644 index 000000000000..12725358b605 --- /dev/null +++ b/tests/wpt/metadata/2dcontext/drawing-images-to-the-canvas/2d.drawImage.broken.html.ini @@ -0,0 +1,4 @@ +[2d.drawImage.broken.html] + [Canvas test: 2d.drawImage.broken] + expected: FAIL + diff --git a/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.broken.html.ini b/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.broken.html.ini new file mode 100644 index 000000000000..ff269ceac8cd --- /dev/null +++ b/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.broken.html.ini @@ -0,0 +1,4 @@ +[2d.pattern.image.broken.html] + [Canvas test: 2d.pattern.image.broken] + expected: FAIL + diff --git a/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.nonexistent.html.ini b/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.nonexistent.html.ini deleted file mode 100644 index d1cbf15e5978..000000000000 --- a/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.nonexistent.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[2d.pattern.image.nonexistent.html] - [Canvas test: 2d.pattern.image.nonexistent] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.zeroheight.html.ini b/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.zeroheight.html.ini new file mode 100644 index 000000000000..06e296d0b50c --- /dev/null +++ b/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.zeroheight.html.ini @@ -0,0 +1,4 @@ +[2d.pattern.image.zeroheight.html] + [Canvas test: 2d.pattern.image.zeroheight] + expected: FAIL + diff --git a/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.zerowidth.html.ini b/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.zerowidth.html.ini new file mode 100644 index 000000000000..2c8d1ad8ffe1 --- /dev/null +++ b/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.pattern.image.zerowidth.html.ini @@ -0,0 +1,4 @@ +[2d.pattern.image.zerowidth.html] + [Canvas test: 2d.pattern.image.zerowidth] + expected: FAIL +