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

Changing WebDriver test_parent_htmldocument to expect error #10058

Merged
merged 2 commits into from Mar 16, 2018

Conversation

Projects
None yet
5 participants
@jimevans
Copy link
Contributor

jimevans commented Mar 15, 2018

When the context element is document.documentElement, and an attempt is
made to find elements from that context element using an XPath of .., a
snapshot is returned containing the document object. While this is
apparently the correct behavior for XPath, the WebDriver spec says that if
the object in the snapshot is not an element, we should return an error
with error code "invalid selector." The test_parent_htmldocument test in
both find_element_from_element.py and find_elements_from_element.py expect
a success in this case. This commit changes the tests to correctly expect
an error from the driver.

Changing WebDriver test_parent_htmldocument to expect error
When the context element is `document.documentElement`, and an attempt is
made to find elements from that context element using an XPath of `..`, a
snapshot is returned containing the `document` object. While this is
apparently the correct behavior for XPath, the WebDriver spec says that if
the object in the snapshot is not an element, we should return an error
with error code "invalid selector." The test_parent_htmldocument test in
both find_element_from_element.py and find_elements_from_element.py expect
a success in this case. This commit changes the tests to correctly expect
an error from the driver.
@w3c-bots

This comment has been minimized.

Copy link

w3c-bots commented Mar 15, 2018

Build PASSED

Started: 2018-03-16 14:16:19
Finished: 2018-03-16 14:22:02

View more information about this build on:

@andreastt
Copy link
Member

andreastt left a comment

You are correct that the XPath selector .. on the <html> element (the document element) should return an invalid selector error. This is consistent with the behaviour described in https://bugzilla.mozilla.org/show_bug.cgi?id=1424635#c0.

That said, I don’t think this is the correct patch for the issue. test_parent_htmldocument tests that it is possible to retrieve a parent HTMLDocument node that is Node.DOCUMENT_NODE. We have to test this specifically because the nodeType differs from other regular elements, and this matters in implementations such as Gecko.

I think we should fix this test to use <body> as the from_element, then write a new test for getting the relative ancestor of <html> and returning an invalid selector error.

Does that make sense?

@andreastt

This comment has been minimized.

Copy link
Member

andreastt commented Mar 16, 2018

See also https://hg.mozilla.org/mozilla-central/rev/3870805aea81 for the background for why we have this test.

@gsnedders

This comment has been minimized.

Copy link
Contributor

gsnedders commented Mar 16, 2018

see also #10055 for a related DOM XPath test (given ".." on the root element in nonsense and cannot match anything per actual XPath)

Changing test_parent_htmldocument to use <body> tag
This reverts the change for expecting an error, and adds a test that
attempting to locate the parent of the document element yields an error.

@andreastt andreastt merged commit 89ba944 into web-platform-tests:master Mar 16, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jimevans jimevans deleted the jimevans:parent-document branch Apr 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.