test_readwriteflush_disabled.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/
  4. */
  5. var disableWorkerTest = "Need a way to set temporary prefs from a worker";
  6. var testGenerator = testSteps();
  7. function testSteps()
  8. {
  9. const name =
  10. this.window ? window.location.pathname : "test_readwriteflush_disabled.js";
  11. info("Resetting experimental pref");
  12. if (this.window) {
  13. SpecialPowers.pushPrefEnv(
  14. {
  15. "set": [
  16. ["dom.indexedDB.experimental", false]
  17. ]
  18. },
  19. continueToNextStep
  20. );
  21. yield undefined;
  22. } else {
  23. resetExperimental();
  24. }
  25. info("Opening database");
  26. let request = indexedDB.open(name);
  27. request.onerror = errorHandler;
  28. request.onupgradeneeded = continueToNextStepSync;
  29. request.onsuccess = unexpectedSuccessHandler;
  30. yield undefined;
  31. // upgradeneeded
  32. request.onupgradeneeded = unexpectedSuccessHandler;
  33. request.onsuccess = continueToNextStepSync;
  34. info("Creating objectStore");
  35. request.result.createObjectStore(name);
  36. yield undefined;
  37. // success
  38. let db = request.result;
  39. info("Attempting to create a 'readwriteflush' transaction");
  40. let exception;
  41. try {
  42. let transaction = db.transaction(name, "readwriteflush");
  43. } catch (e) {
  44. exception = e;
  45. }
  46. ok(exception, "'readwriteflush' transaction threw");
  47. ok(exception instanceof Error, "exception is an Error object");
  48. is(exception.message,
  49. "Argument 2 of IDBDatabase.transaction 'readwriteflush' is not a valid " +
  50. "value for enumeration IDBTransactionMode.",
  51. "exception has the correct message");
  52. finishTest();
  53. yield undefined;
  54. }