test_filehandle_overlapping.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. for (let i = 0; i < 50; i++) {
  27. let stepNumber = 0;
  28. request = mutableFile.open("readwrite").append("string1");
  29. request.onsuccess = function(event) {
  30. is(stepNumber, 1, "This callback came first");
  31. stepNumber++;
  32. event.target.fileHandle.oncomplete = grabEventAndContinueHandler;
  33. }
  34. request = mutableFile.open("readwrite").append("string2");
  35. request.onsuccess = function(event) {
  36. is(stepNumber, 2, "This callback came second");
  37. stepNumber++;
  38. event.target.fileHandle.oncomplete = grabEventAndContinueHandler;
  39. }
  40. request = mutableFile.open("readwrite").append("string3");
  41. request.onsuccess = function(event) {
  42. is(stepNumber, 3, "This callback came third");
  43. stepNumber++;
  44. event.target.fileHandle.oncomplete = grabEventAndContinueHandler;
  45. }
  46. stepNumber++;
  47. yield undefined; yield undefined; yield undefined;;
  48. is(stepNumber, 4, "All callbacks received");
  49. }
  50. finishTest();
  51. yield undefined;
  52. }
  53. </script>
  54. <script type="text/javascript;version=1.7" src="helpers.js"></script>
  55. </head>
  56. <body onload="runTest();"></body>
  57. </html>