-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
core: save native HTMLElement.prototype.matches function #6283
Conversation
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.
Nice! If you wanted to be extra secure with a test, you could throw a line that overrides matches to one of our smoke test files, probably the dbw_tester.html
?
5b2a8d6
to
b878b6a
Compare
Done, thanks for pointing me towards the smoke tests. |
Paul found this err'ing sites: https://www.fitreisen.de/
Well, the second one does. Looking into why the first one is failing. |
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.
LGTM!
OK, the first link fails due to specific elements having a custom property descriptor (overriding Switched to saving the method on |
b878b6a
to
03617b3
Compare
patch looks great. some of the smoketests are being a problem. Perhaps there's an extra console error now? |
yeah, seems that the two elements I added produces an extra log statement. It also makes for two fewer render blocking requests ... I guess these smoke tests are pretty fragile? I'll update the new expected values, let me know if that is incorrect. Output before changing expectations:
|
My assumption is that some sort of costly processing happens with each element, and it is throwing off the expected result of all those |
03617b3
to
d336580
Compare
@hoten yeah those smoketest errors definitely aren't expected. It looks like something is wrong with the HTML that's causing the rest of the elements to be dropped.
is an error that shouldn't be there. A different test can't find Also for the smoketest I'm thinking we want to redefine matches, not just use it to make sure our workaround is working-around something :) |
|
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.
nj getting into the smoke tests!
<object id="5934a"></object> | ||
<object id="5934b"></object> | ||
<script> | ||
document.getElementById("5934a").matches = "See #5934"; |
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.
can you add a comment on why these lines are here so we aren't mystified at some point in the future :)
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.
yup, done
@@ -1137,7 +1137,8 @@ class Driver { | |||
async cacheNatives() { | |||
await this.evaluateScriptOnNewDocument(`window.__nativePromise = Promise; | |||
window.__nativeError = Error; | |||
window.__nativeURL = URL;`); | |||
window.__nativeURL = URL; | |||
window.__ElementMatches = Element.prototype.matches;`); |
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.
👍👍 on the __ElementMatches
instead of modifying the prototype
d336580
to
5319678
Compare
@patrickhulce I'll add a line that also redefines |
Oh ya for sure didn't mean to suggest removing what you've already got 👍 :) |
Summary
HTMLElement.prototype.matches was being overriden (by userland code), so we now store the native implementation at
HTMLElement.prototype.__matches
and use that instead.Not sure how to make a test for this. If you use the sample HTML provided in the associated ticket, you'll see that the error no longer occurs.
Related Issues/PRs
Fixes #5934