dom/indexedDB/test/unit/test_object_identity.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /**
michael@0 2 * Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 4 */
michael@0 5
michael@0 6 var testGenerator = testSteps();
michael@0 7
michael@0 8 function testSteps()
michael@0 9 {
michael@0 10 let request = indexedDB.open(this.window ? window.location.pathname : "Splendid Test", 1);
michael@0 11 request.onerror = errorHandler;
michael@0 12 request.onupgradeneeded = grabEventAndContinueHandler;
michael@0 13 let event = yield undefined;
michael@0 14
michael@0 15 let db = event.target.result;
michael@0 16 let transaction = event.target.transaction;
michael@0 17
michael@0 18 let objectStore1 = db.createObjectStore("foo");
michael@0 19 let objectStore2 = transaction.objectStore("foo");
michael@0 20 ok(objectStore1 === objectStore2, "Got same objectStores");
michael@0 21
michael@0 22 let index1 = objectStore1.createIndex("bar", "key");
michael@0 23 let index2 = objectStore2.index("bar");
michael@0 24 ok(index1 === index2, "Got same indexes");
michael@0 25
michael@0 26 request.onsuccess = continueToNextStep;
michael@0 27 yield undefined;
michael@0 28
michael@0 29 transaction = db.transaction(db.objectStoreNames);
michael@0 30
michael@0 31 let objectStore3 = transaction.objectStore("foo");
michael@0 32 let objectStore4 = transaction.objectStore("foo");
michael@0 33 ok(objectStore3 === objectStore4, "Got same objectStores");
michael@0 34
michael@0 35 ok(objectStore3 !== objectStore1, "Different objectStores");
michael@0 36 ok(objectStore4 !== objectStore2, "Different objectStores");
michael@0 37
michael@0 38 let index3 = objectStore3.index("bar");
michael@0 39 let index4 = objectStore4.index("bar");
michael@0 40 ok(index3 === index4, "Got same indexes");
michael@0 41
michael@0 42 ok(index3 !== index1, "Different indexes");
michael@0 43 ok(index4 !== index2, "Different indexes");
michael@0 44
michael@0 45 finishTest();
michael@0 46 yield undefined;
michael@0 47 }
michael@0 48

mercurial