Bug 30993

Summary: Node.lookupNamespaceURI doesn't convert empty strings to null
Product: WebKit Reporter: nanto_vi (TOYAMA Nao) <nanto>
Component: DOMAssignee: Rob Buis <rwlbuis>
Status: RESOLVED FIXED    
Severity: Normal CC: annevk, ap, buildbot, bzbarsky, cdumez, commit-queue, esprehn+autocc, joepeck, kangil.han, mjs, rbuis, rniwa, rwlbuis, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from webkit-ews-07 for mac-mountainlion
none
Patch joepeck: review-

Description nanto_vi (TOYAMA Nao) 2009-11-01 05:59:22 PST
Although DOM3 Core says nothing about how to treat Node.lookupNamespaceURI(''), Mozilla treats empty strings in the same way as null.  Accepting empty strings as null also improves the compatibility with Opera, which only accepts empty strings.

To reproduce, execute the following JavaScript code:
var doc = new DOMParser().parseFromString('<root xmlns="http://example.org/"/>', 'application/xml');
alert(doc.lookupNamespaceURI(''));

Expected: http://example.org/
Actual: null

Confirmed on WebKit-r50095
Comment 1 Alexey Proskuryakov 2009-11-01 13:38:48 PST
Yeah, <http://lists.w3.org/Archives/Public/public-webapps/2008JulSep/0126.html>. If Gecko isn't going to make this behavior strictly compatible with the letter of DOM 3 Core, we should probably bite the bullet and implement their quirk.
Comment 2 Boris Zbarsky 2009-11-01 14:45:16 PST
You might be interested in https://bugzilla.mozilla.org/show_bug.cgi?id=312019

I'm also pretty sure the Gecko behavior for "" here is unintentional, for what it's worth.
Comment 3 Rob Buis 2013-07-04 18:39:24 PDT
Created attachment 206117 [details]
Patch
Comment 4 Build Bot 2013-07-04 19:46:10 PDT
Comment on attachment 206117 [details]
Patch

Attachment 206117 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/991244

New failing tests:
svg/batik/text/smallFonts.svg
Comment 5 Build Bot 2013-07-04 19:46:11 PDT
Created attachment 206120 [details]
Archive of layout-test-results from webkit-ews-07 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-07  Port: mac-mountainlion  Platform: Mac OS X 10.8.3
Comment 6 Rob Buis 2013-07-05 07:54:27 PDT
Created attachment 206152 [details]
Patch
Comment 7 Sam Weinig 2013-07-05 21:19:14 PDT
Comment on attachment 206152 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=206152&action=review

> Source/WebCore/dom/Node.cpp:1446
>      // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algorithms.html#lookupNamespaceURIAlgo

If we not longer plan on following DOM Level 3 here, we should update the comment.
Comment 8 Sam Weinig 2013-07-05 21:21:19 PDT
What's with the two failing tests? Is DOM4 in conflict with DOM3? Is that an intentional diversion?
Comment 9 Anne van Kesteren 2013-07-06 07:24:22 PDT
I don't recall the specifics. I guess I wrote down what Gecko implemented assuming the rule about null and the empty string in DOM Level 3 was also meant for prefixes and not just namespaces.
Comment 10 Sam Weinig 2013-07-06 12:08:57 PDT
(In reply to comment #9)
> I don't recall the specifics. I guess I wrote down what Gecko implemented assuming the rule about null and the empty string in DOM Level 3 was also meant for prefixes and not just namespaces.

The test suite differs I guess.   Not sure how I feel here.
Comment 11 Joseph Pecoraro 2015-11-12 15:13:31 PST
Comment on attachment 206152 [details]
Patch

Sorry, this patch has grown stale.

I'm going to r- because, this should add a new test for the new expected behavior instead of just depending on the xhtml/level3 test failures. Perhaps this is now covered by `LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Node-lookupNamespaceURI.html` and all we need to do is rebase the patch and re-run all tests.
Comment 12 Rob Buis 2018-11-07 11:29:26 PST
Closing, this was fixed by:
http://trac.webkit.org/changeset/204536
Comment 13 Radar WebKit Bug Importer 2018-11-07 11:30:54 PST
<rdar://problem/45883375>
Comment 14 Lucas Forschler 2019-02-06 09:04:08 PST
Mass moving XML DOM bugs to the "DOM" Component.