-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 #1365: Support image loading through node-canvas module. #1366
Conversation
The change in de89791 has fixed all failing tests as far as I can see. You may want to look into handling statusCodes properly elsewhere in the library, as it doesn't look like there is any handling of it right now. I think whit this commit, my work is so far completed. i have done extensive tests with the paper.js library, and haven't managed to find any issues. What's missing for this still is unit tests. How are you testing the other parts of the library? |
To test things that only work with the canvas package installed, we probably need to follow the pattern in test/living-html/htmlcanvaselement.js. The new web platform tests framework won't work as well for that. |
get width() { | ||
const parsed = parseInt(this.getAttribute("width")); | ||
const parsed = parseInt(this.getAttribute("width"), 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the 10s; that is the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, ok! But it used to be that parseInt("0...")
returned an octal value on some browsers? I'll take it out again : )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ES5 removed octal interpretation. older browsers will indeed interpret it as octal, however those older browsers are not supported anyway, since we require ES6 features. Do note that: parseInt('0x123', 10) === 0
and parseInt('0x123') === 291
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I read up on it in the meantime. There are definitely too many things to keep track of in the ES* universe, but it's an exciting time!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But looking through the jsdom source, I can spot other places where this is still in use, e.g. three locations in xmlhttprequest alone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And lastly, I am wondering why HTMLImageElement-Impl.js
uses this:
conversions["unsigned long"](this.getAttribute("width"))
While HTMLCanvasElement-Impl.js
uses this:
parseInt(this.getAttribute("width"))
Do you need more work from me for this PR, or is it just awaiting review now? |
It needs tests! |
I've been a bit frightened of touching that part, as it seems massive... Where do I find the canvas tests? |
Which command runs the sub-set of tests that |
|
Great, thanks! Is there a way to run both |
|
I have finally started to implement unit tests for this in 3d9060d, but some are currently failing: When setting Could you tell me why this is used there? If I replace the call with the content of its callback, then it all works as expected. But I cannot judge if this would break things elsewhere. |
I am not sure exactly why that is there; maybe there was just a desire that fetch() always be async. You can remove it, as long as it doesn't break other tests. It would be great if you could rebase, instead of merge. This branch is not really readable or reviewable as-is. |
Ok, I will give that a go. And I'm sorry about the merges. How can I fix this now? |
If you rebase on master (and preferably squash your commits), you can then force-push once the local history looks reasonable. |
Oh dear, that's all news to me... |
I might just create a patch from all my changes and reapply it to master in one commit. |
Yeah, that will work great! |
Cool, I keep working with the current branch, and once I'm done I do that as the last move, if you're OK with that. I'm nearly done with finishing the tests. |
Hmm I can't seem to be able to run all tests locally either way. It stalls at this line:
Do you have any ideas why? |
I'm not really sure. Maybe try doing |
370e8f0
to
9326a2c
Compare
Also adds support for: - HTMLImageElement.naturalWidth, naturalHeight, complete, currentSrc - HTMLCanvasElement.drawImage() - HTMLCanvasElement.toBlob()
9326a2c
to
86d9470
Compare
So here we go: Commit 86d9470 contains all my changes along with unit tests for them, and my modifications now pass all tests. This is good to go from my end, please review. |
Is there anything else that I can do to help out and expedite the merging in of this? The upcoming v0.10.0 of paper.js depends on it and we are otherwise good to go, so hoping it can find its way into a release soonish... |
Well, if you want to do my day job then that would certainly expedite things :). I generally work on jsdom on weekends when I have free time. |
Haha, gotcha :) I didn't mean to put pressure on, just wanted to make sure I do what I can to get the ball rolling. |
t.strictEqual(image.naturalWidth, 0, "before loading, naturalWidth should be 0"); | ||
t.strictEqual(image.naturalHeight, 0, "before loading, naturalHeight should be 0"); | ||
t.strictEqual(image.complete, false, "before loading, complete should be false"); | ||
t.strictEqual(image.src, "", "before loading, src should be an empty string"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect. src
should, per spec, reflect the src=""
content attribute. It should not change in the course of loading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see, you simply haven't set src
yet. OK, no problem.
Merged as 59f277b; thank you! Very cool stuff. |
Sweet, thanks! I'm happy to help out where I can. As soon as I find the time, I will tackle #1368 next. |
Also add support for: