Fix error handling bugs: 17609, 17236, 17643, 17650
authorJonas Sicking <jonas@sicking.cc>
Sun, 15 Jul 2012 02:19:57 -0700
changeset 358aab14b0951ca
parent 357 2fa535e8d3dd
child 359 63c710c23079
Fix error handling bugs: 17609, 17236, 17643, 17650
Overview.html
Speclet_021_IDB_API_Algorithms.html
Speclet_022_IDB_API_Synchronous_APIs.html
Speclet_023_IDB_API_Asynchronous_APIs.html
     1.1 --- a/Overview.html	Thu Jul 12 15:10:48 2012 -0700
     1.2 +++ b/Overview.html	Sun Jul 15 02:19:57 2012 -0700
     1.3 @@ -1245,7 +1245,7 @@
     1.4              <dfn>Options object</dfn>s are dictionary objects [[!WEBIDL]] 
     1.5              which are used to supply optional parameters to some indexedDB functions like 
     1.6              <a href="#widl-IDBDatabase-createObjectStore-IDBObjectStore-DOMString-name-IDBObjectStoreParameters-optionalParameters">createObjectStore</a> and
     1.7 -            <a href="#widl-IDBObjectStore-createIndex-IDBIndex-DOMString-name-DOMString-keyPath-IDBIndexParameters-optionalParameters">createIndex</a>. The attributes on the object
     1.8 +            <a href="#widl-IDBObjectStore-createIndex-IDBIndex-DOMString-name-any-keyPath-IDBIndexParameters-optionalParameters">createIndex</a>. The attributes on the object
     1.9              correspond to optional parameters on the function called.
    1.10            </p>
    1.11            <div class="block">
    1.12 @@ -2215,8 +2215,8 @@
    1.13                  If <var>keyPath</var> is an <code>Array</code> and any items in the array is not a <a>valid key path</a>,
    1.14                  or if <var>keyPath</var> is a string and is not a <a>valid key path</a> then a <code>DOMException</code>
    1.15                  of type <a>SyntaxError</a> MUST be thrown. If <var>keyPath</var> is
    1.16 -                and <code>Array</code> and the <var>multiEntry</var> property in the <var>optionalParameters</var> is true,
    1.17 -                then a <code>DOMException</code> of type <a>NotSupportedError</a> MUST be thrown. Otherwise set the created <a>object store</a>'s
    1.18 +                an <code>Array</code> and the <var>multiEntry</var> property in the <var>optionalParameters</var> is true,
    1.19 +                then a <code>DOMException</code> of type <a>InvalidAccessError</a> MUST be thrown. Otherwise set the created <a>object store</a>'s
    1.20                  <a title="object store key path">key path</a> is set to the value of <var>keyPath</var>.
    1.21                </p>
    1.22                <p>
    1.23 @@ -2771,20 +2771,18 @@
    1.24              <dd>The <a>database</a> <a>connection</a> of which this <a>transaction</a>
    1.25                is a part
    1.26              </dd>
    1.27 -			<dt>readonly attribute DOMError       error</dt>
    1.28 -			<dd>
    1.29 -              When the <a title="request done">done</a> flag is true, getting this
    1.30 -              property MUST return the error of the request that caused the <a>transaction</a> to be aborted. 
    1.31 -              If the error was generated when committing the <a>transaction</a> and not from an individual request, 
    1.32 -              the error must contain the reasons for the transaction failure (e.g. <code>QuotaExceededError</code>, <code>UnknownError</code>). 
    1.33 -              This is null when no error occurred or when the transaction is programmatically aborted. 
    1.34 -              When the <a title="request done">done</a> flag is false, 
    1.35 -              getting this property MUST throw a DOMException of type <code>InvalidStateError</code>.
    1.36 -              <dl class="getraises" title="DOMException">
    1.37 -                <dt><a>InvalidStateError</a></dt>
    1.38 -                <dd>Thrown when this attribute was read when the <a title="request done">done</a> flag was set to false.</dd>
    1.39 -              </dl>
    1.40 -			</dd>
    1.41 +            <dt>readonly attribute DOMError       error</dt>
    1.42 +            <dd>
    1.43 +              If this <a>transaction</a> is not <a>finished</a>, is <a>finished</a> but was successfully
    1.44 +              <a title="commit">committed</a>, or was aborted due to a call to the
    1.45 +              <a class="idlType" href="#widl-IDBTransaction-abort-void"><code>abort</code></a> function, this property
    1.46 +              returns <code>null</code>.
    1.47 +              If this transaction was aborted due to a failed <a>request</a>, this property returns the same
    1.48 +              <code>DOMError</code> as the <a>request</a> which caused this transaction to be aborted.
    1.49 +              If this transaction was aborted due to an error when committing the <a>transaction</a>, and not due to a failed
    1.50 +              <a>request</a>, this property returns a <code>DOMError</code> which contains the reason for the transaction
    1.51 +              failure (e.g. <code>QuotaExceededError</code> or <code>UnknownError</code>).
    1.52 +            </dd>
    1.53              <dt>IDBObjectStore objectStore()</dt>
    1.54              <dd>
    1.55                Returns an <a>IDBObjectStore</a> representing an <a>object store</a> that is part of the
    1.56 @@ -3509,7 +3507,7 @@
    1.57                  or if <var>keyPath</var> is a string and is not a <a>valid key path</a>, then a <code>DOMException</code>
    1.58                  of type <a>SyntaxError</a> MUST be thrown. If <var>keyPath</var> is
    1.59                  and <code>Array</code> and the <var>multiEntry</var> property in the <var>optionalParameters</var> is true,
    1.60 -                then a <code>DOMException</code> of type <a>NotSupportedError</a> MUST be thrown. Otherwise set the created <a>object store</a>'s
    1.61 +                then a <code>DOMException</code> of type <a>InvalidAccessError</a> MUST be thrown. Otherwise set the created <a>object store</a>'s
    1.62                  <a title="object store key path">key path</a> is set to the value of <var>keyPath</var>.
    1.63                </p>
    1.64                <dl class="parameters">
    1.65 @@ -4181,20 +4179,18 @@
    1.66              <dt>attribute IDBDatabaseSync db</dt>
    1.67              <dd>The <a>database</a> <a>connection</a> of which this <a>transaction</a>
    1.68                is a part</dd>
    1.69 -			<dt>readonly attribute DOMError       error</dt>
    1.70 -			<dd>
    1.71 -              When the <a title="request done">done</a> flag is true, getting this
    1.72 -              property MUST return the error of the request that caused the <a>transaction</a> to be aborted. 
    1.73 -              If the error was generated when committing the <a>transaction</a> and not from an individual request, 
    1.74 -              the error must contain the reasons for the transaction failure (e.g. <code>QuotaExceededError</code>, <code>UnknownError</code>). 
    1.75 -              This is null when no error occurred or when the transaction is programmatically aborted. 
    1.76 -              When the <a title="request done">done</a> flag is false, 
    1.77 -              getting this property MUST throw a DOMException of type <code>InvalidStateError</code>.
    1.78 -              <dl class="getraises" title="DOMException">
    1.79 -                <dt><a>InvalidStateError</a></dt>
    1.80 -                <dd>Thrown when this attribute was read when the <a title="request done">done</a> flag was set to false.</dd>
    1.81 -              </dl>
    1.82 -			</dd>
    1.83 +            <dt>readonly attribute DOMError       error</dt>
    1.84 +            <dd>
    1.85 +              If this <a>transaction</a> is not <a>finished</a>, is <a>finished</a> but was successfully
    1.86 +              <a title="commit">committed</a>, or was aborted due to a call to the
    1.87 +              <a class="idlType" href="#widl-IDBTransactionSync-abort-void"><code>abort</code></a> function, this property
    1.88 +              returns <code>null</code>.
    1.89 +              If this transaction was aborted due to a failed <a>request</a>, this property returns the same
    1.90 +              <code>DOMError</code> as the <a>request</a> which caused this transaction to be aborted.
    1.91 +              If this transaction was aborted due to an error when committing the <a>transaction</a>, and not due to a failed
    1.92 +              <a>request</a>, this property returns a <code>DOMError</code> which contains the reason for the transaction
    1.93 +              failure (e.g. <code>QuotaExceededError</code> or <code>UnknownError</code>).
    1.94 +            </dd>
    1.95              <dt>IDBObjectStoreSync objectStore()</dt>
    1.96              <dd>
    1.97                Returns an <a>IDBObjectStoreSync</a> representing an <a>object store</a> that is within the <a>scope</a> of this <a>transaction</a>. 
    1.98 @@ -4219,9 +4215,8 @@
    1.99              <dd>
   1.100                If this <a>transaction</a> is <a title="transaction finish">finished</a>, throw a <code>DOMException</code> of type <a>InvalidStateError</a>. 
   1.101                Otherwise this method sets the transactions's <a>active</a> flag to false and
   1.102 -              <a title="transaction abort">aborts</a> the transaction by running the
   1.103 -              <a>steps for aborting a transaction</a>.
   1.104 -              It also sets the <var>error</var> attribute on the <a>transaction</a> to a <code>DOMError</code> of type <a>AbortError</a>.
   1.105 +              <a title="transaction abort">aborts</a> the transaction by running the <a>steps for aborting a transaction</a> with the <var>error</var>
   1.106 +              parameter set to <code>null</code>.
   1.107                <dl class="exception" title="DOMException">
   1.108                  <dt>InvalidStateError</dt>
   1.109                  <dd>If this <a>transaction</a> has already been committed or aborted.</dd>
   1.110 @@ -4468,8 +4463,11 @@
   1.111                    and set the request's <code>error</code> attribute to a <code>DOMError</code> with a type of <a>AbortError</a>.
   1.112                  </li>
   1.113                  <li>
   1.114 -                  <a>Fire an error event</a> at the <a>request</a>. However when running these
   1.115 -                  steps, ignore any request to run the <a>steps for aborting a transaction</a> as those steps are already running.
   1.116 +                  Dispatch an event at <var>request</var>. The event must use
   1.117 +                  the <a><code>Event</code></a> interface and have its <code>type</code> set to <code>"error"</code>.
   1.118 +                  The event bubbles and is cancelable. The
   1.119 +                  <a>propagation path</a> for the event is <var>transaction</var>'s <a title="transaction connection">connection</a>,
   1.120 +                  then <var>transaction</var> and finally the <a>request</a>. There is no <a>default action</a> for the event.
   1.121                  </li>
   1.122                </ol>
   1.123                <p class="note">
   1.124 @@ -4933,7 +4931,8 @@
   1.125                <a>propagation path</a> for the event is the <var>transaction</var>'s <a title="transaction connection">connection</a>,
   1.126                then <var>transaction</var> and finally <var>request</var>. The event's <a>default action</a> is to abort the
   1.127                <var>transaction</var> by running the <a>steps for aborting a transaction</a> using <var>transaction</var> as <var>transaction</var>
   1.128 -              and the <code>name</code> of <a>request</a>'s <code>error</code> property as <var>error</var>.
   1.129 +              and the <code>name</code> of <a>request</a>'s <code>error</code> property as <var>error</var>. However the <a>default action</a> is
   1.130 +              not taken if any of the event handlers threw an exception.
   1.131              </li>
   1.132              <li>
   1.133                Set the <a>active</a> flag of <var>transaction</var> to false.
   1.134 @@ -4941,7 +4940,12 @@
   1.135              <li>
   1.136                If an exception was propagated out from any event handler while dispatching the event in step 3,
   1.137                abort the transaction by following the <a>steps for aborting a transaction</a> using <var>transaction</var> as
   1.138 -              <var>transaction</var> parameter, and <code>AbortError</code> as <var>error</var>.
   1.139 +              <var>transaction</var> parameter, and <code>AbortError</code> as <var>error</var>. This is done even if the error event is not
   1.140 +              canceled.
   1.141 +              <p class="note">
   1.142 +                This means that if an error event is fired and any of the event handlers throw an exception, the <code>error</code> property
   1.143 +                on the transaction is set to an <code>AbortError</code> rather than whatever <code>DOMError</code> the <code>error</code>
   1.144 +                property on the request was set to. Even if <code>preventDefault</code> is never called.
   1.145              </li>
   1.146            </ol>
   1.147          </section>
     2.1 --- a/Speclet_021_IDB_API_Algorithms.html	Thu Jul 12 15:10:48 2012 -0700
     2.2 +++ b/Speclet_021_IDB_API_Algorithms.html	Sun Jul 15 02:19:57 2012 -0700
     2.3 @@ -365,8 +365,11 @@
     2.4                    and set the request's <code>error</code> attribute to a <code>DOMError</code> with a type of <a>AbortError</a>.
     2.5                  </li>
     2.6                  <li>
     2.7 -                  <a>Fire an error event</a> at the <a>request</a>. However when running these
     2.8 -                  steps, ignore any request to run the <a>steps for aborting a transaction</a> as those steps are already running.
     2.9 +                  Dispatch an event at <var>request</var>. The event must use
    2.10 +                  the <a><code>Event</code></a> interface and have its <code>type</code> set to <code>"error"</code>.
    2.11 +                  The event bubbles and is cancelable. The
    2.12 +                  <a>propagation path</a> for the event is <var>transaction</var>'s <a title="transaction connection">connection</a>,
    2.13 +                  then <var>transaction</var> and finally the <a>request</a>. There is no <a>default action</a> for the event.
    2.14                  </li>
    2.15                </ol>
    2.16                <p class="note">
    2.17 @@ -830,7 +833,8 @@
    2.18                <a>propagation path</a> for the event is the <var>transaction</var>'s <a title="transaction connection">connection</a>,
    2.19                then <var>transaction</var> and finally <var>request</var>. The event's <a>default action</a> is to abort the
    2.20                <var>transaction</var> by running the <a>steps for aborting a transaction</a> using <var>transaction</var> as <var>transaction</var>
    2.21 -              and the <code>name</code> of <a>request</a>'s <code>error</code> property as <var>error</var>.
    2.22 +              and the <code>name</code> of <a>request</a>'s <code>error</code> property as <var>error</var>. However the <a>default action</a> is
    2.23 +              not taken if any of the event handlers threw an exception.
    2.24              </li>
    2.25              <li>
    2.26                Set the <a>active</a> flag of <var>transaction</var> to false.
    2.27 @@ -838,7 +842,12 @@
    2.28              <li>
    2.29                If an exception was propagated out from any event handler while dispatching the event in step 3,
    2.30                abort the transaction by following the <a>steps for aborting a transaction</a> using <var>transaction</var> as
    2.31 -              <var>transaction</var> parameter, and <code>AbortError</code> as <var>error</var>.
    2.32 +              <var>transaction</var> parameter, and <code>AbortError</code> as <var>error</var>. This is done even if the error event is not
    2.33 +              canceled.
    2.34 +              <p class="note">
    2.35 +                This means that if an error event is fired and any of the event handlers throw an exception, the <code>error</code> property
    2.36 +                on the transaction is set to an <code>AbortError</code> rather than whatever <code>DOMError</code> the <code>error</code>
    2.37 +                property on the request was set to. Even if <code>preventDefault</code> is never called.
    2.38              </li>
    2.39            </ol>
    2.40          </section>
     3.1 --- a/Speclet_022_IDB_API_Synchronous_APIs.html	Thu Jul 12 15:10:48 2012 -0700
     3.2 +++ b/Speclet_022_IDB_API_Synchronous_APIs.html	Sun Jul 15 02:19:57 2012 -0700
     3.3 @@ -822,7 +822,7 @@
     3.4                  or if <var>keyPath</var> is a string and is not a <a>valid key path</a>, then a <code>DOMException</code>
     3.5                  of type <a>SyntaxError</a> MUST be thrown. If <var>keyPath</var> is
     3.6                  and <code>Array</code> and the <var>multiEntry</var> property in the <var>optionalParameters</var> is true,
     3.7 -                then a <code>DOMException</code> of type <a>NotSupportedError</a> MUST be thrown. Otherwise set the created <a>object store</a>'s
     3.8 +                then a <code>DOMException</code> of type <a>InvalidAccessError</a> MUST be thrown. Otherwise set the created <a>object store</a>'s
     3.9                  <a title="object store key path">key path</a> is set to the value of <var>keyPath</var>.
    3.10                </p>
    3.11                <dl class="parameters">
    3.12 @@ -1494,20 +1494,18 @@
    3.13              <dt>attribute IDBDatabaseSync db</dt>
    3.14              <dd>The <a>database</a> <a>connection</a> of which this <a>transaction</a>
    3.15                is a part</dd>
    3.16 -			<dt>readonly attribute DOMError       error</dt>
    3.17 -			<dd>
    3.18 -              When the <a title="request done">done</a> flag is true, getting this
    3.19 -              property MUST return the error of the request that caused the <a>transaction</a> to be aborted. 
    3.20 -              If the error was generated when committing the <a>transaction</a> and not from an individual request, 
    3.21 -              the error must contain the reasons for the transaction failure (e.g. <code>QuotaExceededError</code>, <code>UnknownError</code>). 
    3.22 -              This is null when no error occurred or when the transaction is programmatically aborted. 
    3.23 -              When the <a title="request done">done</a> flag is false, 
    3.24 -              getting this property MUST throw a DOMException of type <code>InvalidStateError</code>.
    3.25 -              <dl class="getraises" title="DOMException">
    3.26 -                <dt><a>InvalidStateError</a></dt>
    3.27 -                <dd>Thrown when this attribute was read when the <a title="request done">done</a> flag was set to false.</dd>
    3.28 -              </dl>
    3.29 -			</dd>
    3.30 +            <dt>readonly attribute DOMError       error</dt>
    3.31 +            <dd>
    3.32 +              If this <a>transaction</a> is not <a>finished</a>, is <a>finished</a> but was successfully
    3.33 +              <a title="commit">committed</a>, or was aborted due to a call to the
    3.34 +              <a class="idlType" href="#widl-IDBTransactionSync-abort-void"><code>abort</code></a> function, this property
    3.35 +              returns <code>null</code>.
    3.36 +              If this transaction was aborted due to a failed <a>request</a>, this property returns the same
    3.37 +              <code>DOMError</code> as the <a>request</a> which caused this transaction to be aborted.
    3.38 +              If this transaction was aborted due to an error when committing the <a>transaction</a>, and not due to a failed
    3.39 +              <a>request</a>, this property returns a <code>DOMError</code> which contains the reason for the transaction
    3.40 +              failure (e.g. <code>QuotaExceededError</code> or <code>UnknownError</code>).
    3.41 +            </dd>
    3.42              <dt>IDBObjectStoreSync objectStore()</dt>
    3.43              <dd>
    3.44                Returns an <a>IDBObjectStoreSync</a> representing an <a>object store</a> that is within the <a>scope</a> of this <a>transaction</a>. 
    3.45 @@ -1532,9 +1530,8 @@
    3.46              <dd>
    3.47                If this <a>transaction</a> is <a title="transaction finish">finished</a>, throw a <code>DOMException</code> of type <a>InvalidStateError</a>. 
    3.48                Otherwise this method sets the transactions's <a>active</a> flag to false and
    3.49 -              <a title="transaction abort">aborts</a> the transaction by running the
    3.50 -              <a>steps for aborting a transaction</a>.
    3.51 -              It also sets the <var>error</var> attribute on the <a>transaction</a> to a <code>DOMError</code> of type <a>AbortError</a>.
    3.52 +              <a title="transaction abort">aborts</a> the transaction by running the <a>steps for aborting a transaction</a> with the <var>error</var>
    3.53 +              parameter set to <code>null</code>.
    3.54                <dl class="exception" title="DOMException">
    3.55                  <dt>InvalidStateError</dt>
    3.56                  <dd>If this <a>transaction</a> has already been committed or aborted.</dd>
     4.1 --- a/Speclet_023_IDB_API_Asynchronous_APIs.html	Thu Jul 12 15:10:48 2012 -0700
     4.2 +++ b/Speclet_023_IDB_API_Asynchronous_APIs.html	Sun Jul 15 02:19:57 2012 -0700
     4.3 @@ -918,8 +918,8 @@
     4.4                  If <var>keyPath</var> is an <code>Array</code> and any items in the array is not a <a>valid key path</a>,
     4.5                  or if <var>keyPath</var> is a string and is not a <a>valid key path</a> then a <code>DOMException</code>
     4.6                  of type <a>SyntaxError</a> MUST be thrown. If <var>keyPath</var> is
     4.7 -                and <code>Array</code> and the <var>multiEntry</var> property in the <var>optionalParameters</var> is true,
     4.8 -                then a <code>DOMException</code> of type <a>NotSupportedError</a> MUST be thrown. Otherwise set the created <a>object store</a>'s
     4.9 +                an <code>Array</code> and the <var>multiEntry</var> property in the <var>optionalParameters</var> is true,
    4.10 +                then a <code>DOMException</code> of type <a>InvalidAccessError</a> MUST be thrown. Otherwise set the created <a>object store</a>'s
    4.11                  <a title="object store key path">key path</a> is set to the value of <var>keyPath</var>.
    4.12                </p>
    4.13                <p>
    4.14 @@ -1474,20 +1474,18 @@
    4.15              <dd>The <a>database</a> <a>connection</a> of which this <a>transaction</a>
    4.16                is a part
    4.17              </dd>
    4.18 -			<dt>readonly attribute DOMError       error</dt>
    4.19 -			<dd>
    4.20 -              When the <a title="request done">done</a> flag is true, getting this
    4.21 -              property MUST return the error of the request that caused the <a>transaction</a> to be aborted. 
    4.22 -              If the error was generated when committing the <a>transaction</a> and not from an individual request, 
    4.23 -              the error must contain the reasons for the transaction failure (e.g. <code>QuotaExceededError</code>, <code>UnknownError</code>). 
    4.24 -              This is null when no error occurred or when the transaction is programmatically aborted. 
    4.25 -              When the <a title="request done">done</a> flag is false, 
    4.26 -              getting this property MUST throw a DOMException of type <code>InvalidStateError</code>.
    4.27 -              <dl class="getraises" title="DOMException">
    4.28 -                <dt><a>InvalidStateError</a></dt>
    4.29 -                <dd>Thrown when this attribute was read when the <a title="request done">done</a> flag was set to false.</dd>
    4.30 -              </dl>
    4.31 -			</dd>
    4.32 +            <dt>readonly attribute DOMError       error</dt>
    4.33 +            <dd>
    4.34 +              If this <a>transaction</a> is not <a>finished</a>, is <a>finished</a> but was successfully
    4.35 +              <a title="commit">committed</a>, or was aborted due to a call to the
    4.36 +              <a class="idlType" href="#widl-IDBTransaction-abort-void"><code>abort</code></a> function, this property
    4.37 +              returns <code>null</code>.
    4.38 +              If this transaction was aborted due to a failed <a>request</a>, this property returns the same
    4.39 +              <code>DOMError</code> as the <a>request</a> which caused this transaction to be aborted.
    4.40 +              If this transaction was aborted due to an error when committing the <a>transaction</a>, and not due to a failed
    4.41 +              <a>request</a>, this property returns a <code>DOMError</code> which contains the reason for the transaction
    4.42 +              failure (e.g. <code>QuotaExceededError</code> or <code>UnknownError</code>).
    4.43 +            </dd>
    4.44              <dt>IDBObjectStore objectStore()</dt>
    4.45              <dd>
    4.46                Returns an <a>IDBObjectStore</a> representing an <a>object store</a> that is part of the