Closed Bug 1527540 Opened 2 years ago Closed 1 year ago

[wpt-sync] Sync PR 15343 - domparsing: Fix an issue that XMLSerializer generates new prefix for an attribute with an existing namespace

Categories

(Core :: DOM: Core & HTML, enhancement, P4)

enhancement

Tracking

()

RESOLVED FIXED
mozilla67
Tracking Status
firefox67 --- fixed

People

(Reporter: mozilla.org, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 15343 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/15343
Details from upstream follow.

Kent Tamura <tkent@chromium.org> wrote:

domparsing: Fix an issue that XMLSerializer generates new prefix for an attribute with an existing namespace

Add an implementation of "retrieving a preferred prefix string"
[1], and apply it to attribute serialization.

The specification says we need to keep a map like [2]

namespace URI => [older prefix, ..., newer prefix]

in order to retrieve most-recently-declared prefix. However, our
current implementation is:

prefix => (namespace URI, declaration index)

When we search the map for a namespace URI, we chose a prefix with
the largest declaration index.

The failing test case in XMLSerializer-serializeToString.html follows
the specification, but Firefox, Safari, and Chrome without this CL
preserve prefix in such case. This CL keeps the interoperable behavior.

[1] https://w3c.github.io/DOM-Parsing/#dfn-retrieving-a-preferred-prefix-string
[2] https://w3c.github.io/DOM-Parsing/#dfn-namespace-prefix-map

Bug: 906807
Change-Id: Idaea590ba19c9c21acbaf456ea91ce550c74db5a

Reviewed-on: https://chromium-review.googlesource.com/1445033
WPT-Export-Revision: 84008f12fea1e42ce516b56368ef7de0966769e0

Component: web-platform-tests → DOM
Product: Testing → Core
Ran 1 tests and 9 subtests
OK     : 1
PASS   : 6
FAIL   : 3

New tests that have failures or other problems:
/domparsing/XMLSerializer-serializeToString.html
    Check if an attribute with namespace and no prefix is serialized with the nearest-declared prefix even if the prefix is assigned to another namespace.: FAIL
    Check if the prefix of an attribute is NOT preserved in a case where neither its prefix nor its namespace URI is not already used.: FAIL
    Check if the prefix of an attribute is replaced with a generated one in a case where the prefix is already mapped to a different namespace URI.: FAIL
Component: DOM → DOM: Core & HTML
Pushed by james@hoppipolla.co.uk:
https://hg.mozilla.org/integration/mozilla-inbound/rev/1a78f6d88afa
[wpt PR 15343] - domparsing: Fix an issue that XMLSerializer generates new prefix for an attribute with an existing namespace, a=testonly
Pushed by james@hoppipolla.co.uk:
https://hg.mozilla.org/integration/mozilla-inbound/rev/2e35ac1f3c21
[wpt PR 15343] - domparsing: Fix an issue that XMLSerializer generates new prefix for an attribute with an existing namespace, a=testonly
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
You need to log in before you can comment on or make changes to this bug.