You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Don't crash when calling nodes_from_point without a document element #10093
A-content/domInteracting with the DOM from web contentC-assignedThere is someone working on resolving the issueE-less-complexStraightforward. Recommended for a new contributor.
Right now, the function Document::nodes_from_point is called when using document.elementsFromPoint.
That function asserts that there should be a document element to run, and crashes if not. It should return an empty vector in that case, preferrably issuing a debug!() message.
Code:
components/script/dom/document.rs (the function nodes_from_point).
@ecoal95 Hi, actually I think document.elementsFromPoint haven't crashed yet, even with the assertion. Is it better for us to remove the assertion and change it to a check to return an empty vector?
By the way, the error message for the [No viewport available] subtest is:
│ FAIL [expected PASS] No viewport available
│ → assert_array_equals: Should have returned [] lengths differ, expected 0 got 2
rather than frames[1] is undefined or window.frames[1] is undefined
So, I'm not sure whether this subtest is using an iframe. The subtest code:
test(function () {
var doc = document.implementation.createHTMLDocument('foo');
assert_array_equals(doc.elementsFromPoint(0, 0), [],
"Should have returned []")
}, "No viewport available");
If my guess is right that this subtest isn't using an iframe, I'm curious whether it can be fixed without we're worrying about iframes.
EDIT: Never mind my reply above, still reading a documentation on createHTMLDocument.
EDIT 2: I guess the subtest code calls createHTMLDocument without appending the new HTML Document to an iframe? (So the new HTML Document doesn't visible (doesn't have a viewport) ).
Yeah, changing the assertion doesn't fix the subtest result:
A-content/domInteracting with the DOM from web contentC-assignedThere is someone working on resolving the issueE-less-complexStraightforward. Recommended for a new contributor.
Activity
luthfianto commentedon Mar 19, 2016
I'd love to work on this
emilio commentedon Mar 19, 2016
That was fast, it's yours!
Don't forget to mention (in the case I don't review that PR) that there are no new passing tests due to the reasons described in #10091 :)
luthfianto commentedon Mar 19, 2016
@ecoal95 Hi, actually I think
document.elementsFromPointhaven't crashed yet, even with the assertion. Is it better for us to remove the assertion and change it to a check to return an empty vector?By the way, the error message for the
[No viewport available]subtest is:rather than
frames[1] is undefinedorwindow.frames[1] is undefinedSo, I'm not sure whether this subtest is using an iframe. The subtest code:
If my guess is right that this subtest isn't using an iframe, I'm curious whether it can be fixed without we're worrying about iframes.
EDIT: Never mind my reply above, still reading a documentation on createHTMLDocument.
EDIT 2: I guess the subtest code calls createHTMLDocument without appending the new HTML Document to an iframe? (So the new HTML Document doesn't visible (doesn't have a viewport) ).
Yeah, changing the assertion doesn't fix the subtest result:
emilio commentedon Mar 21, 2016
Yes, exactly,
createHTMLDocumentdoesn't create a new iframe, but it does append an<html>node and a<body>node, which are our two nodes.It seems that we should check if the document is in the viewport before doing hit test.
The spec: https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
emilio commentedon Mar 21, 2016
Note that the assertion should be changed regardless, that's not what that test is testing (no viewport != no document element).
jdm commentedon Mar 21, 2016
You probably want
document.browsing_context().is_some()instead.jdm commentedon Apr 5, 2016
Are you still working on this, @rilut?
luthfianto commentedon Apr 5, 2016
@jdm Yes, I'll get it done on Thursday after exam
jdm commentedon Apr 5, 2016
Ok, thanks! No rush, just wanted to make sure it wasn't abandoned.
luthfianto commentedon Apr 5, 2016
@jdm sure! Thanks for your consideration
Auto merge of #10426 - rilut:fix-elementsFromPoint-no-viewport-availa…