test_filehandle_lifetimes.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!--
  2. Any copyright is dedicated to the Public Domain.
  3. http://creativecommons.org/publicdomain/zero/1.0/
  4. -->
  5. <html>
  6. <head>
  7. <title>File Handle Test</title>
  8. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  10. <script type="text/javascript;version=1.7">
  11. function testSteps()
  12. {
  13. const name = window.location.pathname;
  14. let request = indexedDB.open(name, 1);
  15. request.onerror = errorHandler;
  16. request.onsuccess = grabEventAndContinueHandler;
  17. let event = yield undefined;
  18. let db = event.target.result;
  19. db.onerror = errorHandler;
  20. request = db.createMutableFile("test.txt");
  21. request.onerror = errorHandler;
  22. request.onsuccess = grabEventAndContinueHandler;
  23. event = yield undefined;
  24. let mutableFile = event.target.result;
  25. mutableFile.onerror = errorHandler;
  26. let fileHandle = mutableFile.open();
  27. continueToNextStep();
  28. yield undefined;
  29. try {
  30. fileHandle.getMetadata({ size: true });
  31. ok(false, "Should have thrown!");
  32. }
  33. catch (e) {
  34. ok(e instanceof DOMException, "Got exception.");
  35. is(e.name, "FileHandleInactiveError", "Good error.");
  36. is(e.code, 0, "Good error code.");
  37. }
  38. finishTest();
  39. yield undefined;
  40. }
  41. </script>
  42. <script type="text/javascript;version=1.7" src="helpers.js"></script>
  43. </head>
  44. <body onload="runTest();"></body>
  45. </html>