summaryrefslogtreecommitdiffstats
path: root/dom/indexedDB/test/unit/test_traffic_jam.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/indexedDB/test/unit/test_traffic_jam.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/indexedDB/test/unit/test_traffic_jam.js')
-rw-r--r--dom/indexedDB/test/unit/test_traffic_jam.js87
1 files changed, 87 insertions, 0 deletions
diff --git a/dom/indexedDB/test/unit/test_traffic_jam.js b/dom/indexedDB/test/unit/test_traffic_jam.js
new file mode 100644
index 000000000..f09985b13
--- /dev/null
+++ b/dom/indexedDB/test/unit/test_traffic_jam.js
@@ -0,0 +1,87 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+var testGenerator = testSteps();
+
+function testSteps()
+{
+ const name = this.window ? window.location.pathname : "Splendid Test";
+
+ let requests = [];
+ function doOpen(version, errorCallback, upgradeNeededCallback, successCallback) {
+ let request = indexedDB.open(name, version);
+ request.onerror = errorCallback;
+ request.onupgradeneeded = upgradeNeededCallback;
+ request.onsuccess = successCallback;
+ requests.push(request);
+ }
+
+ doOpen(1, errorHandler, grabEventAndContinueHandler, grabEventAndContinueHandler);
+ doOpen(2, errorHandler, unexpectedSuccessHandler, unexpectedSuccessHandler);
+
+ let event = yield undefined;
+ is(event.type, "upgradeneeded", "expect an upgradeneeded event");
+ is(event.target, requests[0], "fired at the right request");
+
+ let db = event.target.result;
+ db.createObjectStore("foo");
+
+ doOpen(3, errorHandler, unexpectedSuccessHandler, unexpectedSuccessHandler);
+ doOpen(2, errorHandler, unexpectedSuccessHandler, unexpectedSuccessHandler);
+ doOpen(3, errorHandler, unexpectedSuccessHandler, unexpectedSuccessHandler);
+
+ event.target.transaction.oncomplete = grabEventAndContinueHandler;
+
+ event = yield undefined;
+ is(event.type, "complete", "expect a complete event");
+ is(event.target, requests[0].transaction, "expect it to be fired at the transaction");
+
+ event = yield undefined;
+ is(event.type, "success", "expect a success event");
+ is(event.target, requests[0], "fired at the right request");
+ event.target.result.close();
+
+ requests[1].onupgradeneeded = grabEventAndContinueHandler;
+
+ event = yield undefined;
+ is(event.type, "upgradeneeded", "expect an upgradeneeded event");
+ is(event.target, requests[1], "fired at the right request");
+
+ requests[1].onsuccess = grabEventAndContinueHandler;
+
+ event = yield undefined;
+ is(event.type, "success", "expect a success event");
+ is(event.target, requests[1], "fired at the right request");
+ event.target.result.close();
+
+ requests[2].onupgradeneeded = grabEventAndContinueHandler;
+
+ event = yield undefined;
+ is(event.type, "upgradeneeded", "expect an upgradeneeded event");
+ is(event.target, requests[2], "fired at the right request");
+
+ requests[2].onsuccess = grabEventAndContinueHandler;
+
+ event = yield undefined;
+ is(event.type, "success", "expect a success event");
+ is(event.target, requests[2], "fired at the right request");
+ event.target.result.close();
+
+ requests[3].onerror = null;
+ requests[3].addEventListener("error", new ExpectError("VersionError", true));
+
+ event = yield undefined;
+
+ requests[4].onsuccess = grabEventAndContinueHandler;
+
+ event = yield undefined;
+ is(event.type, "success", "expect a success event");
+ is(event.target, requests[4], "fired at the right request");
+ event.target.result.close();
+
+ finishTest();
+ yield undefined;
+}
+