Bug 1816170 - Disable perftest-on-autoland cron. r=aglavic
[gecko.git] / dom / indexedDB / test / unit / test_readwriteflush_disabled.js
blob6271959346204aa77e2f3d36ec05d93365ade8c1
1 /**
2  * Any copyright is dedicated to the Public Domain.
3  * http://creativecommons.org/publicdomain/zero/1.0/
4  */
6 /* exported testGenerator, disableWorkerTest */
7 var disableWorkerTest = "Need a way to set temporary prefs from a worker";
9 var testGenerator = testSteps();
11 function* testSteps() {
12   const name = this.window
13     ? window.location.pathname
14     : "test_readwriteflush_disabled.js";
16   info("Resetting experimental pref");
18   if (this.window) {
19     SpecialPowers.pushPrefEnv(
20       {
21         set: [["dom.indexedDB.experimental", false]],
22       },
23       continueToNextStep
24     );
25     yield undefined;
26   } else {
27     resetExperimental();
28   }
30   info("Opening database");
32   let request = indexedDB.open(name);
33   request.onerror = errorHandler;
34   request.onupgradeneeded = continueToNextStepSync;
35   request.onsuccess = unexpectedSuccessHandler;
37   yield undefined;
39   // upgradeneeded
40   request.onupgradeneeded = unexpectedSuccessHandler;
41   request.onsuccess = continueToNextStepSync;
43   info("Creating objectStore");
45   request.result.createObjectStore(name);
47   yield undefined;
49   // success
50   let db = request.result;
52   info("Attempting to create a 'readwriteflush' transaction");
54   let exception;
56   try {
57     db.transaction(name, "readwriteflush");
58   } catch (e) {
59     exception = e;
60   }
62   ok(exception, "'readwriteflush' transaction threw");
63   ok(exception instanceof Error, "exception is an Error object");
64   is(
65     exception.message,
66     "IDBDatabase.transaction: 'readwriteflush' (value of argument 2) is not " +
67       "a valid value for enumeration IDBTransactionMode.",
68     "exception has the correct message"
69   );
71   finishTest();