test_filehandle_request_readyState.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. is(request.readyState, "pending", "Correct readyState");
  16. request.onerror = errorHandler;
  17. request.onsuccess = grabEventAndContinueHandler;
  18. let event = yield undefined;
  19. is(request.readyState, "done", "Correct readyState");
  20. let db = event.target.result;
  21. db.onerror = errorHandler;
  22. request = db.createMutableFile("test.txt");
  23. is(request.readyState, "pending", "Correct readyState");
  24. request.onerror = errorHandler;
  25. request.onsuccess = grabEventAndContinueHandler;
  26. event = yield undefined;
  27. is(request.readyState, "done", "Correct readyState");
  28. let mutableFile = event.target.result;
  29. mutableFile.onerror = errorHandler;
  30. let fileHandle = mutableFile.open("readwrite");
  31. request = fileHandle.write("string");
  32. is(request.readyState, "pending", "Correct readyState");
  33. request.onsuccess = grabEventAndContinueHandler;
  34. event = yield undefined;
  35. is(request.readyState, "done", "Correct readyState");
  36. fileHandle.location = 0;
  37. request = fileHandle.readAsText(6);
  38. request.onsuccess = grabEventAndContinueHandler;
  39. is(request.readyState, "pending", "Correct readyState");
  40. event = yield undefined;
  41. ok(event.target.result, "Got something");
  42. is(request.readyState, "done", "Correct readyState");
  43. finishTest();
  44. yield undefined;
  45. }
  46. </script>
  47. <script type="text/javascript;version=1.7" src="helpers.js"></script>
  48. </head>
  49. <body onload="runTest();"></body>
  50. </html>