<?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>27712</bug_id>
          
          <creation_ts>2014-12-28 19:58:12 +0000</creation_ts>
          <short_desc>IndexedDB: Array comparison algorithm doesn&apos;t handle empty arrays</short_desc>
          <delta_ts>2015-01-13 23:47: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>Windows NT</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>n210241048576</reporter>
          <assigned_to name="Joshua Bell">jsbell</assigned_to>
          <cc>jsbell</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
    
    <cc>r.t.h1.0.9.0.h</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>116702</commentid>
    <comment_count>0</comment_count>
    <who name="">n210241048576</who>
    <bug_when>2014-12-28 19:58:12 +0000</bug_when>
    <thetext>The array comparison algorithm says to compare the first element of the arrays before checking the length, which means that it doesn&apos;t work for empty arrays, despite empty arrays being valid keys.


Let A be the first Array value and B be the second Array value.
Let length be the lesser of A&apos;s length and B&apos;s length.
Let i be 0.
If the ith value of A is less than the ith value of B, then A is less than B. Skip the remaining steps.
If the ith value of A is greater than the ith value of B, then A is greater than B. Skip the remaining steps.
Increase i by 1.
If i is not equal to length, go back to step 4. Otherwise continue to next step.
If A&apos;s length is less than B&apos;s length, then A is less than B. If A&apos;s length is greater than B&apos;s length, then A is greater than B. Otherwise A and B are equal.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116894</commentid>
    <comment_count>1</comment_count>
    <who name="Joshua Bell">jsbell</who>
    <bug_when>2015-01-07 18:52:06 +0000</bug_when>
    <thetext>Simplest fix: insert new step 3 and update 4-&gt;5

1. Let A be the first Array value and B be the second Array value.
2. Let length be the lesser of A&apos;s length and B&apos;s length.
3. If length is 0, go to step 9.
4. Let i be 0.
5. If the ith value of A is less than the ith value of B, then A is less than B. Skip the remaining steps.
6. If the ith value of A is greater than the ith value of B, then A is greater than B. Skip the remaining steps.
7. Increase i by 1.
8. If i is not equal to length, go back to step 5. Otherwise continue to next step.
9. If A&apos;s length is less than B&apos;s length, then A is less than B. If A&apos;s length is greater than B&apos;s length, then A is greater than B. Otherwise A and B are equal.

Alternately:

1. Let A be the first Array value and B be the second Array value.
2. Let length be the lesser of A&apos;s length and B&apos;s length.
3. Let i be 0.
4. If i is equal to length, go to step 9. Otherwise continue to next step.
5. If the ith value of A is less than the ith value of B, then A is less than B. Skip the remaining steps.
6. If the ith value of A is greater than the ith value of B, then A is greater than B. Skip the remaining steps.
7. Increase i by 1.
8. Go back to step 4.
9. If A&apos;s length is less than B&apos;s length, then A is less than B. If A&apos;s length is greater than B&apos;s length, then A is greater than B. Otherwise A and B are equal.

Or using a &apos;while&apos; loop:

1. Let A be the first Array value and B be the second Array value.
2. Let length be the lesser of A&apos;s length and B&apos;s length.
3. Let i be 0.
4. While i is less than length:
  1. If the ith value of A is less than the ith value of B, then A is less than B. Skip the remaining steps.
  2. If the ith value of A is greater than the ith value of B, then A is greater than B. Skip the remaining steps.
  3. Increase i by 1.
5. If A&apos;s length is less than B&apos;s length, then A is less than B. If A&apos;s length is greater than B&apos;s length, then A is greater than B. Otherwise A and B are equal.

I can fix in the ED if someone wants to select and sanity-check one of the above.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117118</commentid>
    <comment_count>2</comment_count>
    <who name="Joshua Bell">jsbell</who>
    <bug_when>2015-01-13 23:47:03 +0000</bug_when>
    <thetext>Addressed in https://github.com/w3c/IndexedDB/commit/377b979783857cc6b37b769119cafe5c9af58228</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>