test_filehandle_lifetimes_nested.html 1.7 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. 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. let fileHandle2;
  28. let comp = SpecialPowers.wrap(SpecialPowers.Components);
  29. let thread = comp.classes["@mozilla.org/thread-manager;1"]
  30. .getService(comp.interfaces.nsIThreadManager)
  31. .currentThread;
  32. let eventHasRun;
  33. thread.dispatch(function() {
  34. eventHasRun = true;
  35. fileHandle2 = mutableFile.open();
  36. }, SpecialPowers.Ci.nsIThread.DISPATCH_NORMAL);
  37. while (!eventHasRun) {
  38. thread.processNextEvent(false);
  39. }
  40. ok(fileHandle2, "Non-null fileHandle2");
  41. continueToNextStep();
  42. yield undefined;
  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>