gecko/dom/file/test/test_success_events_after_abort.html
Bobby Holley 5af5a73d3d Bug 792036 - Automated fixups. r=mccr8
find /files/mozilla/build/d/_tests/testing/mochitest/tests/ | egrep "\.(xhtml|html|xml|js)$" | grep -v SimpleTest | grep -vi mochikit | grep -v simpleThread | grep -v test_ipc_messagemanager_blob.html | grep -v "indexedDB/test" | xargs grep -l Components |  xargs grep -L enablePrivilege | perl -pe 's#.*mochitest/tests/##' | xargs perl -p -i.bakkk -e 's/Components\.interfaces(\s|;|\.|\[)/SpecialPowers\.Ci$1/g, s/SpecialPowers\.wrap\(Components\)\.(.)(lasses|tils|nterfaces|esults)/SpecialPowers.C$1/g, s/(?<![\.a-zA-Z])Components/SpecialPowers\.Components/g, s/window\.Components/window\.SpecialPowers\.Components/g'
2012-09-24 14:46:29 +02:00

67 lines
1.8 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;
let fileHandle = event.target.result;
fileHandle.onerror = errorHandler;
let lockedFile = fileHandle.open();
lockedFile.oncomplete = unexpectedSuccessHandler;
lockedFile.onabort = grabEventAndContinueHandler;
let sawError = false;
request = lockedFile.getMetadata({ size: true });
request.onsuccess = unexpectedSuccessHandler;
request.onerror = function(event) {
is(event.target.error.name, "AbortError", "Good error");
sawError = true;
event.stopPropagation();
}
lockedFile.abort();
event = yield;
is(event.type, "abort", "Got abort event");
is(sawError, true, "Saw getMetadata() error");
// Make sure the success event isn't queued somehow.
let comp = SpecialPowers.wrap(SpecialPowers.Components);
var thread = comp.classes["@mozilla.org/thread-manager;1"]
.getService(comp.interfaces.nsIThreadManager)
.currentThread;
while (thread.hasPendingEvents()) {
thread.processNextEvent(false);
}
}
finishTest();
yield;
}
</script>
<script type="text/javascript;version=1.7" src="helpers.js"></script>
</head>
<body onload="runTest();"></body>
</html>