|
151 | 151 | });
|
152 | 152 |
|
153 | 153 | queuedAsyncTest("Open a lower version schema", function(){
|
154 |
| - |
155 | 154 | $.indexedDB(DB.NAME, 1).then(function(res, e){
|
156 | 155 | ok(false, "Should not have opened as DB was lower version");
|
157 | 156 | _("Should not have opened as DB was lower version");
|
|
220 | 219 | ok(true, "Added " + res + " to the database");
|
221 | 220 | _("Added" + res + "to the database ");
|
222 | 221 | start();
|
| 222 | + stop(); |
223 | 223 | $.indexedDB(DB.NAME).objectStore(DB.OBJECT_STORE_1).get(res).then(function(val){
|
224 | 224 | deepEqual(val, value, "Value of the returned object " + val);
|
225 | 225 | _("Got object using" + res + " key");
|
|
386 | 386 | ok(true, "Object Deleted " + elem.key);
|
387 | 387 | _("Object Deleted");
|
388 | 388 | start();
|
389 |
| - nextTest(); |
| 389 | + stop(); |
390 | 390 | }, function(){
|
391 | 391 | ok(false, "Object NOT Deleted " + elem.key);
|
392 | 392 | _("Object NOT Deleted");
|
393 | 393 | start();
|
394 |
| - nextTest(); |
| 394 | + stop(); |
395 | 395 | });
|
396 | 396 | } else {
|
397 | 397 | var val = elem.value;
|
|
400 | 400 | ok(true, "Object updated " + elem.key);
|
401 | 401 | _("Object updated");
|
402 | 402 | start();
|
403 |
| - nextTest(); |
| 403 | + stop(); |
404 | 404 | }, function(){
|
405 | 405 | ok(false, "Object NOT updated " + elem.key);
|
406 | 406 | _("Object NOT updated");
|
407 | 407 | start();
|
408 |
| - nextTest(); |
| 408 | + stop(); |
409 | 409 | });
|
410 | 410 | }
|
411 | 411 | ok(true, "Looking at " + elem.key);
|
|
414 | 414 | }).then(function(){
|
415 | 415 | ok(true, "Iteration complete success");
|
416 | 416 | start();
|
| 417 | + nextTest(); |
417 | 418 | }, function(){
|
418 | 419 | ok(false, "Iteration complete failure");
|
419 | 420 | start();
|
| 421 | + nextTest(); |
420 | 422 | });
|
421 | 423 | });
|
422 | 424 |
|
|
498 | 500 | var value = sample.obj();
|
499 | 501 | var objectStore = $.indexedDB(DB.NAME).objectStore(DB.OBJECT_STORE_1);
|
500 | 502 | objectStore.index("Int").each(function(elem){
|
501 |
| - equal(elem.key >= 30 && elem.key <= 70, true, elem.value.Int + " is between 30 and 70"); |
| 503 | + equal(elem.key >= 10 && elem.key <= 90, true, elem.value.Int + " is between 10 and 90"); |
| 504 | + _("Iterating on " + JSON.stringify(elem.value)); |
| 505 | + start(); |
| 506 | + stop(); |
| 507 | + }, [10, 90]).then(function(res, e){ |
| 508 | + ok(true, "Index Iteration completed"); |
| 509 | + start(); |
| 510 | + nextTest(); |
| 511 | + }, function(err, e){ |
| 512 | + ok(false, "Index Iteration NOT completed"); |
| 513 | + _("Index Iteration NOT completed"); |
| 514 | + start(); |
| 515 | + nextTest(); |
| 516 | + }); |
| 517 | + }); |
| 518 | + |
| 519 | + queuedAsyncTest("Index Iteration with range, reverse", function(){ |
| 520 | + var key = sample.integer(); |
| 521 | + var value = sample.obj(); |
| 522 | + var objectStore = $.indexedDB(DB.NAME).objectStore(DB.OBJECT_STORE_1); |
| 523 | + var prev = Infinity; |
| 524 | + objectStore.index("Int").each(function(elem){ |
| 525 | + equal(prev > elem.key, true, elem.key + " is less that the previous value and in range " + prev); |
| 526 | + prev = elem.key; |
502 | 527 | _("Iterating on " + JSON.stringify(elem.value));
|
503 | 528 | start();
|
504 | 529 | stop();
|
505 |
| - }, [30, 70]).then(function(res, e){ |
| 530 | + }, [10, 90], $.indexedDB.IDBCursor.PREV).then(function(res, e){ |
506 | 531 | ok(true, "Index Iteration completed");
|
507 | 532 | start();
|
508 | 533 | nextTest();
|
|
517 | 542 | queuedAsyncTest("Index iteration with keyCursor", function(){
|
518 | 543 | var key = sample.integer();
|
519 | 544 | var value = sample.obj();
|
520 |
| - var objectStore = $.indexedDB(DB.NAME).objectStore(DB.OBJECT_STORE_2); |
521 |
| - objectStore.index(DB.INDEX1_ON_OBJECT_STORE_2).eachKey(function(elem){ |
| 545 | + var objectStore = $.indexedDB(DB.NAME).objectStore(DB.OBJECT_STORE_1); |
| 546 | + objectStore.index("Int").eachKey(function(elem){ |
522 | 547 | ok(true, "Iterating on " + elem.key + ":" + elem.value);
|
523 | 548 | start();
|
524 | 549 | stop();
|
|
534 | 559 | });
|
535 | 560 | });
|
536 | 561 |
|
| 562 | + queuedAsyncTest("Index iteration with keyCursor and range, reverse", function(){ |
| 563 | + var key = sample.integer(); |
| 564 | + var value = sample.obj(); |
| 565 | + var objectStore = $.indexedDB(DB.NAME).objectStore(DB.OBJECT_STORE_1); |
| 566 | + var prev = Infinity; |
| 567 | + objectStore.index("Int").eachKey(function(elem){ |
| 568 | + equal(prev > elem.key, true, elem.key + " is less that the previous value " + prev); |
| 569 | + prev = elem.key |
| 570 | + start(); |
| 571 | + stop(); |
| 572 | + }, [10, 90], $.indexedDB.IDBCursor.PREV).then(function(res, e){ |
| 573 | + ok(true, "Index Iteration completed"); |
| 574 | + start(); |
| 575 | + nextTest(); |
| 576 | + }, function(err, e){ |
| 577 | + ok(false, "Index Iteration NOT completed"); |
| 578 | + _("Index Iteration NOT completed"); |
| 579 | + start(); |
| 580 | + nextTest(); |
| 581 | + }); |
| 582 | + }); |
| 583 | + |
537 | 584 | queuedModule("Transactions");
|
538 | 585 | queuedAsyncTest("Simple transaction", function(){
|
539 | 586 | $.indexedDB(DB.NAME).transaction([DB.OBJECT_STORE_1, DB.OBJECT_STORE_2, DB.OBJECT_STORE_3]).then(function(e){
|
|
564 | 611 | });
|
565 | 612 |
|
566 | 613 | queuedAsyncTest("Simple transaction with mode", function(){
|
567 |
| - |
568 | 614 | $.indexedDB(DB.NAME).transaction([DB.OBJECT_STORE_1, DB.OBJECT_STORE_2, DB.OBJECT_STORE_3], $.indexedDB.IDBTransaction.READ_WRITE).then(function(e){
|
569 | 615 | equal(e.type, "complete", "Transaction completed successfully");
|
570 | 616 | start();
|
|
582 | 628 | });
|
583 | 629 |
|
584 | 630 | queuedAsyncTest("Aborted transaction", function(){
|
585 |
| - |
586 | 631 | $.indexedDB(DB.NAME).transaction([DB.OBJECT_STORE_1, DB.OBJECT_STORE_2, DB.OBJECT_STORE_3]).then(function(e){
|
587 | 632 | notEqual(e.type, "complete", "Transaction completed successfully");
|
588 | 633 | start();
|
|
605 | 650 | });
|
606 | 651 |
|
607 | 652 | queuedAsyncTest("Transaction with non-existant object store", function(){
|
608 |
| - |
609 | 653 | $.indexedDB(DB.NAME).transaction(["Error ", DB.OBJECT_STORE_2, DB.OBJECT_STORE_3]).then(function(e){
|
610 | 654 | notEqual(e.type, "complete", "Transaction completed successfully");
|
611 | 655 | start();
|
|
620 | 664 | });
|
621 | 665 |
|
622 | 666 | queuedAsyncTest("Transaction aborts due to exception when in progress", function(){
|
623 |
| - |
624 | 667 | $.indexedDB(DB.NAME).transaction([DB.OBJECT_STORE_1, DB.OBJECT_STORE_2, DB.OBJECT_STORE_3]).then(function(e){
|
625 | 668 | notEqual(e.type, "complete", "Transaction completed successfully");
|
626 | 669 | start();
|
|
637 | 680 | });
|
638 | 681 |
|
639 | 682 | queuedAsyncTest("Multiple object store ops", function(){
|
640 |
| - |
641 | 683 | var testCount = 0;
|
642 | 684 | for (var i = 0; i < 10; i++) {
|
643 | 685 | (function(mode, count){
|
|
681 | 723 | });
|
682 | 724 |
|
683 | 725 | queuedAsyncTest("Multiple transactions at same time", function(){
|
684 |
| - |
685 | 726 | var testCount = 0;
|
686 | 727 | for (var i = 0; i < 10; i++) {
|
687 | 728 | (function(mode, count){
|
|
705 | 746 | transaction.objectStore(DB.OBJECT_STORE_1).add(sample.obj(), count).then(function(res, e){
|
706 | 747 | _(count + "> Added to Object Store 1: " + mode);
|
707 | 748 | ok(true, count + "> Added to Object Store 1: " + mode);
|
| 749 | + start(); |
| 750 | + stop(); |
708 | 751 | }, function(err, e){
|
709 | 752 | _(count + "> Could not add to Object Store 1: " + mode);
|
710 | 753 | ok(false, count + "> Could not add in transaction to Object Store 1: " + mode);
|
| 754 | + start(); |
| 755 | + stop(); |
711 | 756 | });
|
712 | 757 | } else {
|
713 | 758 | transaction.objectStore(DB.OBJECT_STORE_1).each(function(elem){
|
714 | 759 | _(count + "> Reading " + elem.key);
|
715 | 760 | ok(true, count + "> Reading " + elem.key);
|
| 761 | + start(); |
| 762 | + stop(); |
716 | 763 | return false;
|
717 | 764 | });
|
718 | 765 | }
|
|
0 commit comments