Closed Bug 1678610 Opened 5 years ago Closed 5 years ago

"WebDriver:FindElement" cannot find anchors for data URLs whose href attribute contain a hash (not encoded)

Categories

(Remote Protocol :: Marionette, defect, P3)

Default
defect

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: whimboo, Unassigned)

Details

(Keywords: hang)

The following Marionette test hangs in WebDriver:FindElement because of the hash in the href attribute:

    def test_hang_find_element(self):
        self.marionette.navigate(inline("""<a href="#">click me</a>"""))
        link = self.marionette.find_element(By.TAG_NAME, "a")

When the hash gets removed it works all fine.

There is actually no hang. By accident I had the implicit timeout set to a high value, and as such the command never returned.

The underlying reason here is that the anchor never gets added to the DOM when the href attribute contains the hash. It can be verified by using the following data URL:

data:text/html;charset=utf-8,<a href=\"#\">click me</a>"

Olli, is that a bug in Firefox or somewhat expected due to the usage of the data URL?

Flags: needinfo?(bugs)

The part after # is fragment identifier.
See what location.hash looks like in that document.

You may need to use an entity for #. (# or # or some such)

Flags: needinfo?(bugs)

The severity field is not set for this bug.
:whimboo, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(hskupin)

(In reply to Olli Pettay [:smaug] from comment #2)

The part after # is fragment identifier.
See what location.hash looks like in that document.

There is no difference. With the hash sign included the click me anchor text is even not displayed. Just open the this URL in Firefox:

data:text/html;charset=utf-8,<a href="#foo">click me</a>

Once you remove the has and leave foo, the anchor text is displayed.

Severity: -- → S3
Flags: needinfo?(hskupin) → needinfo?(bugs)

Everything after # in the data url is part of the fragment identifier.
perhaps
data:text/html;charset=utf-8,<a href="%23foo">click me</a>

Flags: needinfo?(bugs)

Ok, so correctly encoding the data URL fixes the Marionette testcase for me. There is actually also no hang. It only happened because I had an implicit wait set by accident.

When using the not encoded URL, the a tag isn't closed correctly, and as such Firefox also doesn't add it to the DOM. So the behavior of Marionette is correct here. Closing as invalid.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID
Summary: "WebDriver:FindElement" hangs for anchors with href attribute containing a hash → "WebDriver:FindElement" cannot find anchors for data URLs whose href attribute contain a hash (not encoded)
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.