Error messages from parentNode.querySelector() do not follow specification
Reported by
dbu...@mozilla.com,
May 5 2016
|
|||||||||||||||
Issue descriptionUserAgent: 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:
,
May 8 2016
,
May 9 2016
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
,
May 9 2016
,
May 10 2016
It is throwing SyntaxError error only as per below code. https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/core/dom/ContainerNode.cpp&q=:querySelector&sq=package:chromium&type=cs&l=1080
,
May 25 2016
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.
,
Jun 1 2016
Moving this nonessential bug to the next milestone. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jun 20 2016
,
Jul 11 2016
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
,
Aug 10 2016
,
Aug 18 2016
Labelling it as GoodFirstBug as per comment #5. Feel free to reach out to ramya (who wrote the comment) or myself for help
,
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.
,
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?
,
Sep 12 2016
Firendly Ping
,
Nov 1 2016
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.
,
Nov 1 2016
,
Feb 13 2017
,
Oct 2 2017
,
Oct 11 2017
Rakina, could you take a look at this?
,
Oct 11 2017
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.
,
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 |
|||||||||||||||
Comment 1 by cbiesin...@chromium.org
, May 5 2016