<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>9888</bug_id>
          
          <creation_ts>2010-06-09 13:00:24 +0000</creation_ts>
          <short_desc>Constants are not accessible when they&apos;re needed for most IndexedDB interfaces.</short_desc>
          <delta_ts>2010-06-15 20:02:27 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>Indexed Database API</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jeremy Orlow">jorlow</reporter>
          <assigned_to name="Nikunj Mehta">nikunj.mehta</assigned_to>
          <cc>mike</cc>
    
    <cc>public-webapps</cc>
    
    <cc>sdwilsh</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>36063</commentid>
    <comment_count>0</comment_count>
    <who name="Jeremy Orlow">jorlow</who>
    <bug_when>2010-06-09 13:00:24 +0000</bug_when>
    <thetext>In indexedDB, there are many cases where it&apos;s impossible to access a constant.  For example, if I&apos;m trying to create a key range, I might want to pass in KeyRange.LEFT_OPEN.  Unfortunately, the only way to get at LEFT_OPEN is to create a KeyRange.  This is true of pretty much all the objects and their constants.

Another example is that you can&apos;t access the error constants without causing an exception so you can get an IDBDatabaseException object.  But that&apos;s not even possible outside of workers.

We could create global constructors, but it doesn&apos;t seem worth it to pollute the namespace.  We could pull all the constants up one level.  For example, the constants for Cursors would be added to IDBIndexes and IDBObjectstores since those are both the places where you&apos;d create a cursor.  If we wanted to avoid the duplication, we could even pull all the constants up to the IndexedDatabaseRequest level (where mozilla&apos;s proposal suggests we put the keyRange constructors).

Until this is fixed, people using IndexedDB will need to use pretty ugly hacks to get at the constants or hard code in the numbers themselves.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36184</commentid>
    <comment_count>1</comment_count>
    <who name="Nikunj Mehta">nikunj.mehta</who>
    <bug_when>2010-06-15 14:33:14 +0000</bug_when>
    <thetext>WebIDL provides the ExceptionConsts modifier that can tie constants to an exception. Would this kind of a solution work for IndexedDB constants? For example:

[ExceptionConsts=FileIOException]
module fileio {

  exception FileIOException {
    unsigned short code;
  };

  const unsigned short FILE_NOT_FOUND = 1;
  const unsigned short READ_ERROR = 2;
  const unsigned short WRITE_ERROR = 3;
};

ECMAScript

typeof FileIOException;          // evaluates to &quot;object&quot;
FileIOException.FILE_NOT_FOUND;  // evaluates to 1

Now I just need to find out whether ExceptionConsts can be used with non-exception consts.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36185</commentid>
    <comment_count>2</comment_count>
    <who name="Nikunj Mehta">nikunj.mehta</who>
    <bug_when>2010-06-15 14:39:14 +0000</bug_when>
    <thetext>Looks like all I need to do is add [NoInterfaceObject] to KeyRange to solve this problem. If we find a similar issue with any other interface, it could be solved that way.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36186</commentid>
    <comment_count>3</comment_count>
    <who name="Nikunj Mehta">nikunj.mehta</who>
    <bug_when>2010-06-15 14:58:44 +0000</bug_when>
    <thetext>Actually upon closer inspection, I realize why I had removed the NoInterfaceObject modifiers from the spec, more or less completely. Per WebIDL, you should be able to access any constant from the interfaces just as intuitively understood. If not, check your IDL compiler.

Once I get confirmation of this from the WebApps WG, I will close this issue as INVALID.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36188</commentid>
    <comment_count>4</comment_count>
    <who name="Jeremy Orlow">jorlow</who>
    <bug_when>2010-06-15 15:01:04 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; WebIDL provides the ExceptionConsts modifier that can tie constants to an
&gt; exception. Would this kind of a solution work for IndexedDB constants? For
&gt; example:
&gt; 
&gt; [ExceptionConsts=FileIOException]
&gt; module fileio {
&gt; 
&gt;   exception FileIOException {
&gt;     unsigned short code;
&gt;   };
&gt; 
&gt;   const unsigned short FILE_NOT_FOUND = 1;
&gt;   const unsigned short READ_ERROR = 2;
&gt;   const unsigned short WRITE_ERROR = 3;
&gt; };
&gt; 
&gt; ECMAScript
&gt; 
&gt; typeof FileIOException;          // evaluates to &quot;object&quot;
&gt; FileIOException.FILE_NOT_FOUND;  // evaluates to 1
&gt; 
&gt; Now I just need to find out whether ExceptionConsts can be used with
&gt; non-exception consts.

It looks like this has been dropped in the latest editors draft: http://dev.w3.org/2006/webapi/WebIDL/#changes

From a quick read, it seems as though implementing exceptions correctly in the spec should at least partially fix the problem though...and that the norm is to have an exception class that&apos;s closely tied to an error class which holds the constants.  So I think you&apos;re on the right track, but it seems as though &quot;ExceptionConsts&quot; itself is not the right direction.

I&apos;d also note that, since IDBDatabaseError/Exception is not in the global namespace (right?) this wouldn&apos;t solve this bug...but implementing exceptions correctly (in terms of WebIDL) is (or should be) in some other bug.


(In reply to comment #2)
&gt; Looks like all I need to do is add [NoInterfaceObject] to KeyRange to solve
&gt; this problem. If we find a similar issue with any other interface, it could be
&gt; solved that way.

I&apos;m looking at http://dev.w3.org/2006/webapi/WebIDL/#NoInterfaceObject but can&apos;t see how this solves the problem.  Can you please explain further?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36190</commentid>
    <comment_count>5</comment_count>
    <who name="Jeremy Orlow">jorlow</who>
    <bug_when>2010-06-15 15:02:13 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; Actually upon closer inspection, I realize why I had removed the
&gt; NoInterfaceObject modifiers from the spec, more or less completely. Per WebIDL,
&gt; you should be able to access any constant from the interfaces just as
&gt; intuitively understood. If not, check your IDL compiler.
&gt; 
&gt; Once I get confirmation of this from the WebApps WG, I will close this issue as
&gt; INVALID.

I.e. they should all be in the global namespace?  Hm...typically we avoid stuff like this, but since everything has a IDB prefix maybe that&apos;s OK...?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36198</commentid>
    <comment_count>6</comment_count>
    <who name="Nikunj Mehta">nikunj.mehta</who>
    <bug_when>2010-06-15 20:00:43 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; (In reply to comment #3)
&gt; &gt; Actually upon closer inspection, I realize why I had removed the
&gt; &gt; NoInterfaceObject modifiers from the spec, more or less completely. Per WebIDL,
&gt; &gt; you should be able to access any constant from the interfaces just as
&gt; &gt; intuitively understood. If not, check your IDL compiler.
&gt; &gt; 
&gt; &gt; Once I get confirmation of this from the WebApps WG, I will close this issue as
&gt; &gt; INVALID.
&gt; 
&gt; I.e. they should all be in the global namespace?  Hm...typically we avoid stuff
&gt; like this, but since everything has a IDB prefix maybe that&apos;s OK...?

There will be a few interfaces in global scope for each of the interfaces with constants. That is how every spec seems to work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36201</commentid>
    <comment_count>7</comment_count>
    <who name="Nikunj Mehta">nikunj.mehta</who>
    <bug_when>2010-06-15 20:02:27 +0000</bug_when>
    <thetext>The spec already does what the bug asks for. Check WebIDL for more help with
access constants defined in interfaces.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>