testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex6-event_order.htm
author Brindusan Cristian <cbrindusan@mozilla.com>
Tue, 20 Nov 2018 20:37:05 +0200
changeset 503769 46ad93280b0678c2bf9db3c3f8dcd3613b0ec9ab
parent 503718 b6ebdb6e8bf9fa6f2a4ba36e7c6a3dd67feda3e9
child 503973 3354122584d671840a0710dc7cd84aaa100a5bf0
permissions -rw-r--r--
Backed out 53 changesets (bug 1505878, bug 1507080, bug 1505638, bug 1507345, bug 1507122, bug 1507341, bug 1506769, bug 1497436, bug 1507796, bug 1506775, bug 1506697, bug 1507089, bug 1507908, bug 1504801, bug 1507063, bug 1507917, bug 1506089, bug 1506919, bug 1507805, bug 1507374, bug 1507421, bug 1507426, bug 1506886, bug 1488424, bug 1507558, bug 1507600, bug 1507977, bug 1507549, bug 1507526, bug 1507064, bug 1507586, bug 1508031, bug 1507472, bug 1507239, bug 1507250, bug 1507532, bug 1507519, bug 1508354, bug 1507660, bug 1506716, bug 1508014, bug 1506994) for wpt failures on grid-container-scrollbar-vertical-lr-001.html. CLOSED TREE Backed out changeset 584f730e1865 (bug 1508354) Backed out changeset 3bdcf979b1a2 (bug 1507532) Backed out changeset f36221255331 (bug 1506769) Backed out changeset d8ba2f11effc (bug 1506769) Backed out changeset c4430fdd1d22 (bug 1508031) Backed out changeset b4d49ed8873e (bug 1507796) Backed out changeset f380f6a8f5c0 (bug 1508014) Backed out changeset d94695f27915 (bug 1507421) Backed out changeset 2b4e8d165519 (bug 1505638) Backed out changeset a96795d1de3f (bug 1505638) Backed out changeset 6e08180c8ba3 (bug 1507977) Backed out changeset e758e29e8a1a (bug 1507908) Backed out changeset 380cb8a671e9 (bug 1507917) Backed out changeset 77f172246b2d (bug 1507519) Backed out changeset 61abe5c39ab5 (bug 1504801) Backed out changeset c750807ac5c4 (bug 1504801) Backed out changeset b49e6067e4bc (bug 1507472) Backed out changeset bb03633ea79a (bug 1507472) Backed out changeset f73f87484839 (bug 1507805) Backed out changeset ab97e60ed777 (bug 1507586) Backed out changeset d4129dccff17 (bug 1506089) Backed out changeset bcb5a5eebc6c (bug 1488424) Backed out changeset d76dc6e3bbaa (bug 1507064) Backed out changeset 30d8f48aab99 (bug 1507080) Backed out changeset e6d88d9f73af (bug 1507080) Backed out changeset ee38ad38e9a1 (bug 1507549) Backed out changeset 0b2f80185614 (bug 1506919) Backed out changeset 0143d49ed65b (bug 1507660) Backed out changeset 2c739b93be1e (bug 1506716) Backed out changeset 0a4f3d45b0c5 (bug 1506716) Backed out changeset 81e2dcf84fb1 (bug 1506886) Backed out changeset 22f64d38d9c8 (bug 1505878) Backed out changeset 0475d6073c30 (bug 1505878) Backed out changeset 956ed95b791e (bug 1507374) Backed out changeset ac8170415338 (bug 1507600) Backed out changeset d7e0ada61934 (bug 1507345) Backed out changeset 6a730fb5a7e4 (bug 1507250) Backed out changeset 1e351d1c2022 (bug 1507250) Backed out changeset 031385cb5558 (bug 1507239) Backed out changeset 2fa696969cc2 (bug 1507239) Backed out changeset 9d55c7b68552 (bug 1507558) Backed out changeset 7385eaebb8e9 (bug 1507526) Backed out changeset d2ac36f03ef5 (bug 1506775) Backed out changeset b6ebdb6e8bf9 (bug 1507426) Backed out changeset 29ca75ba2433 (bug 1507341) Backed out changeset b5aa3737ca29 (bug 1497436) Backed out changeset f3cb0265f0c1 (bug 1497436) Backed out changeset f3f2d714b4eb (bug 1506994) Backed out changeset aa35cce4fb76 (bug 1507089) Backed out changeset 43cfc59879d2 (bug 1507089) Backed out changeset 8e13752959d6 (bug 1507122) Backed out changeset dfbc81d5e518 (bug 1507063) Backed out changeset 378d0c633eae (bug 1506697)

