gecko/dom/file/test/test_lockedfile_ordering.html

55 lines
1.5 KiB
HTML

<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<title>File Handle Test</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript;version=1.7">
function testSteps()
{
for each (let fileStorage in fileStorages) {
let request = getFileHandle(fileStorage.key, "test.txt");
request.onerror = errorHandler;
request.onsuccess = grabEventAndContinueHandler;
let event = yield undefined;
let fileHandle = event.target.result;
fileHandle.onerror = errorHandler;
let lockedFile1 = fileHandle.open("readwrite");
let lockedFile2 = fileHandle.open("readwrite");
let request1 = lockedFile2.write("2");
let request2 = lockedFile1.write("1");
lockedFile1.oncomplete = grabEventAndContinueHandler;
lockedFile2.oncomplete = grabEventAndContinueHandler;
yield undefined;
yield undefined;
let lockedFile3 = fileHandle.open("readonly");
let request3 = lockedFile3.readAsText(1);
request3.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
is(event.target.result, "2", "Locked files were ordered properly.");
}
finishTest();
yield undefined;
}
</script>
<script type="text/javascript;version=1.7" src="helpers.js"></script>
</head>
<body onload="runTest();"></body>
</html>