New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 609415 link

Starred by 4 users

Issue metadata

Status: WontFix
Owner:
Closed: Oct 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

Error messages from parentNode.querySelector() do not follow specification

Reported by dbu...@mozilla.com, May 5 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0

Example URL:
https://dom.spec.whatwg.org/#scope-match-a-selectors-string

Steps to reproduce the problem:
1. Go to any page
2. run JS to do document.querySelector("")
3. Catch DOMException error

What is the expected behavior?
It should throw a Synxtax error as described in the DOM spec

What went wrong?
wrong error message

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? No 

Does this work in other browsers? Yes 

Chrome version: Version 50.0.2661.94 (64-bit)  Channel: n/a
OS Version: OS X 10.11
Flash Version:
 
Components: -Blink Blink>CSS

Comment 2 by shans@chromium.org, May 8 2016

Labels: Needs-Bisect
Status: Untriaged (was: Unconfirmed)
Cc: nyerramilli@chromium.org
Labels: -Needs-Bisect Needs-triage M-52 OS-Linux OS-Windows
Thanks for the report.

Bisect info:
CHANGELOG URL:
  https://chromium.googlesource.com/chromium/src/+log/2f32cebd5614a37e715a1350e14376238f418a93..5380cdb69bd13a765979df2a49630d373370249f

Blink CL:
https://build.chromium.org/f/chromium/perf/dashboard/ui/changelog_blink.html?url=/trunk&range=178454:178494&mode=html

unable to find the suspect, requesting dev team to check the issue.

Note: Issue broken in M38
Good Build: 38.0.2098.0
Bad Build: 38.0.2099.0

Able to reproduce the issue on Win7, Mac OSX 10.11.4, Ubuntu 14.04 using Chrome Stable 50.0.2661.94, Dev 52.0.2723.2 and Canary 52.0.2728.0

Comment 4 by suzyh@chromium.org, May 9 2016

Status: Available (was: Untriaged)
I think this may be a Firefox vs. Blink expectation mismatch.
document.querySelector(""); gives:
Uncaught DOMException: The provider selector is empty.

However the exception name is correct:
try { document.querySelector(""); } catch(ex) { ex.name; } gives:
"SyntaxError".

This may be a bit confusing compared to what my FF nightly does:
document.querySelector("");
SyntaxError: An invalid or illegal string was specified

So I think the bug report is invalid.
Project Member

Comment 7 by sheriffbot@chromium.org, Jun 1 2016

Labels: -M-52 M-53 MovedFrom-52
Moving this nonessential bug to the next milestone.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: -Needs-triage
Project Member

Comment 9 by sheriffbot@chromium.org, Jul 11 2016

Labels: -M-53 MovedFrom-53
This issue has been moved once and is lower than Pri-1. Removing the milestone.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: Hotlist-Interop
Labels: Hotlist-GoodFirstBug
Labelling it as GoodFirstBug as per comment #5. Feel free to reach out to ramya (who wrote the comment) or myself for help

Comment 12 by ratsu...@gmail.com, Aug 19 2016

I've dive into this bug and have some interesting facts to share

try { document.querySelector(""); } catch(ex) { console.log(ex.name, ex instanceof DOMException, ex instanceof SyntaxError); }

You can run this test code in Chrome and Firefox, both of them returns "SyntaxError true false"

So actually both Chrome and Firefox throws the correct Exception, and the 'SyntaxError' is only the name of the Exception (see https://heycam.github.io/webidl/#syntaxerror) 

The only thing different is the way that console show the exception. Firefox doesn't show the exception's classname 'DOMException', only show the name of exception. But the Chrome show the classname and hide the 'true' name of the DOMException.

I've made a patch which changes https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/ContainerNode.cpp?sq=package:chromium&type=cs&rcl=1471447605&l=1119 to `exceptionState.throwSyntaxError`, after that it now can throw a 'true' SyntaxError, but I don't think it meet the web standards.

@ramya, @nainar, what's your opinion?
Thanks.

Comment 13 by ratsu...@gmail.com, Aug 19 2016

I cannot decide whether made chrome console behaviour same as the firefox console is a good idea. Because the firefox style may misleading user to catch the wrong SyntaxError but not the correct DOMException.

Maybe show both DOMException and SyntaxError, like 'Uncaught DOMException: SyntaxError, Failed to execute 'querySelector' on 'Document': The provided selector is empty.' is a good idea?

Comment 14 by ratsu...@gmail.com, Sep 12 2016

Firendly Ping
Cc: ramy...@samsung.com rbyers@chromium.org
Hi ratsunny@

First of all my sincere apologies for not replying to this in time. Neither ramya@ nor myself were cced on this bug and didn't see these comments. I am ccing them now.

Also since this involves standards stuff I am ccing rbyers who may be able to guide you here. 
Cc: nainar@chromium.org
Labels: Update-Quarterly
Components: -Blink>CSS Blink>DOM

Comment 19 by kochi@chromium.org, Oct 11 2017

Cc: kochi@chromium.org
Owner: rakina@chromium.org
Status: Assigned (was: Available)
Rakina, could you take a look at this?

Comment 20 by kochi@chromium.org, Oct 11 2017

Status: WontFix (was: Assigned)
With conversation with Rakina, we found that Chrome, Firefox, Safari (not
tested Edge yet) all returns "SyntaxError true false" for the test case
given in comment#12.

The current WHATWG DOM says:
https://dom.spec.whatwg.org/#selectors
> If s is failure, then throw a SyntaxError.
and "SyntaxError" links to:
https://heycam.github.io/webidl/#syntaxerror
which is DOMException, whose name is "SyntaxError".

According to "2.5 Exceptions" in WebIDL,
https://heycam.github.io/webidl/#idl-exceptions
There are 2 kinds of exceptions : simple exception and DOMException,
where the former (simple exception) coming from ECMAScript error objects
https://tc39.github.io/ecma262/#sec-error-objects
and there is `SyntaxError` as well.

WebIDL also says about simple exception as:
> apart from SyntaxError and Error, which are deliberately omitted as
> they are reserved for use by the ECMAScript parser and by authors,
> respectively

So from these, what querySelector() should throw is DOMException whose
name is "SyntaxError", not `SyntaxError` which is a simple exception
derived from ECMAScript.

With that said, I think all tested browsers conform to the DOM spec
and no action should be taken.

In web platform tests, it is already covered by runInvalidSelectorTest in
https://github.com/w3c/web-platform-tests/blob/ea0dc05a90b23e4c3d82a210eb234b539826430d/dom/nodes/ParentNode-querySelector-All.js#L212

So in conclusion the original report is coming from confusion between
simple exception SyntaxError and DOMException "SyntaxError", and we don't
need any further work here.

I think we can close this as WontFix.

Comment 21 by kochi@chromium.org, Oct 13 2017

For the record,
Now WebIDL and DOM spec were updated not to get confused with two SyntaxErrors:
https://github.com/heycam/webidl/pull/459
https://github.com/whatwg/dom/pull/518

Sign in to add a comment