<?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>26492</bug_id>
          
          <creation_ts>2014-07-31 23:45:19 +0000</creation_ts>
          <short_desc>IndexedDB: add/put/update operations should define ordering of clone vs. keypath evaluation</short_desc>
          <delta_ts>2015-05-19 22:15:03 +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>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</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="Joshua Bell">jsbell</reporter>
          <assigned_to name="This bug has no owner yet - up for the taking">dave.null</assigned_to>
          <cc>jonas</cc>
    
    <cc>me</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>109726</commentid>
    <comment_count>0</comment_count>
    <who name="Joshua Bell">jsbell</who>
    <bug_when>2014-07-31 23:45:19 +0000</bug_when>
    <thetext>We recently fixed a bug in Chromium, but it looks like it affects Firefox as well and is implicit in the web-platform-tests suite (key_invalid.htm)

var store = db.createObjectStore(&apos;store&apos;, {keyPath: &apos;keypath&apos;});
var values = [&apos;string1&apos;, &apos;string2&apos;];
var obj = { get keypath() { return values.shift(); } };

store.put(obj);
store.openCursor().onsuccess = function(e) {
  console.log(&apos;key is: &apos; + e.target.result.key);
  console.log(&apos;value has: &apos; + JSON.stringify(e.target.result.value.keypath));
};

In FF33 the key is &apos;string1&apos; and the value has &apos;string2&apos;. Having these out of sync seems like a violation of the intent of the spec, although the letter of the spec does imply tests before cloning.

In Chromium (circa 38) we clone, then evaluate the keypaths, so the result is &apos;string1&apos; / &apos;string1&apos;. 

This manifests in the key_invalid.htm test since it provides invalid key values such as function(){}. In Chromium we return DataCloneError since we clone before evaluating, whereas the test looks for DataError since it assumes evaluation before cloning.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109727</commentid>
    <comment_count>1</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2014-08-01 00:26:25 +0000</bug_when>
    <thetext>I agree that the spec should call for first cloning, then evaluating the keypath on the clone.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109782</commentid>
    <comment_count>2</comment_count>
    <who name="Kyle Huey">me</who>
    <bug_when>2014-08-02 03:21:19 +0000</bug_when>
    <thetext>Yeah we discussed this at Mozilla a year or two ago and came to a similar conclusion.  Fixing it hasn&apos;t been a priority for us yet though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120374</commentid>
    <comment_count>3</comment_count>
    <who name="Joshua Bell">jsbell</who>
    <bug_when>2015-05-19 22:15:03 +0000</bug_when>
    <thetext>This has been &quot;fixed&quot; in the V2 spec, although it may not match reality exactly.

https://w3c.github.io/IndexedDB/</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>