toolkit/components/osfile/tests/xpcshell/test_osfile_async_flush.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 "use strict";
michael@0 2
michael@0 3 Components.utils.import("resource://gre/modules/osfile.jsm");
michael@0 4 Components.utils.import("resource://gre/modules/Task.jsm");
michael@0 5
michael@0 6 function run_test() {
michael@0 7 do_test_pending();
michael@0 8 run_next_test();
michael@0 9 }
michael@0 10
michael@0 11 /**
michael@0 12 * Test to ensure that |File.prototype.flush| is available in the async API.
michael@0 13 */
michael@0 14
michael@0 15 add_task(function test_flush() {
michael@0 16 let path = OS.Path.join(OS.Constants.Path.tmpDir,
michael@0 17 "test_osfile_async_flush.tmp");
michael@0 18 let file = yield OS.File.open(path, {trunc: true, write: true});
michael@0 19 try {
michael@0 20 try {
michael@0 21 yield file.flush();
michael@0 22 } finally {
michael@0 23 yield file.close();
michael@0 24 }
michael@0 25 } finally {
michael@0 26 yield OS.File.remove(path);
michael@0 27 }
michael@0 28 });
michael@0 29
michael@0 30 add_task(do_test_finished);

mercurial