test_readwriteflush_disabled.js (1659B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 6 /* exported testGenerator, disableWorkerTest */ 7 var disableWorkerTest = "Need a way to set temporary prefs from a worker"; 8 9 var testGenerator = testSteps(); 10 11 function* testSteps() { 12 const name = this.window 13 ? window.location.pathname 14 : "test_readwriteflush_disabled.js"; 15 16 info("Resetting experimental pref"); 17 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 } 29 30 info("Opening database"); 31 32 let request = indexedDB.open(name); 33 request.onerror = errorHandler; 34 request.onupgradeneeded = continueToNextStepSync; 35 request.onsuccess = unexpectedSuccessHandler; 36 37 yield undefined; 38 39 // upgradeneeded 40 request.onupgradeneeded = unexpectedSuccessHandler; 41 request.onsuccess = continueToNextStepSync; 42 43 info("Creating objectStore"); 44 45 request.result.createObjectStore(name); 46 47 yield undefined; 48 49 // success 50 let db = request.result; 51 52 info("Attempting to create a 'readwriteflush' transaction"); 53 54 let exception; 55 56 try { 57 db.transaction(name, "readwriteflush"); 58 } catch (e) { 59 exception = e; 60 } 61 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 ); 70 71 finishTest(); 72 }