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

Issue 601493 link

Starred by 3 users

Issue metadata

Status: WontFix
Owner:
Last visit > 30 days ago
Closed: Jul 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Feature



Sign in to add a comment

svg parser errors are not reported as JavaScript exceptions

Project Member Reported by johnjbarton@google.com, Apr 7 2016

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36

Steps to reproduce the problem:
<script>
(function () {
  try {
    var svgns = "http://www.w3.org/2000/svg";
    var shape = document.createElementNS(svgns, "circle");
    shape.setAttributeNS(null, "r",  "foo");
    console.log('No exception was thrown');
  } catch(ex) {
    console.error(ex.stack || ex);
  }
})();
</script>

What is the expected behavior?
An exception logged in the console.

What went wrong?
No exception was thrown. This means all kinds of JS tools cannot know that the svg parse failed.  In particular,
unit tests can pass even though the parse failed. 

Did this work before? No 

Chrome version: 49.0.2623.110  Channel: stable
OS Version: 
Flash Version: Shockwave Flash 21.0 r0

This is probably a design bug in the interface between svg and chrome but I put it under Developer Tools because we are the ones who will care about this problem.
 

Comment 1 by f...@opera.com, Apr 8 2016

This is rather a DOM spec thing: https://dom.spec.whatwg.org/#dom-element-setattributens

And as can be seen there, it doesn't really care about the value. There's also nothing requiring that the "value" (string) => "something useful for the engine" should happen synchronously when setAttribute{,NS} is called.

We do drop a note in the console though:

 'Error: <circle> attribute r: Expected length, "foo".'

I'd be happy to try and improve that some more.

On a side-note, if setAttribute were to throw for each value it didn't recognize, the platform would likely be in trouble.
Thank you for your reply!

To be clear, my report is not about the attribute parsing but rather it is
about the "drop a note in the console"  approach.

Developers focus a lot of attention on the browser console. It is their
primary UI to develop web pages. As we are trying to use the Web to create
useful content, we request that the browser also try to be useful in its
output to the console for developers.

Sending "Error" to the console as a logging message is not useful.  We
don't have any mechanism for routing such messages.  We can't log them when
users find them; we can't check for them in unit tests; we can't prevent
them when we know the errors are harmless. There is an established and
effective solution for errors: throw JS exceptions or route the errors
through window.onerror.

Thanks.

Comment 3 by f...@opera.com, Apr 8 2016

Regardless of mechanism this sounds like something that would be "Web exposed", so should probably be ventilated outside the Chromium project first before going anywhere. Maybe https://github.com/DeveloperToolsWG/console-object is a good starting point for discussions?

Comment 5 by alph@chromium.org, Apr 11 2016

Labels: -OS-Linux -Type-Bug -Pri-2 OS-All Pri-3 Type-Feature
Owner: kozyatinskiy@chromium.org
Status: Assigned (was: Unconfirmed)
Project Member

Comment 6 by sheriffbot@chromium.org, Jun 3 2016

Labels: Hotlist-Google
Status: WontFix (was: Assigned)
Since it's a spec issue, I'll close it here.
Feel free to open it again when spec will be ready.

Sign in to add a comment