Skip to content

Commit 812ee6f

Browse files
Add handle to cursor to avoid exposing internal state to script (#455)
Closes #445 by updating cursors to include an object store handle or an index handle. Co-authored-by: Joshua Bell <[email protected]>
1 parent 896d5be commit 812ee6f

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

index.bs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,15 +1380,17 @@ A <dfn>cursor</dfn> is used to iterate over a range of records in an
13801380

13811381
<div dfn-for=cursor>
13821382

1383-
A [=cursor=] has a <dfn>transaction</dfn>, the [=/transaction=]
1384-
that was [=transaction/active=] when the cursor was created.
1383+
A [=cursor=] has a <dfn>source handle</dfn>, which is the [=/index handle=] or the [=/object store handle=] that opened the cursor.
1384+
1385+
A [=cursor=] has a <dfn>transaction</dfn>, which is the [=/transaction=] from the cursor's [=cursor/source handle=].
13851386

13861387
A [=cursor=] has a <dfn>range</dfn> of records in either an
13871388
[=/index=] or an [=/object store=].
13881389

1389-
A [=cursor=] has a <dfn>source</dfn> that indicates which [=/index=]
1390-
or an [=/object store=] is associated with the records over which
1391-
the [=cursor=] is iterating.
1390+
A [=cursor=] has a <dfn>source</dfn>, which is an [=/index=] or an [=/object store=] from the cursor's [=cursor/source handle=].
1391+
The cursor's [=cursor/source=] indicates which [=/index=] or [=/object store=] is associated with the records over which the [=cursor=] is iterating.
1392+
If the cursor's [=cursor/source handle=] is an [=index handle=], then the cursor's [=cursor/source=] is [=index-handle/index|the index handle's associated index=].
1393+
Otherwise, cursor's [=cursor/source=] is [=object-store-handle/object store|the object store handle's associated object store=].
13921394

13931395
A [=cursor=] has a <dfn>direction</dfn> that determines whether it
13941396
moves in monotonically increasing or decreasing order of the
@@ -3306,12 +3308,11 @@ The <dfn method for=IDBObjectStore>openCursor(|query|, |direction|)</dfn> method
33063308
Rethrow any exceptions.
33073309

33083310
1. Let |cursor| be a new [=cursor=] with its
3309-
[=cursor/transaction=] set to |transaction|,
3311+
[=cursor/source handle=] set to [=/this=],
33103312
undefined [=cursor/position=],
33113313
[=cursor/direction=] set to |direction|,
33123314
[=cursor/got value flag=] set to false,
33133315
undefined [=cursor/key=] and [=cursor/value=],
3314-
[=cursor/source=] set to |store|,
33153316
[=cursor/range=] set to |range|, and
33163317
[=cursor/key only flag=] set to false.
33173318

@@ -3350,12 +3351,11 @@ The <dfn method for=IDBObjectStore>openKeyCursor(|query|, |direction|)</dfn> met
33503351
Rethrow any exceptions.
33513352

33523353
1. Let |cursor| be a new [=cursor=] with its
3353-
[=cursor/transaction=] set to |transaction|,
3354+
[=cursor/source handle=] set to [=/this=],
33543355
undefined [=cursor/position=],
33553356
[=cursor/direction=] set to |direction|,
33563357
[=cursor/got value flag=] set to false,
33573358
undefined [=cursor/key=] and [=cursor/value=],
3358-
[=cursor/source=] set to |store|,
33593359
[=cursor/range=] set to |range|, and
33603360
[=cursor/key only flag=] set to true.
33613361

@@ -3962,12 +3962,11 @@ The <dfn method for=IDBIndex>openCursor(|query|, |direction|)</dfn> method steps
39623962
Rethrow any exceptions.
39633963

39643964
1. Let |cursor| be a new [=cursor=] with its
3965-
[=cursor/transaction=] set to |transaction|,
3965+
[=cursor/source handle=] set to [=/this=],
39663966
undefined [=cursor/position=],
39673967
[=cursor/direction=] set to |direction|,
39683968
[=cursor/got value flag=] set to false,
39693969
undefined [=cursor/key=] and [=cursor/value=],
3970-
[=cursor/source=] set to |index|,
39713970
[=cursor/range=] set to |range|, and
39723971
[=cursor/key only flag=] set to false.
39733972

@@ -4006,12 +4005,11 @@ The <dfn method for=IDBIndex>openKeyCursor(|query|, |direction|)</dfn> method st
40064005
Rethrow any exceptions.
40074006

40084007
1. Let |cursor| be a new [=cursor=] with its
4009-
[=cursor/transaction=] set to |transaction|,
4008+
[=cursor/source handle=] set to [=/this=],
40104009
undefined [=cursor/position=],
40114010
[=cursor/direction=] set to |direction|,
40124011
[=cursor/got value flag=] set to false,
40134012
undefined [=cursor/key=] and [=cursor/value=],
4014-
[=cursor/source=] set to |index|,
40154013
[=cursor/range=] set to |range|, and
40164014
[=cursor/key only flag=] set to true.
40174015

@@ -4274,7 +4272,7 @@ enum IDBCursorDirection {
42744272

42754273

42764274
The <dfn attribute for=IDBCursor>source</dfn> getter steps are to
4277-
return [=/this=]'s [=cursor/source=].
4275+
return [=/this=]'s [=cursor/source handle=].
42784276

42794277
NOTE:
42804278
The {{IDBCursor/source}} attribute never returns null or throws an exception, even if the
@@ -4384,7 +4382,7 @@ The <dfn method for=IDBCursor>advance(|count|)</dfn> method steps are:
43844382

43854383
1. Let |operation| be an algorithm to run [=iterate a cursor=] with [=ECMAScript/the current Realm record=], [=/this=], and |count|.
43864384

4387-
1. Run [=asynchronously execute a request=] with [=/this=]'s [=cursor/source=], |operation|, and |request|.
4385+
1. Run [=asynchronously execute a request=] with [=/this=]'s [=cursor/source handle=], |operation|, and |request|.
43884386

43894387
</div>
43904388

@@ -4440,7 +4438,7 @@ The <dfn method for=IDBCursor>continue(|key|)</dfn> method steps are:
44404438

44414439
1. Let |operation| be an algorithm to run [=iterate a cursor=] with [=ECMAScript/the current Realm record=], [=/this=], and |key| (if given).
44424440

4443-
1. Run [=asynchronously execute a request=] with [=/this=]'s [=cursor/source=], |operation|, and |request|.
4441+
1. Run [=asynchronously execute a request=] with [=/this=]'s [=cursor/source handle=], |operation|, and |request|.
44444442

44454443
</div>
44464444

@@ -4517,7 +4515,7 @@ The <dfn method for=IDBCursor>continuePrimaryKey(|key|, |primaryKey|)</dfn> meth
45174515

45184516
1. Let |operation| be an algorithm to run [=iterate a cursor=] with [=ECMAScript/the current Realm record=], [=/this=], |key|, and |primaryKey|.
45194517

4520-
1. Run [=asynchronously execute a request=] with [=/this=]'s [=cursor/source=], |operation|, and |request|.
4518+
1. Run [=asynchronously execute a request=] with [=/this=]'s [=cursor/source handle=], |operation|, and |request|.
45214519

45224520
</div>
45234521

@@ -6721,6 +6719,7 @@ For the revision history of the second edition, see [that document's Revision Hi
67216719
* Clarify that only [=transaction/inactive=] [=/transactions=] should attempt to auto-commit. (<#436>)
67226720
* Correct [=/upgrade a database=] steps to handle aborted transactions. (<#436>)
67236721
* Update [=/iterate a cursor=] value serialization to use [=/value=] for [=/object stores=] instead of [=index/referenced values=]. (<#452>)
6722+
* Add [=cursor/source handle=] to [=/cursor=] to avoid exposing internal indexes and object stores to script. (<#445>)
67246723

67256724
<!-- ============================================================ -->
67266725
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)