Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several HTMLImageElement#complete bugs #2967

Closed
wants to merge 1 commit into from

Conversation

strager
Copy link
Contributor

@strager strager commented May 8, 2020

jsdom implements HTMLImageElement#complete poorly. I noticed this when I observed .complete giving false despite the onerror callback being called. To address this, perform the following changes:

  • Make .complete true if src is unset or is empty.
  • Make .complete true if an error occurs loading the image.
  • Make .complete false if .src is reset to an unloaded URL.

This commit fixes most (but not all) test cases in html/semantics/embedded-content/the-img-element/img.complete.html. This commit does not address srcset or the image list.

@strager strager force-pushed the img-complete branch 2 times, most recently from 07cccad to 4f01e47 Compare May 9, 2020 00:23
@strager strager marked this pull request as ready for review May 9, 2020 00:25
jsdom implements HTMLImageElement#complete poorly. I noticed this when
I observed .complete giving false despite the onerror callback being
called. To address this, perform the following changes:

* Make .complete true if src is unset or is empty.
* Make .complete true if an error occurs loading the image.
* Make .complete false if .src is reset to an unloaded URL.

This commit fixes most (but not all) test cases in
html/semantics/embedded-content/the-img-element/img.complete.html. This
commit does not address srcset or the image list.
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great, just some nits; thanks!

@@ -5,7 +5,16 @@ const HTMLElementImpl = require("./HTMLElement-impl").implementation;
const { Canvas } = require("../../utils");
const { parseURLToResultingURLRecord } = require("../helpers/document-base-url");

const REQUEST_STATE_BROKEN = "broken";
const REQUEST_STATE_COMPLETELY_AVAILABLE = "completely available";
const REQUEST_STATE_UNAVAILABLE = "unavailable";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's eliminate these and just use the strings directly.

@@ -0,0 +1,43 @@
<!DOCTYPE html>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you name this -dont-upstream.html since it's a copy of an existing file and we need to remember not to upstream it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I see it's not a copy of an existing file... I'll give this some thought.

@domenic
Copy link
Member

domenic commented Jul 5, 2020

I'm trying to push fixes to this branch but I cannot do so. Can you ensure that "Allow edits from maintainers" is checked, per https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork ?

@domenic domenic closed this in #3024 Aug 8, 2020
domenic added a commit that referenced this pull request Aug 8, 2020
In particular, now:

* complete returns true if src="" is unset or empty.
* complete returns true if an error occurs loading the image.
* complete returns false if src="" is reset to a not-yet-loaded URL.

Closes #2967 by superseding it.

Co-authored-by: Matthew Glazar <strager.nds@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants