Bug 205923 - document.querySelector doesn't work for xml documents
Summary: document.querySelector doesn't work for xml documents
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-01-08 06:03 PST by Carlos Garcia Campos
Modified: 2023-12-29 03:38 PST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2020-01-08 06:03:39 PST
This is causing the WebDriver test imported/w3c/webdriver/tests/is_element_enabled/enabled.py::test_xml_always_not_enabled to fail, but because we fail to find the node first.

>       element = session.find.css("note", all=False)
E           NoSuchElementException: no such element (404):

body       = {'using': 'css selector', 'value': 'note'}
err        = <NoSuchElementException http_status=404>
method     = 'POST'
response   = <Response status=404 error=<NoSuchElementException http_status=404>>
self       = <Session 2d4c898d-9ba1-40e7-867c-3c99b339dcdb>
url        = 'session/2d4c898d-9ba1-40e7-867c-3c99b339dcdb/element'

This is because document.querySelector('note') is returning null.

The document is just:

<?xml version="1.0" encoding="utf-8"?>
<note></note>

Saving that to a file and opening it in both ff and chrome, I can get the valid node by calling document.querySelector('note') from the inspector console.
Comment 1 Radar WebKit Bug Importer 2020-01-08 10:46:30 PST
<rdar://problem/58413567>
Comment 2 Anne van Kesteren 2023-12-29 03:38:11 PST
This appears to work fine:

data:text/xml,<note><script%20xmlns="http://www.w3.org/1999/xhtml">alert(document.querySelector("note"))</script></note>