test_optionalArguments.js 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712
  1. /**
  2. * Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/
  4. */
  5. var testGenerator = testSteps();
  6. function testSteps()
  7. {
  8. const osName = "people";
  9. const indexName = "weight";
  10. const data = [
  11. { ssn: "237-23-7732", name: "Bob", height: 60, weight: 120 },
  12. { ssn: "237-23-7733", name: "Ann", height: 52, weight: 110 },
  13. { ssn: "237-23-7734", name: "Ron", height: 73, weight: 180 },
  14. { ssn: "237-23-7735", name: "Sue", height: 58, weight: 130 },
  15. { ssn: "237-23-7736", name: "Joe", height: 65, weight: 150 },
  16. { ssn: "237-23-7737", name: "Pat", height: 65 },
  17. { ssn: "237-23-7738", name: "Mel", height: 66, weight: {} },
  18. { ssn: "237-23-7739", name: "Tom", height: 62, weight: 130 }
  19. ];
  20. const weightSort = [1, 0, 3, 7, 4, 2];
  21. let request = indexedDB.open(this.window ? window.location.pathname : "Splendid Test", 1);
  22. request.onerror = errorHandler;
  23. request.onupgradeneeded = grabEventAndContinueHandler;
  24. request.onsuccess = grabEventAndContinueHandler;
  25. let event = yield undefined;
  26. is(event.type, "upgradeneeded", "Got upgradeneeded event");
  27. let db = event.target.result;
  28. db.onerror = errorHandler;
  29. let objectStore = db.createObjectStore(osName, { keyPath: "ssn" });
  30. objectStore.createIndex(indexName, "weight", { unique: false });
  31. for (let i of data) {
  32. objectStore.add(i);
  33. }
  34. event = yield undefined;
  35. is(event.type, "success", "Got success event");
  36. try {
  37. IDBKeyRange.bound(1, -1);
  38. ok(false, "Bound keyRange with backwards args should throw!");
  39. }
  40. catch (e) {
  41. is(e.name, "DataError", "Threw correct exception");
  42. is(e.code, 0, "Threw with correct code");
  43. }
  44. try {
  45. IDBKeyRange.bound(1, 1);
  46. ok(true, "Bound keyRange with same arg should be ok");
  47. }
  48. catch (e) {
  49. ok(false, "Bound keyRange with same arg should have been ok");
  50. }
  51. try {
  52. IDBKeyRange.bound(1, 1, true);
  53. ok(false, "Bound keyRange with same arg and open should throw!");
  54. }
  55. catch (e) {
  56. is(e.name, "DataError", "Threw correct exception");
  57. is(e.code, 0, "Threw with correct code");
  58. }
  59. try {
  60. IDBKeyRange.bound(1, 1, true, true);
  61. ok(false, "Bound keyRange with same arg and open should throw!");
  62. }
  63. catch (e) {
  64. is(e.name, "DataError", "Threw correct exception");
  65. is(e.code, 0, "Threw with correct code");
  66. }
  67. objectStore = db.transaction(osName).objectStore(osName);
  68. try {
  69. objectStore.get();
  70. ok(false, "Get with unspecified arg should have thrown");
  71. }
  72. catch(e) {
  73. ok(true, "Get with unspecified arg should have thrown");
  74. }
  75. try {
  76. objectStore.get(undefined);
  77. ok(false, "Get with undefined should have thrown");
  78. }
  79. catch(e) {
  80. ok(true, "Get with undefined arg should have thrown");
  81. }
  82. try {
  83. objectStore.get(null);
  84. ok(false, "Get with null should have thrown");
  85. }
  86. catch(e) {
  87. is(e instanceof DOMException, true,
  88. "Got right kind of exception");
  89. is(e.name, "DataError", "Correct error.");
  90. is(e.code, 0, "Correct code.");
  91. }
  92. objectStore.get(data[2].ssn).onsuccess = grabEventAndContinueHandler;
  93. event = yield undefined;
  94. is(event.target.result.name, data[2].name, "Correct data");
  95. let keyRange = IDBKeyRange.only(data[2].ssn);
  96. objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
  97. event = yield undefined;
  98. is(event.target.result.name, data[2].name, "Correct data");
  99. keyRange = IDBKeyRange.lowerBound(data[2].ssn);
  100. objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
  101. event = yield undefined;
  102. is(event.target.result.name, data[2].name, "Correct data");
  103. keyRange = IDBKeyRange.lowerBound(data[2].ssn, true);
  104. objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
  105. event = yield undefined;
  106. is(event.target.result.name, data[3].name, "Correct data");
  107. keyRange = IDBKeyRange.upperBound(data[2].ssn);
  108. objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
  109. event = yield undefined;
  110. is(event.target.result.name, data[0].name, "Correct data");
  111. keyRange = IDBKeyRange.bound(data[2].ssn, data[4].ssn);
  112. objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
  113. event = yield undefined;
  114. is(event.target.result.name, data[2].name, "Correct data");
  115. keyRange = IDBKeyRange.bound(data[2].ssn, data[4].ssn, true);
  116. objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
  117. event = yield undefined;
  118. is(event.target.result.name, data[3].name, "Correct data");
  119. objectStore = db.transaction(osName, "readwrite")
  120. .objectStore(osName);
  121. try {
  122. objectStore.delete();
  123. ok(false, "Delete with unspecified arg should have thrown");
  124. }
  125. catch(e) {
  126. ok(true, "Delete with unspecified arg should have thrown");
  127. }
  128. try {
  129. objectStore.delete(undefined);
  130. ok(false, "Delete with undefined should have thrown");
  131. }
  132. catch(e) {
  133. ok(true, "Delete with undefined arg should have thrown");
  134. }
  135. try {
  136. objectStore.delete(null);
  137. ok(false, "Delete with null should have thrown");
  138. }
  139. catch(e) {
  140. is(e instanceof DOMException, true,
  141. "Got right kind of exception");
  142. is(e.name, "DataError", "Correct error.");
  143. is(e.code, 0, "Correct code.");
  144. }
  145. objectStore.count().onsuccess = grabEventAndContinueHandler;
  146. event = yield undefined;
  147. is(event.target.result, data.length, "Correct count");
  148. objectStore.delete(data[2].ssn).onsuccess = grabEventAndContinueHandler;
  149. event = yield undefined;
  150. ok(event.target.result === undefined, "Correct result");
  151. objectStore.count().onsuccess = grabEventAndContinueHandler;
  152. event = yield undefined;
  153. is(event.target.result, data.length - 1, "Correct count");
  154. keyRange = IDBKeyRange.bound(data[3].ssn, data[5].ssn);
  155. objectStore.delete(keyRange).onsuccess = grabEventAndContinueHandler;
  156. event = yield undefined;
  157. ok(event.target.result === undefined, "Correct result");
  158. objectStore.count().onsuccess = grabEventAndContinueHandler;
  159. event = yield undefined;
  160. is(event.target.result, data.length - 4, "Correct count");
  161. keyRange = IDBKeyRange.lowerBound(10);
  162. objectStore.delete(keyRange).onsuccess = grabEventAndContinueHandler;
  163. event = yield undefined;
  164. ok(event.target.result === undefined, "Correct result");
  165. objectStore.count().onsuccess = grabEventAndContinueHandler;
  166. event = yield undefined;
  167. is(event.target.result, 0, "Correct count");
  168. event.target.transaction.oncomplete = grabEventAndContinueHandler;
  169. for (let i of data) {
  170. objectStore.add(i);
  171. }
  172. yield undefined;
  173. objectStore = db.transaction(osName).objectStore(osName);
  174. objectStore.count().onsuccess = grabEventAndContinueHandler;
  175. event = yield undefined;
  176. is(event.target.result, data.length, "Correct count");
  177. let count = 0;
  178. objectStore.openCursor().onsuccess = function(event) {
  179. let cursor = event.target.result;
  180. if (cursor) {
  181. count++;
  182. cursor.continue();
  183. }
  184. else {
  185. testGenerator.next();
  186. }
  187. }
  188. yield undefined;
  189. is(count, data.length, "Correct count for no arg to openCursor");
  190. count = 0;
  191. objectStore.openCursor(null).onsuccess = function(event) {
  192. let cursor = event.target.result;
  193. if (cursor) {
  194. count++;
  195. cursor.continue();
  196. }
  197. else {
  198. testGenerator.next();
  199. }
  200. }
  201. yield undefined;
  202. is(count, data.length, "Correct count for null arg to openCursor");
  203. count = 0;
  204. objectStore.openCursor(undefined).onsuccess = function(event) {
  205. let cursor = event.target.result;
  206. if (cursor) {
  207. count++;
  208. cursor.continue();
  209. }
  210. else {
  211. testGenerator.next();
  212. }
  213. }
  214. yield undefined;
  215. is(count, data.length, "Correct count for undefined arg to openCursor");
  216. count = 0;
  217. objectStore.openCursor(data[2].ssn).onsuccess = function(event) {
  218. let cursor = event.target.result;
  219. if (cursor) {
  220. count++;
  221. cursor.continue();
  222. }
  223. else {
  224. testGenerator.next();
  225. }
  226. }
  227. yield undefined;
  228. is(count, 1, "Correct count for single key arg to openCursor");
  229. count = 0;
  230. objectStore.openCursor("foo").onsuccess = function(event) {
  231. let cursor = event.target.result;
  232. if (cursor) {
  233. count++;
  234. cursor.continue();
  235. }
  236. else {
  237. testGenerator.next();
  238. }
  239. }
  240. yield undefined;
  241. is(count, 0,
  242. "Correct count for non-existent single key arg to openCursor");
  243. count = 0;
  244. keyRange = IDBKeyRange.only(data[2].ssn);
  245. objectStore.openCursor(keyRange).onsuccess = function(event) {
  246. let cursor = event.target.result;
  247. if (cursor) {
  248. count++;
  249. cursor.continue();
  250. }
  251. else {
  252. testGenerator.next();
  253. }
  254. }
  255. yield undefined;
  256. is(count, 1, "Correct count for only keyRange arg to openCursor");
  257. count = 0;
  258. keyRange = IDBKeyRange.lowerBound(data[2].ssn);
  259. objectStore.openCursor(keyRange).onsuccess = function(event) {
  260. let cursor = event.target.result;
  261. if (cursor) {
  262. count++;
  263. cursor.continue();
  264. }
  265. else {
  266. testGenerator.next();
  267. }
  268. }
  269. yield undefined;
  270. is(count, data.length - 2,
  271. "Correct count for lowerBound arg to openCursor");
  272. count = 0;
  273. keyRange = IDBKeyRange.lowerBound(data[2].ssn, true);
  274. objectStore.openCursor(keyRange).onsuccess = function(event) {
  275. let cursor = event.target.result;
  276. if (cursor) {
  277. count++;
  278. cursor.continue();
  279. }
  280. else {
  281. testGenerator.next();
  282. }
  283. }
  284. yield undefined;
  285. is(count, data.length - 3,
  286. "Correct count for lowerBound arg to openCursor");
  287. count = 0;
  288. keyRange = IDBKeyRange.lowerBound("foo");
  289. objectStore.openCursor(keyRange).onsuccess = function(event) {
  290. let cursor = event.target.result;
  291. if (cursor) {
  292. count++;
  293. cursor.continue();
  294. }
  295. else {
  296. testGenerator.next();
  297. }
  298. }
  299. yield undefined;
  300. is(count, 0,
  301. "Correct count for non-existent lowerBound arg to openCursor");
  302. count = 0;
  303. keyRange = IDBKeyRange.bound(data[2].ssn, data[3].ssn);
  304. objectStore.openCursor(keyRange).onsuccess = function(event) {
  305. let cursor = event.target.result;
  306. if (cursor) {
  307. count++;
  308. cursor.continue();
  309. }
  310. else {
  311. testGenerator.next();
  312. }
  313. }
  314. yield undefined;
  315. is(count, 2, "Correct count for bound arg to openCursor");
  316. count = 0;
  317. keyRange = IDBKeyRange.bound(data[2].ssn, data[3].ssn, true);
  318. objectStore.openCursor(keyRange).onsuccess = function(event) {
  319. let cursor = event.target.result;
  320. if (cursor) {
  321. count++;
  322. cursor.continue();
  323. }
  324. else {
  325. testGenerator.next();
  326. }
  327. }
  328. yield undefined;
  329. is(count, 1, "Correct count for bound arg to openCursor");
  330. count = 0;
  331. keyRange = IDBKeyRange.bound(data[2].ssn, data[3].ssn, true, true);
  332. objectStore.openCursor(keyRange).onsuccess = function(event) {
  333. let cursor = event.target.result;
  334. if (cursor) {
  335. count++;
  336. cursor.continue();
  337. }
  338. else {
  339. testGenerator.next();
  340. }
  341. }
  342. yield undefined;
  343. is(count, 0, "Correct count for bound arg to openCursor");
  344. let index = objectStore.index(indexName);
  345. count = 0;
  346. index.openKeyCursor().onsuccess = function(event) {
  347. let cursor = event.target.result;
  348. if (cursor) {
  349. count++;
  350. cursor.continue();
  351. }
  352. else {
  353. testGenerator.next();
  354. }
  355. }
  356. yield undefined;
  357. is(count, weightSort.length,
  358. "Correct count for unspecified arg to index.openKeyCursor");
  359. count = 0;
  360. index.openKeyCursor(null).onsuccess = function(event) {
  361. let cursor = event.target.result;
  362. if (cursor) {
  363. count++;
  364. cursor.continue();
  365. }
  366. else {
  367. testGenerator.next();
  368. }
  369. }
  370. yield undefined;
  371. is(count, weightSort.length,
  372. "Correct count for null arg to index.openKeyCursor");
  373. count = 0;
  374. index.openKeyCursor(undefined).onsuccess = function(event) {
  375. let cursor = event.target.result;
  376. if (cursor) {
  377. count++;
  378. cursor.continue();
  379. }
  380. else {
  381. testGenerator.next();
  382. }
  383. }
  384. yield undefined;
  385. is(count, weightSort.length,
  386. "Correct count for undefined arg to index.openKeyCursor");
  387. count = 0;
  388. index.openKeyCursor(data[0].weight).onsuccess = function(event) {
  389. let cursor = event.target.result;
  390. if (cursor) {
  391. count++;
  392. cursor.continue();
  393. }
  394. else {
  395. testGenerator.next();
  396. }
  397. }
  398. yield undefined;
  399. is(count, 1, "Correct count for single key arg to index.openKeyCursor");
  400. count = 0;
  401. index.openKeyCursor("foo").onsuccess = function(event) {
  402. let cursor = event.target.result;
  403. if (cursor) {
  404. count++;
  405. cursor.continue();
  406. }
  407. else {
  408. testGenerator.next();
  409. }
  410. }
  411. yield undefined;
  412. is(count, 0,
  413. "Correct count for non-existent key arg to index.openKeyCursor");
  414. count = 0;
  415. keyRange = IDBKeyRange.only("foo");
  416. index.openKeyCursor(keyRange).onsuccess = function(event) {
  417. let cursor = event.target.result;
  418. if (cursor) {
  419. count++;
  420. cursor.continue();
  421. }
  422. else {
  423. testGenerator.next();
  424. }
  425. }
  426. yield undefined;
  427. is(count, 0,
  428. "Correct count for non-existent keyRange arg to index.openKeyCursor");
  429. count = 0;
  430. keyRange = IDBKeyRange.only(data[0].weight);
  431. index.openKeyCursor(keyRange).onsuccess = function(event) {
  432. let cursor = event.target.result;
  433. if (cursor) {
  434. count++;
  435. cursor.continue();
  436. }
  437. else {
  438. testGenerator.next();
  439. }
  440. }
  441. yield undefined;
  442. is(count, 1,
  443. "Correct count for only keyRange arg to index.openKeyCursor");
  444. count = 0;
  445. keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
  446. index.openKeyCursor(keyRange).onsuccess = function(event) {
  447. let cursor = event.target.result;
  448. if (cursor) {
  449. count++;
  450. cursor.continue();
  451. }
  452. else {
  453. testGenerator.next();
  454. }
  455. }
  456. yield undefined;
  457. is(count, weightSort.length,
  458. "Correct count for lowerBound keyRange arg to index.openKeyCursor");
  459. count = 0;
  460. keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
  461. index.openKeyCursor(keyRange).onsuccess = function(event) {
  462. let cursor = event.target.result;
  463. if (cursor) {
  464. count++;
  465. cursor.continue();
  466. }
  467. else {
  468. testGenerator.next();
  469. }
  470. }
  471. yield undefined;
  472. is(count, weightSort.length - 1,
  473. "Correct count for lowerBound keyRange arg to index.openKeyCursor");
  474. count = 0;
  475. keyRange = IDBKeyRange.lowerBound("foo");
  476. index.openKeyCursor(keyRange).onsuccess = function(event) {
  477. let cursor = event.target.result;
  478. if (cursor) {
  479. count++;
  480. cursor.continue();
  481. }
  482. else {
  483. testGenerator.next();
  484. }
  485. }
  486. yield undefined;
  487. is(count, 0,
  488. "Correct count for lowerBound keyRange arg to index.openKeyCursor");
  489. count = 0;
  490. keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight);
  491. index.openKeyCursor(keyRange).onsuccess = function(event) {
  492. let cursor = event.target.result;
  493. if (cursor) {
  494. count++;
  495. cursor.continue();
  496. }
  497. else {
  498. testGenerator.next();
  499. }
  500. }
  501. yield undefined;
  502. is(count, 1,
  503. "Correct count for upperBound keyRange arg to index.openKeyCursor");
  504. count = 0;
  505. keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
  506. index.openKeyCursor(keyRange).onsuccess = function(event) {
  507. let cursor = event.target.result;
  508. if (cursor) {
  509. count++;
  510. cursor.continue();
  511. }
  512. else {
  513. testGenerator.next();
  514. }
  515. }
  516. yield undefined;
  517. is(count, 0,
  518. "Correct count for upperBound keyRange arg to index.openKeyCursor");
  519. count = 0;
  520. keyRange = IDBKeyRange.upperBound(data[weightSort[weightSort.length - 1]].weight);
  521. index.openKeyCursor(keyRange).onsuccess = function(event) {
  522. let cursor = event.target.result;
  523. if (cursor) {
  524. count++;
  525. cursor.continue();
  526. }
  527. else {
  528. testGenerator.next();
  529. }
  530. }
  531. yield undefined;
  532. is(count, weightSort.length,
  533. "Correct count for upperBound keyRange arg to index.openKeyCursor");
  534. count = 0;
  535. keyRange = IDBKeyRange.upperBound(data[weightSort[weightSort.length - 1]].weight,
  536. true);
  537. index.openKeyCursor(keyRange).onsuccess = function(event) {
  538. let cursor = event.target.result;
  539. if (cursor) {
  540. count++;
  541. cursor.continue();
  542. }
  543. else {
  544. testGenerator.next();
  545. }
  546. }
  547. yield undefined;
  548. is(count, weightSort.length - 1,
  549. "Correct count for upperBound keyRange arg to index.openKeyCursor");
  550. count = 0;
  551. keyRange = IDBKeyRange.upperBound("foo");
  552. index.openKeyCursor(keyRange).onsuccess = function(event) {
  553. let cursor = event.target.result;
  554. if (cursor) {
  555. count++;
  556. cursor.continue();
  557. }
  558. else {
  559. testGenerator.next();
  560. }
  561. }
  562. yield undefined;
  563. is(count, weightSort.length,
  564. "Correct count for upperBound keyRange arg to index.openKeyCursor");
  565. count = 0;
  566. keyRange = IDBKeyRange.upperBound(0);
  567. index.openKeyCursor(keyRange).onsuccess = function(event) {
  568. let cursor = event.target.result;
  569. if (cursor) {
  570. count++;
  571. cursor.continue();
  572. }
  573. else {
  574. testGenerator.next();
  575. }
  576. }
  577. yield undefined;
  578. is(count, 0,
  579. "Correct count for upperBound keyRange arg to index.openKeyCursor");
  580. count = 0;
  581. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  582. data[weightSort[weightSort.length - 1]].weight);
  583. index.openKeyCursor(keyRange).onsuccess = function(event) {
  584. let cursor = event.target.result;
  585. if (cursor) {
  586. count++;
  587. cursor.continue();
  588. }
  589. else {
  590. testGenerator.next();
  591. }
  592. }
  593. yield undefined;
  594. is(count, weightSort.length,
  595. "Correct count for bound keyRange arg to index.openKeyCursor");
  596. count = 0;
  597. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  598. data[weightSort[weightSort.length - 1]].weight,
  599. true);
  600. index.openKeyCursor(keyRange).onsuccess = function(event) {
  601. let cursor = event.target.result;
  602. if (cursor) {
  603. count++;
  604. cursor.continue();
  605. }
  606. else {
  607. testGenerator.next();
  608. }
  609. }
  610. yield undefined;
  611. is(count, weightSort.length - 1,
  612. "Correct count for bound keyRange arg to index.openKeyCursor");
  613. count = 0;
  614. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  615. data[weightSort[weightSort.length - 1]].weight,
  616. true, true);
  617. index.openKeyCursor(keyRange).onsuccess = function(event) {
  618. let cursor = event.target.result;
  619. if (cursor) {
  620. count++;
  621. cursor.continue();
  622. }
  623. else {
  624. testGenerator.next();
  625. }
  626. }
  627. yield undefined;
  628. is(count, weightSort.length - 2,
  629. "Correct count for bound keyRange arg to index.openKeyCursor");
  630. count = 0;
  631. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight - 1,
  632. data[weightSort[weightSort.length - 1]].weight + 1);
  633. index.openKeyCursor(keyRange).onsuccess = function(event) {
  634. let cursor = event.target.result;
  635. if (cursor) {
  636. count++;
  637. cursor.continue();
  638. }
  639. else {
  640. testGenerator.next();
  641. }
  642. }
  643. yield undefined;
  644. is(count, weightSort.length,
  645. "Correct count for bound keyRange arg to index.openKeyCursor");
  646. count = 0;
  647. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight - 2,
  648. data[weightSort[0]].weight - 1);
  649. index.openKeyCursor(keyRange).onsuccess = function(event) {
  650. let cursor = event.target.result;
  651. if (cursor) {
  652. count++;
  653. cursor.continue();
  654. }
  655. else {
  656. testGenerator.next();
  657. }
  658. }
  659. yield undefined;
  660. is(count, 0,
  661. "Correct count for bound keyRange arg to index.openKeyCursor");
  662. count = 0;
  663. keyRange = IDBKeyRange.bound(data[weightSort[1]].weight,
  664. data[weightSort[2]].weight);
  665. index.openKeyCursor(keyRange).onsuccess = function(event) {
  666. let cursor = event.target.result;
  667. if (cursor) {
  668. count++;
  669. cursor.continue();
  670. }
  671. else {
  672. testGenerator.next();
  673. }
  674. }
  675. yield undefined;
  676. is(count, 3,
  677. "Correct count for bound keyRange arg to index.openKeyCursor");
  678. count = 0;
  679. index.openCursor().onsuccess = function(event) {
  680. let cursor = event.target.result;
  681. if (cursor) {
  682. count++;
  683. cursor.continue();
  684. }
  685. else {
  686. testGenerator.next();
  687. }
  688. }
  689. yield undefined;
  690. is(count, weightSort.length,
  691. "Correct count for unspecified arg to index.openCursor");
  692. count = 0;
  693. index.openCursor(null).onsuccess = function(event) {
  694. let cursor = event.target.result;
  695. if (cursor) {
  696. count++;
  697. cursor.continue();
  698. }
  699. else {
  700. testGenerator.next();
  701. }
  702. }
  703. yield undefined;
  704. is(count, weightSort.length,
  705. "Correct count for null arg to index.openCursor");
  706. count = 0;
  707. index.openCursor(undefined).onsuccess = function(event) {
  708. let cursor = event.target.result;
  709. if (cursor) {
  710. count++;
  711. cursor.continue();
  712. }
  713. else {
  714. testGenerator.next();
  715. }
  716. }
  717. yield undefined;
  718. is(count, weightSort.length,
  719. "Correct count for undefined arg to index.openCursor");
  720. count = 0;
  721. index.openCursor(data[0].weight).onsuccess = function(event) {
  722. let cursor = event.target.result;
  723. if (cursor) {
  724. count++;
  725. cursor.continue();
  726. }
  727. else {
  728. testGenerator.next();
  729. }
  730. }
  731. yield undefined;
  732. is(count, 1, "Correct count for single key arg to index.openCursor");
  733. count = 0;
  734. index.openCursor("foo").onsuccess = function(event) {
  735. let cursor = event.target.result;
  736. if (cursor) {
  737. count++;
  738. cursor.continue();
  739. }
  740. else {
  741. testGenerator.next();
  742. }
  743. }
  744. yield undefined;
  745. is(count, 0,
  746. "Correct count for non-existent key arg to index.openCursor");
  747. count = 0;
  748. keyRange = IDBKeyRange.only("foo");
  749. index.openCursor(keyRange).onsuccess = function(event) {
  750. let cursor = event.target.result;
  751. if (cursor) {
  752. count++;
  753. cursor.continue();
  754. }
  755. else {
  756. testGenerator.next();
  757. }
  758. }
  759. yield undefined;
  760. is(count, 0,
  761. "Correct count for non-existent keyRange arg to index.openCursor");
  762. count = 0;
  763. keyRange = IDBKeyRange.only(data[0].weight);
  764. index.openCursor(keyRange).onsuccess = function(event) {
  765. let cursor = event.target.result;
  766. if (cursor) {
  767. count++;
  768. cursor.continue();
  769. }
  770. else {
  771. testGenerator.next();
  772. }
  773. }
  774. yield undefined;
  775. is(count, 1,
  776. "Correct count for only keyRange arg to index.openCursor");
  777. count = 0;
  778. keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
  779. index.openCursor(keyRange).onsuccess = function(event) {
  780. let cursor = event.target.result;
  781. if (cursor) {
  782. count++;
  783. cursor.continue();
  784. }
  785. else {
  786. testGenerator.next();
  787. }
  788. }
  789. yield undefined;
  790. is(count, weightSort.length,
  791. "Correct count for lowerBound keyRange arg to index.openCursor");
  792. count = 0;
  793. keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
  794. index.openCursor(keyRange).onsuccess = function(event) {
  795. let cursor = event.target.result;
  796. if (cursor) {
  797. count++;
  798. cursor.continue();
  799. }
  800. else {
  801. testGenerator.next();
  802. }
  803. }
  804. yield undefined;
  805. is(count, weightSort.length - 1,
  806. "Correct count for lowerBound keyRange arg to index.openCursor");
  807. count = 0;
  808. keyRange = IDBKeyRange.lowerBound("foo");
  809. index.openCursor(keyRange).onsuccess = function(event) {
  810. let cursor = event.target.result;
  811. if (cursor) {
  812. count++;
  813. cursor.continue();
  814. }
  815. else {
  816. testGenerator.next();
  817. }
  818. }
  819. yield undefined;
  820. is(count, 0,
  821. "Correct count for lowerBound keyRange arg to index.openCursor");
  822. count = 0;
  823. keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight);
  824. index.openCursor(keyRange).onsuccess = function(event) {
  825. let cursor = event.target.result;
  826. if (cursor) {
  827. count++;
  828. cursor.continue();
  829. }
  830. else {
  831. testGenerator.next();
  832. }
  833. }
  834. yield undefined;
  835. is(count, 1,
  836. "Correct count for upperBound keyRange arg to index.openCursor");
  837. count = 0;
  838. keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
  839. index.openCursor(keyRange).onsuccess = function(event) {
  840. let cursor = event.target.result;
  841. if (cursor) {
  842. count++;
  843. cursor.continue();
  844. }
  845. else {
  846. testGenerator.next();
  847. }
  848. }
  849. yield undefined;
  850. is(count, 0,
  851. "Correct count for upperBound keyRange arg to index.openCursor");
  852. count = 0;
  853. keyRange = IDBKeyRange.upperBound(data[weightSort[weightSort.length - 1]].weight);
  854. index.openCursor(keyRange).onsuccess = function(event) {
  855. let cursor = event.target.result;
  856. if (cursor) {
  857. count++;
  858. cursor.continue();
  859. }
  860. else {
  861. testGenerator.next();
  862. }
  863. }
  864. yield undefined;
  865. is(count, weightSort.length,
  866. "Correct count for upperBound keyRange arg to index.openCursor");
  867. count = 0;
  868. keyRange = IDBKeyRange.upperBound(data[weightSort[weightSort.length - 1]].weight,
  869. true);
  870. index.openCursor(keyRange).onsuccess = function(event) {
  871. let cursor = event.target.result;
  872. if (cursor) {
  873. count++;
  874. cursor.continue();
  875. }
  876. else {
  877. testGenerator.next();
  878. }
  879. }
  880. yield undefined;
  881. is(count, weightSort.length - 1,
  882. "Correct count for upperBound keyRange arg to index.openCursor");
  883. count = 0;
  884. keyRange = IDBKeyRange.upperBound("foo");
  885. index.openCursor(keyRange).onsuccess = function(event) {
  886. let cursor = event.target.result;
  887. if (cursor) {
  888. count++;
  889. cursor.continue();
  890. }
  891. else {
  892. testGenerator.next();
  893. }
  894. }
  895. yield undefined;
  896. is(count, weightSort.length,
  897. "Correct count for upperBound keyRange arg to index.openCursor");
  898. count = 0;
  899. keyRange = IDBKeyRange.upperBound(0);
  900. index.openCursor(keyRange).onsuccess = function(event) {
  901. let cursor = event.target.result;
  902. if (cursor) {
  903. count++;
  904. cursor.continue();
  905. }
  906. else {
  907. testGenerator.next();
  908. }
  909. }
  910. yield undefined;
  911. is(count, 0,
  912. "Correct count for upperBound keyRange arg to index.openCursor");
  913. count = 0;
  914. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  915. data[weightSort[weightSort.length - 1]].weight);
  916. index.openCursor(keyRange).onsuccess = function(event) {
  917. let cursor = event.target.result;
  918. if (cursor) {
  919. count++;
  920. cursor.continue();
  921. }
  922. else {
  923. testGenerator.next();
  924. }
  925. }
  926. yield undefined;
  927. is(count, weightSort.length,
  928. "Correct count for bound keyRange arg to index.openCursor");
  929. count = 0;
  930. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  931. data[weightSort[weightSort.length - 1]].weight,
  932. true);
  933. index.openCursor(keyRange).onsuccess = function(event) {
  934. let cursor = event.target.result;
  935. if (cursor) {
  936. count++;
  937. cursor.continue();
  938. }
  939. else {
  940. testGenerator.next();
  941. }
  942. }
  943. yield undefined;
  944. is(count, weightSort.length - 1,
  945. "Correct count for bound keyRange arg to index.openCursor");
  946. count = 0;
  947. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  948. data[weightSort[weightSort.length - 1]].weight,
  949. true, true);
  950. index.openCursor(keyRange).onsuccess = function(event) {
  951. let cursor = event.target.result;
  952. if (cursor) {
  953. count++;
  954. cursor.continue();
  955. }
  956. else {
  957. testGenerator.next();
  958. }
  959. }
  960. yield undefined;
  961. is(count, weightSort.length - 2,
  962. "Correct count for bound keyRange arg to index.openCursor");
  963. count = 0;
  964. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight - 1,
  965. data[weightSort[weightSort.length - 1]].weight + 1);
  966. index.openCursor(keyRange).onsuccess = function(event) {
  967. let cursor = event.target.result;
  968. if (cursor) {
  969. count++;
  970. cursor.continue();
  971. }
  972. else {
  973. testGenerator.next();
  974. }
  975. }
  976. yield undefined;
  977. is(count, weightSort.length,
  978. "Correct count for bound keyRange arg to index.openCursor");
  979. count = 0;
  980. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight - 2,
  981. data[weightSort[0]].weight - 1);
  982. index.openCursor(keyRange).onsuccess = function(event) {
  983. let cursor = event.target.result;
  984. if (cursor) {
  985. count++;
  986. cursor.continue();
  987. }
  988. else {
  989. testGenerator.next();
  990. }
  991. }
  992. yield undefined;
  993. is(count, 0,
  994. "Correct count for bound keyRange arg to index.openCursor");
  995. count = 0;
  996. keyRange = IDBKeyRange.bound(data[weightSort[1]].weight,
  997. data[weightSort[2]].weight);
  998. index.openCursor(keyRange).onsuccess = function(event) {
  999. let cursor = event.target.result;
  1000. if (cursor) {
  1001. count++;
  1002. cursor.continue();
  1003. }
  1004. else {
  1005. testGenerator.next();
  1006. }
  1007. }
  1008. yield undefined;
  1009. is(count, 3,
  1010. "Correct count for bound keyRange arg to index.openCursor");
  1011. try {
  1012. index.get();
  1013. ok(false, "Get with unspecified arg should have thrown");
  1014. }
  1015. catch(e) {
  1016. ok(true, "Get with unspecified arg should have thrown");
  1017. }
  1018. try {
  1019. index.get(undefined);
  1020. ok(false, "Get with undefined should have thrown");
  1021. }
  1022. catch(e) {
  1023. ok(true, "Get with undefined arg should have thrown");
  1024. }
  1025. try {
  1026. index.get(null);
  1027. ok(false, "Get with null should have thrown");
  1028. }
  1029. catch(e) {
  1030. is(e instanceof DOMException, true,
  1031. "Got right kind of exception");
  1032. is(e.name, "DataError", "Correct error.");
  1033. is(e.code, 0, "Correct code.");
  1034. }
  1035. index.get(data[0].weight).onsuccess = grabEventAndContinueHandler;
  1036. event = yield undefined;
  1037. is(event.target.result.weight, data[0].weight, "Got correct result");
  1038. keyRange = IDBKeyRange.only(data[0].weight);
  1039. index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1040. event = yield undefined;
  1041. is(event.target.result.weight, data[0].weight, "Got correct result");
  1042. keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
  1043. index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1044. event = yield undefined;
  1045. is(event.target.result.weight, data[weightSort[0]].weight,
  1046. "Got correct result");
  1047. keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight - 1);
  1048. index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1049. event = yield undefined;
  1050. is(event.target.result.weight, data[weightSort[0]].weight,
  1051. "Got correct result");
  1052. keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight + 1);
  1053. index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1054. event = yield undefined;
  1055. is(event.target.result.weight, data[weightSort[1]].weight,
  1056. "Got correct result");
  1057. keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
  1058. index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1059. event = yield undefined;
  1060. is(event.target.result.weight, data[weightSort[1]].weight,
  1061. "Got correct result");
  1062. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1063. data[weightSort[1]].weight);
  1064. index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1065. event = yield undefined;
  1066. is(event.target.result.weight, data[weightSort[0]].weight,
  1067. "Got correct result");
  1068. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1069. data[weightSort[1]].weight, true);
  1070. index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1071. event = yield undefined;
  1072. is(event.target.result.weight, data[weightSort[1]].weight,
  1073. "Got correct result");
  1074. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1075. data[weightSort[1]].weight, true, true);
  1076. index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1077. event = yield undefined;
  1078. is(event.target.result, undefined, "Got correct result");
  1079. keyRange = IDBKeyRange.upperBound(data[weightSort[5]].weight);
  1080. index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1081. event = yield undefined;
  1082. is(event.target.result.weight, data[weightSort[0]].weight,
  1083. "Got correct result");
  1084. keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
  1085. index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1086. event = yield undefined;
  1087. is(event.target.result, undefined, "Got correct result");
  1088. try {
  1089. index.getKey();
  1090. ok(false, "Get with unspecified arg should have thrown");
  1091. }
  1092. catch(e) {
  1093. ok(true, "Get with unspecified arg should have thrown");
  1094. }
  1095. try {
  1096. index.getKey(undefined);
  1097. ok(false, "Get with undefined should have thrown");
  1098. }
  1099. catch(e) {
  1100. ok(true, "Get with undefined arg should have thrown");
  1101. }
  1102. try {
  1103. index.getKey(null);
  1104. ok(false, "Get with null should have thrown");
  1105. }
  1106. catch(e) {
  1107. is(e instanceof DOMException, true,
  1108. "Got right kind of exception");
  1109. is(e.name, "DataError", "Correct error.");
  1110. is(e.code, 0, "Correct code.");
  1111. }
  1112. index.getKey(data[0].weight).onsuccess = grabEventAndContinueHandler;
  1113. event = yield undefined;
  1114. is(event.target.result, data[0].ssn, "Got correct result");
  1115. keyRange = IDBKeyRange.only(data[0].weight);
  1116. index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1117. event = yield undefined;
  1118. is(event.target.result, data[0].ssn, "Got correct result");
  1119. keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
  1120. index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1121. event = yield undefined;
  1122. is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
  1123. keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight - 1);
  1124. index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1125. event = yield undefined;
  1126. is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
  1127. keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight + 1);
  1128. index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1129. event = yield undefined;
  1130. is(event.target.result, data[weightSort[1]].ssn, "Got correct result");
  1131. keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
  1132. index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1133. event = yield undefined;
  1134. is(event.target.result, data[weightSort[1]].ssn, "Got correct result");
  1135. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1136. data[weightSort[1]].weight);
  1137. index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1138. event = yield undefined;
  1139. is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
  1140. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1141. data[weightSort[1]].weight, true);
  1142. index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1143. event = yield undefined;
  1144. is(event.target.result, data[weightSort[1]].ssn, "Got correct result");
  1145. keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1146. data[weightSort[1]].weight, true, true);
  1147. index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1148. event = yield undefined;
  1149. is(event.target.result, undefined, "Got correct result");
  1150. keyRange = IDBKeyRange.upperBound(data[weightSort[5]].weight);
  1151. index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1152. event = yield undefined;
  1153. is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
  1154. keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
  1155. index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1156. event = yield undefined;
  1157. is(event.target.result, undefined, "Got correct result");
  1158. count = 0;
  1159. index.openKeyCursor().onsuccess = function(event) {
  1160. let cursor = event.target.result;
  1161. if (cursor) {
  1162. count++;
  1163. cursor.continue();
  1164. }
  1165. else {
  1166. testGenerator.next();
  1167. }
  1168. }
  1169. yield undefined;
  1170. is(count, weightSort.length,
  1171. "Correct count for no arg to index.openKeyCursor");
  1172. count = 0;
  1173. index.openKeyCursor(null).onsuccess = function(event) {
  1174. let cursor = event.target.result;
  1175. if (cursor) {
  1176. count++;
  1177. cursor.continue();
  1178. }
  1179. else {
  1180. testGenerator.next();
  1181. }
  1182. }
  1183. yield undefined;
  1184. is(count, weightSort.length,
  1185. "Correct count for null arg to index.openKeyCursor");
  1186. count = 0;
  1187. index.openKeyCursor(undefined).onsuccess = function(event) {
  1188. let cursor = event.target.result;
  1189. if (cursor) {
  1190. count++;
  1191. cursor.continue();
  1192. }
  1193. else {
  1194. testGenerator.next();
  1195. }
  1196. }
  1197. yield undefined;
  1198. is(count, weightSort.length,
  1199. "Correct count for undefined arg to index.openKeyCursor");
  1200. count = 0;
  1201. index.openKeyCursor(data[weightSort[0]].weight).onsuccess = function(event) {
  1202. let cursor = event.target.result;
  1203. if (cursor) {
  1204. count++;
  1205. cursor.continue();
  1206. }
  1207. else {
  1208. testGenerator.next();
  1209. }
  1210. }
  1211. yield undefined;
  1212. is(count, 1, "Correct count for single key arg to index.openKeyCursor");
  1213. count = 0;
  1214. index.openKeyCursor("foo").onsuccess = function(event) {
  1215. let cursor = event.target.result;
  1216. if (cursor) {
  1217. count++;
  1218. cursor.continue();
  1219. }
  1220. else {
  1221. testGenerator.next();
  1222. }
  1223. }
  1224. yield undefined;
  1225. is(count, 0,
  1226. "Correct count for non-existent single key arg to index.openKeyCursor");
  1227. count = 0;
  1228. keyRange = IDBKeyRange.only(data[weightSort[0]].weight);
  1229. index.openKeyCursor(keyRange).onsuccess = function(event) {
  1230. let cursor = event.target.result;
  1231. if (cursor) {
  1232. count++;
  1233. cursor.continue();
  1234. }
  1235. else {
  1236. testGenerator.next();
  1237. }
  1238. }
  1239. yield undefined;
  1240. is(count, 1,
  1241. "Correct count for only keyRange arg to index.openKeyCursor");
  1242. objectStore.mozGetAll(data[1].ssn).onsuccess = grabEventAndContinueHandler;
  1243. event = yield undefined;
  1244. is(event.target.result instanceof Array, true, "Got an array");
  1245. is(event.target.result.length, 1, "Got correct length");
  1246. is(event.target.result[0].ssn, data[1].ssn, "Got correct result");
  1247. objectStore.mozGetAll(null).onsuccess = grabEventAndContinueHandler;
  1248. event = yield undefined;
  1249. is(event.target.result instanceof Array, true, "Got an array");
  1250. is(event.target.result.length, data.length, "Got correct length");
  1251. for (let i in event.target.result) {
  1252. is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
  1253. }
  1254. objectStore.mozGetAll(undefined).onsuccess = grabEventAndContinueHandler;
  1255. event = yield undefined;
  1256. is(event.target.result instanceof Array, true, "Got an array");
  1257. is(event.target.result.length, data.length, "Got correct length");
  1258. for (let i in event.target.result) {
  1259. is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
  1260. }
  1261. objectStore.mozGetAll().onsuccess = grabEventAndContinueHandler;
  1262. event = yield undefined;
  1263. is(event.target.result instanceof Array, true, "Got an array");
  1264. is(event.target.result.length, data.length, "Got correct length");
  1265. for (let i in event.target.result) {
  1266. is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
  1267. }
  1268. keyRange = IDBKeyRange.lowerBound(0);
  1269. objectStore.mozGetAll(keyRange).onsuccess = grabEventAndContinueHandler;
  1270. event = yield undefined;
  1271. is(event.target.result instanceof Array, true, "Got an array");
  1272. is(event.target.result.length, data.length, "Got correct length");
  1273. for (let i in event.target.result) {
  1274. is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
  1275. }
  1276. index.mozGetAll().onsuccess = grabEventAndContinueHandler;
  1277. event = yield undefined;
  1278. is(event.target.result instanceof Array, true, "Got an array");
  1279. is(event.target.result.length, weightSort.length, "Got correct length");
  1280. for (let i in event.target.result) {
  1281. is(event.target.result[i].ssn, data[weightSort[i]].ssn,
  1282. "Got correct value");
  1283. }
  1284. index.mozGetAll(undefined).onsuccess = grabEventAndContinueHandler;
  1285. event = yield undefined;
  1286. is(event.target.result instanceof Array, true, "Got an array");
  1287. is(event.target.result.length, weightSort.length, "Got correct length");
  1288. for (let i in event.target.result) {
  1289. is(event.target.result[i].ssn, data[weightSort[i]].ssn,
  1290. "Got correct value");
  1291. }
  1292. index.mozGetAll(null).onsuccess = grabEventAndContinueHandler;
  1293. event = yield undefined;
  1294. is(event.target.result instanceof Array, true, "Got an array");
  1295. is(event.target.result.length, weightSort.length, "Got correct length");
  1296. for (let i in event.target.result) {
  1297. is(event.target.result[i].ssn, data[weightSort[i]].ssn,
  1298. "Got correct value");
  1299. }
  1300. index.mozGetAll(data[weightSort[0]].weight).onsuccess = grabEventAndContinueHandler;
  1301. event = yield undefined;
  1302. is(event.target.result instanceof Array, true, "Got an array");
  1303. is(event.target.result.length, 1, "Got correct length");
  1304. is(event.target.result[0].ssn, data[weightSort[0]].ssn, "Got correct result");
  1305. keyRange = IDBKeyRange.lowerBound(0);
  1306. index.mozGetAll(keyRange).onsuccess = grabEventAndContinueHandler;
  1307. event = yield undefined;
  1308. is(event.target.result instanceof Array, true, "Got an array");
  1309. is(event.target.result.length, weightSort.length, "Got correct length");
  1310. for (let i in event.target.result) {
  1311. is(event.target.result[i].ssn, data[weightSort[i]].ssn,
  1312. "Got correct value");
  1313. }
  1314. index.mozGetAllKeys().onsuccess = grabEventAndContinueHandler;
  1315. event = yield undefined;
  1316. is(event.target.result instanceof Array, true, "Got an array");
  1317. is(event.target.result.length, weightSort.length, "Got correct length");
  1318. for (let i in event.target.result) {
  1319. is(event.target.result[i], data[weightSort[i]].ssn,
  1320. "Got correct value");
  1321. }
  1322. index.mozGetAllKeys(undefined).onsuccess = grabEventAndContinueHandler;
  1323. event = yield undefined;
  1324. is(event.target.result instanceof Array, true, "Got an array");
  1325. is(event.target.result.length, weightSort.length, "Got correct length");
  1326. for (let i in event.target.result) {
  1327. is(event.target.result[i], data[weightSort[i]].ssn,
  1328. "Got correct value");
  1329. }
  1330. index.mozGetAllKeys(null).onsuccess = grabEventAndContinueHandler;
  1331. event = yield undefined;
  1332. is(event.target.result instanceof Array, true, "Got an array");
  1333. is(event.target.result.length, weightSort.length, "Got correct length");
  1334. for (let i in event.target.result) {
  1335. is(event.target.result[i], data[weightSort[i]].ssn,
  1336. "Got correct value");
  1337. }
  1338. index.mozGetAllKeys(data[weightSort[0]].weight).onsuccess = grabEventAndContinueHandler;
  1339. event = yield undefined;
  1340. is(event.target.result instanceof Array, true, "Got an array");
  1341. is(event.target.result.length, 1, "Got correct length");
  1342. is(event.target.result[0], data[weightSort[0]].ssn, "Got correct result");
  1343. keyRange = IDBKeyRange.lowerBound(0);
  1344. index.mozGetAllKeys(keyRange).onsuccess = grabEventAndContinueHandler;
  1345. event = yield undefined;
  1346. is(event.target.result instanceof Array, true, "Got an array");
  1347. is(event.target.result.length, weightSort.length, "Got correct length");
  1348. for (let i in event.target.result) {
  1349. is(event.target.result[i], data[weightSort[i]].ssn,
  1350. "Got correct value");
  1351. }
  1352. finishTest();
  1353. yield undefined;
  1354. }