test_filehandle_ordering.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 fileHandle1 = mutableFile.open("readwrite");
  27. let fileHandle2 = mutableFile.open("readwrite");
  28. let request1 = fileHandle2.write("2");
  29. let request2 = fileHandle1.write("1");
  30. fileHandle1.oncomplete = grabEventAndContinueHandler;
  31. fileHandle2.oncomplete = grabEventAndContinueHandler;
  32. yield undefined;
  33. yield undefined;
  34. let fileHandle3 = mutableFile.open("readonly");
  35. let request3 = fileHandle3.readAsText(1);
  36. request3.onsuccess = grabEventAndContinueHandler;
  37. event = yield undefined;
  38. is(event.target.result, "2", "File handles were ordered properly.");
  39. finishTest();
  40. yield undefined;
  41. }
  42. </script>
  43. <script type="text/javascript;version=1.7" src="helpers.js"></script>
  44. </head>
  45. <body onload="runTest();"></body>
  46. </html>