<!DOCTYPE html>
<meta charset=utf-8>
<title>IDBObjectStore.createIndex() - event order when unique constraint is triggered</title>
<link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
<meta rel=help href=http://odinho.html5.org/IndexedDB/spec/Overview.html#widl-IDBObjectStore-createIndex-IDBIndex-DOMString-name-any-keyPath-IDBIndexParameters-optionalParameters>
<meta rel=assert title="The index that is requested to be created can contain constraints on the data allowed in the index's referenced object store, such as requiring uniqueness of the values referenced by the index's keyPath. If the referenced object store already contains data which violates these constraints, this must not cause the implementation of createIndex to throw an exception or affect what it returns. The implementation must still create and return an IDBIndex object. Instead the implementation must queue up an operation to abort the 'versionchange' transaction which was used for the createIndex call.">
<meta rel=assert title="In some implementations it's possible for the implementation to asynchronously run into problems creating the index after the createIndex function has returned. For example in implementations where metadata about the newly created index is queued up to be inserted into the database asynchronously, or where the implementation might need to ask the user for permission for quota reasons. Such implementations must still create and return an IDBIndex object. Instead, once the implementation realizes that creating the index has failed, it must abort the transaction using the steps for aborting a transaction using the appropriate error as error parameter.">
<meta rel=assert title="if the index can't be created due to unique constraints, ConstraintError must be used as error">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=support.js></script>

<script>
    // Transaction may fire window.onerror in some implementations.
    setup({allow_uncaught_exception:true});

    var db,
      events = [],
      t = async_test(document.title, {timeout: 10000})

    var open_rq = createdb(t);
    open_rq.onupgradeneeded = function(e) {
        db = e.target.result;
        db.onerror = log("db.error");
        db.onabort = log("db.abort");
        e.target.transaction.onabort = log("transaction.abort")
        e.target.transaction.onerror = log("transaction.error")
        e.target.transaction.oncomplete = log("transaction.complete")

        var txn = e.target.transaction,
          objStore = db.createObjectStore("store");

        var rq_add1 = objStore.add({ animal: "Unicorn" }, 1);
        rq_add1.onsuccess = log("rq_add1.success");
        rq_add1.onerror   = log("rq_add1.error");

        var rq_add2 = objStore.add({ animal: "Unicorn" }, 2);
        rq_add2.onsuccess = log("rq_add2.success");
        rq_add2.onerror   = log("rq_add2.error");

        objStore.createIndex("index", "animal", { unique: true })

        var rq_add3 = objStore.add({ animal: "Unicorn" }, 3);
        rq_add3.onsuccess = log("rq_add3.success");
        rq_add3.onerror   = log("rq_add3.error");
    }

    open_rq.onerror = function(e) {
        log("open_rq.error")(e);
        assert_array_equals(events, [ "rq_add1.success",
                                      "rq_add2.success",

                                      "rq_add3.error: AbortError",
                                      "transaction.error: AbortError",
                                      "db.error: AbortError",

                                      "transaction.abort: ConstraintError",
                                      "db.abort: ConstraintError",

                                      "open_rq.error: AbortError" ],
                            "events");
        t.done();
    }

    function log(msg) {
        return function(e) {
            if(e && e.target && e.target.error)
                events.push(msg + ": " + e.target.error.name);
            else
                events.push(msg);
        };
    }
</script>

<div id=log></div>