This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 21591 - String constant on NavigatorID is invalid per WebIDL
Summary: String constant on NavigatorID is invalid per WebIDL
Status: RESOLVED WONTFIX
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard: [v1]
Keywords:
Depends on:
Blocks: 22041
  Show dependency treegraph
 
Reported: 2013-04-05 12:13 UTC by contributor
Modified: 2013-07-09 20:28 UTC (History)
9 users (show)

See Also:


Attachments

Description contributor 2013-04-05 12:13:28 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html
Multipage: http://www.whatwg.org/C#client-identification
Complete: http://www.whatwg.org/c#client-identification

Comment:
String constant on NavigatorID is invalid per WebIDL

Posted from: 81.242.195.27 by ms2ger@gmail.com
User agent: Mozilla/5.0 (X11; Linux x86_64; rv:22.0) Gecko/20130301 Firefox/22.0
Comment 1 Ms2ger 2013-04-05 12:14:48 UTC
Either make it a simple readonly attribute or make Cameron allow it, I guess.
Comment 2 Ian 'Hixie' Hickson 2013-04-11 22:23:58 UTC
heycam, let's allow it! :-D

This relates to the last interesting line of this IDL block:

[NoInterfaceObject]
interface NavigatorID {
  readonly attribute DOMString appName;
  readonly attribute DOMString appVersion;
  readonly attribute DOMString platform;
  readonly attribute DOMString userAgent;

  const DOMString product = "Gecko"; // for historical reasons
};
Comment 3 Simon Pieters 2013-04-11 23:05:06 UTC
Constants appear on both the interface object and on the prototype. In this case, there's no interface object because of [NoInterfaceObject], but it still seems wrong conceptually to use a constant for .product.
Comment 4 Ian 'Hixie' Hickson 2013-04-12 06:49:20 UTC
If there was some WebIDL way of defining an attribute that always returned a single value but didn't appear on the prototype, that would be even better. I agree that the type of constant that appears on the interface isn't what I'm looking for here.
Comment 5 Brendan Eich 2013-04-12 07:16:05 UTC
  static const DOMString product = "Gecko"; // for historical reasons

?

/be
Comment 6 Cameron McCormack 2013-04-12 07:23:13 UTC
static attributes already exist, if you were happy to to do the 'Return "Gecko".` bit in prose.  Otherwise static const seems reasonable to me.  And probably preferable, since it would result in a data property rather than an accessor property.

I don't understand the objection to use a constant if the value is indeed constant, by the way.
Comment 7 Simon Pieters 2013-04-12 07:34:45 UTC
The attribute should only be on the prototype, not on the interface object. static does the opposite.

I think what is requested here is the equivalent of

[[
interface Foo {
 readonly attribute DOMString product;
};

The `product` attribute must return the string "Gecko".
]]

Since this is a legacy feature, I'm not convinced WebIDL should support dedicated syntax for it.
Comment 8 Ian 'Hixie' Hickson 2013-04-15 22:00:47 UTC
Yeah I'm just trying to avoid having prose for this legacy feature, the same way that people keep having me avoid prose where I can avoid it by using other features like defaults for optional arguments, enums, etc. :-)

heycam: If you don't want to support this, just reassign it to me and I'll use prose.
Comment 9 Anne 2013-07-04 08:23:02 UTC
I understand the desire to avoid writing prose, but I don't understand why we'd want string constants in IDL.
Comment 10 Ian 'Hixie' Hickson 2013-07-09 20:26:28 UTC
FYI, I don't need this for HTML anymore. I made it all prose.
Comment 11 Anne 2013-07-09 20:28:36 UTC
WONTFIX since nobody came up with a compelling use case.