Closed Bug 1881443 Opened 9 months ago Closed 9 months ago

Idref links in devtools do not respect web component boundaries

Categories

(DevTools :: Inspector, defect)

Firefox 122
defect

Tracking

(firefox125 verified, firefox126 verified)

VERIFIED FIXED
125 Branch
Tracking Status
firefox125 --- verified
firefox126 --- verified

People

(Reporter: kilian, Assigned: nchevobbe)

Details

Attachments

(2 files)

Attached image Selection_2328.png

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0

Steps to reproduce:

Using the following codepen: https://codepen.io/matuzo/pen/yLwYNYY?editors=1010

  1. Open the devtools
  2. Inspect the button inside the <some-bugs>
  3. Click the locator/ "Select element #h1" button in the inspector tree view

Actual results:

You jump to the element with id #h1 outside of the <some-bugs> webcomponent.

This is incorrect because aria-labelledby can not cross a webcomponent boundary, so the "h1" needs to exist inside the webcomponent to be able to be referenced.

Expected results:

The linked element can not be found in the same root, so the button to select it should work similarly to when a completely non-existant ID is referenced.

The Bugbug bot thinks this bug should belong to the 'DevTools::Inspector' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Inspector
Product: Firefox → DevTools

Hello Kilian, thanks for the report!
I can indeed reproduce easily.
The click on the button is handled in https://searchfox.org/mozilla-central/rev/a8cc31504a2379bcf8ba395d2da7bb632b5521d6/devtools/client/inspector/markup/markup.js#1219-1234

// Select the node in the same document.
nodeFront.walkerFront
  .document(nodeFront)
  .then(doc => {
    return nodeFront.walkerFront
      .querySelector(doc, "#" + CSS.escape(link))
      .then(node => {
        if (!node) {
          this.emit("idref-attribute-link-failed");
          return;
        }
        this.inspector.selection.setNodeFront(node, {
          reason: "markup-attribute-link",
        });
      });
  })

and we're simply querying the document. We should have additional logic for web component

Status: UNCONFIRMED → NEW
Ever confirmed: true

(I checked the accessibility panel and it does indicate that the button is not labelled , so we're good there)

In order to select elements referenced in idref/idreflist attributes,
we were querying the whole node document.
This is incorrect as id reference are scipes within a shadow root.
To fix this, we add a dedicated walker method to retrieve the referenced
node within the base node rootNode.
A test case is added to ensure we don't regress.

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a99aa592b4a7 [devtools] Lookup node from idref attribute within node rootNode. r=devtools-reviewers,devtools-backward-compat-reviewers,ochameau,bomsy.
Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 125 Branch
QA Whiteboard: [qa-125b-p2]

Reproducible on a 2024-02-22 Nightly build on macOS 12.
Verified as fixed on Firefox Nightly 126.0a1 and Firefox 125.0 on macOS 12, Windows 10, Ubuntu 22.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-125b-p2]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: