mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1607791 - Get rid of IDBMutableFile.getFile() - part 4 - Remove a few tests, r=janv
Differential Revision: https://phabricator.services.mozilla.com/D59143 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
a9cf3442be
commit
4a25262f66
@ -176,8 +176,6 @@ skip-if = toolkit == 'android' && !is_fennec
|
||||
[test_filehandle_append_read_data.html]
|
||||
[test_filehandle_compat.html]
|
||||
[test_filehandle_disabled_pref.html]
|
||||
[test_filehandle_getFile.html]
|
||||
skip-if = true
|
||||
[test_filehandle_iteration.html]
|
||||
[test_filehandle_lifetimes.html]
|
||||
[test_filehandle_lifetimes_nested.html]
|
||||
@ -188,8 +186,6 @@ skip-if = true
|
||||
[test_filehandle_readonly_exceptions.html]
|
||||
[test_filehandle_request_readyState.html]
|
||||
[test_filehandle_serialization.html]
|
||||
[test_filehandle_store_snapshot.html]
|
||||
[test_filehandle_stream_tracking.html]
|
||||
[test_filehandle_success_events_after_abort.html]
|
||||
[test_filehandle_truncate.html]
|
||||
[test_filehandle_workers.html]
|
||||
|
@ -1,52 +0,0 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>File Handle Test</title>
|
||||
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="text/javascript">
|
||||
function* testSteps()
|
||||
{
|
||||
const name = window.location.pathname;
|
||||
|
||||
let request = indexedDB.open(name, 1);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
let event = yield undefined;
|
||||
|
||||
let db = event.target.result;
|
||||
db.onerror = errorHandler;
|
||||
|
||||
request = db.createMutableFile("test.txt");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
let mutableFile = event.target.result;
|
||||
mutableFile.onerror = errorHandler;
|
||||
|
||||
request = mutableFile.getFile();
|
||||
ok(request instanceof DOMRequest, "Correct interface");
|
||||
ok(!(request instanceof IDBFileRequest), "Correct interface");
|
||||
ok(!("fileHandle" in request), "Property should not exist");
|
||||
ok(request.fileHandle === undefined, "Property should not exist");
|
||||
ok(!("lockedFile" in request), "Property should not exist");
|
||||
ok(request.lockedFile === undefined, "Property should not exist");
|
||||
ok(!("onprogress" in request), "Property should not exist");
|
||||
ok(request.onprogress === undefined, "Property should not exist");
|
||||
|
||||
finishTest();
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="helpers.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="runTest();"></body>
|
||||
|
||||
</html>
|
@ -1,97 +0,0 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Indexed Database Property Test</title>
|
||||
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
<script type="text/javascript">
|
||||
function* testSteps()
|
||||
{
|
||||
const READ_WRITE = "readwrite";
|
||||
|
||||
const name = window.location.pathname;
|
||||
|
||||
const objectStoreName = "Blobs";
|
||||
|
||||
const testFile = getRandomFile("random.bin", 100000);
|
||||
|
||||
let request = indexedDB.open(name, 1);
|
||||
request.onerror = errorHandler;
|
||||
request.onupgradeneeded = grabEventAndContinueHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
let event = yield undefined;
|
||||
|
||||
is(event.type, "upgradeneeded", "Got correct event type");
|
||||
|
||||
let db = event.target.result;
|
||||
db.onerror = errorHandler;
|
||||
|
||||
let objectStore = db.createObjectStore(objectStoreName, { });
|
||||
|
||||
event = yield undefined;
|
||||
|
||||
is(event.type, "success", "Got correct event type");
|
||||
|
||||
request = db.createMutableFile("random.bin", "binary/random");
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
let mutableFile = event.target.result;
|
||||
mutableFile.onerror = errorHandler;
|
||||
|
||||
let fileHandle = mutableFile.open("readwrite");
|
||||
|
||||
is(getFileId(mutableFile), 1, "Correct file id");
|
||||
|
||||
request = fileHandle.write(testFile);
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
request = mutableFile.getFile();
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
let file = event.target.result;
|
||||
|
||||
let trans = db.transaction([objectStoreName], READ_WRITE);
|
||||
objectStore = trans.objectStore(objectStoreName);
|
||||
|
||||
request = objectStore.add(file, 42);
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
// At this moment, the file should not be readable anymore.
|
||||
let reader = new FileReader();
|
||||
try {
|
||||
reader.readAsArrayBuffer(file);
|
||||
ok(false, "Should have thrown!");
|
||||
}
|
||||
catch (e) {
|
||||
ok(e instanceof DOMException, "Got exception.");
|
||||
is(e.name, "FileHandleInactiveError", "Good error.");
|
||||
is(e.code, 0, "Good error code.");
|
||||
}
|
||||
|
||||
request = objectStore.get(42);
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
verifyBlob(event.target.result, testFile, 2);
|
||||
yield undefined;
|
||||
|
||||
finishTest();
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="file.js"></script>
|
||||
<script type="text/javascript" src="helpers.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="runTest();"></body>
|
||||
|
||||
</html>
|
@ -1,111 +0,0 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>File Handle Test</title>
|
||||
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
<script type="text/javascript">
|
||||
function* testSteps()
|
||||
{
|
||||
const name = window.location.pathname;
|
||||
|
||||
var testBuffer = getRandomBuffer(100000);
|
||||
|
||||
let request = indexedDB.open(name, 1);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
let event = yield undefined;
|
||||
|
||||
let db = event.target.result;
|
||||
db.onerror = errorHandler;
|
||||
|
||||
request = db.createMutableFile("test.txt");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
let mutableFile = event.target.result;
|
||||
mutableFile.onerror = errorHandler;
|
||||
|
||||
let fileHandle = mutableFile.open("readwrite");
|
||||
|
||||
request = fileHandle.write(testBuffer);
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
request = mutableFile.getFile();
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
let file = event.target.result;
|
||||
|
||||
let resultBuffer1;
|
||||
let resultBuffer2;
|
||||
|
||||
let reader1 = new FileReader();
|
||||
reader1.readAsArrayBuffer(file);
|
||||
reader1.onerror = errorHandler;
|
||||
reader1.onload = function(event)
|
||||
{
|
||||
resultBuffer1 = event.target.result;
|
||||
|
||||
let reader = new FileReader();
|
||||
try {
|
||||
reader.readAsArrayBuffer(file);
|
||||
ok(false, "Should have thrown!");
|
||||
}
|
||||
catch (e) {
|
||||
ok(e instanceof DOMException, "Got exception.");
|
||||
is(e.name, "FileHandleInactiveError", "Good error.");
|
||||
is(e.code, 0, "Good error code.");
|
||||
}
|
||||
|
||||
if (resultBuffer2) {
|
||||
testGenerator.next();
|
||||
}
|
||||
};
|
||||
|
||||
let reader2 = new FileReader();
|
||||
reader2.readAsArrayBuffer(file);
|
||||
reader2.onerror = errorHandler;
|
||||
reader2.onload = function(event)
|
||||
{
|
||||
resultBuffer2 = event.target.result;
|
||||
|
||||
let reader = new FileReader();
|
||||
try {
|
||||
reader.readAsArrayBuffer(file);
|
||||
ok(false, "Should have thrown!");
|
||||
}
|
||||
catch (e) {
|
||||
ok(e instanceof DOMException, "Got exception.");
|
||||
is(e.name, "FileHandleInactiveError", "Good error.");
|
||||
is(e.code, 0, "Good error code.");
|
||||
}
|
||||
|
||||
if (resultBuffer1) {
|
||||
testGenerator.next();
|
||||
}
|
||||
};
|
||||
|
||||
yield undefined;
|
||||
|
||||
ok(compareBuffers(resultBuffer1, testBuffer), "Correct data");
|
||||
ok(compareBuffers(resultBuffer2, testBuffer), "Correct data");
|
||||
|
||||
finishTest();
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="file.js"></script>
|
||||
<script type="text/javascript" src="helpers.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="runTest();"></body>
|
||||
|
||||
</html>
|
@ -71,24 +71,6 @@
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
request = mutableFile.getFile();
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
let file = event.target.result;
|
||||
|
||||
let worker2 = new Worker(url);
|
||||
URL.revokeObjectURL(url);
|
||||
try {
|
||||
worker2.postMessage(file);
|
||||
ok(false, "Should have thrown!");
|
||||
}
|
||||
catch (e) {
|
||||
ok(e instanceof DOMException, "Got exception.");
|
||||
is(e.name, "DataCloneError", "Good error.");
|
||||
is(e.code, DOMException.DATA_CLONE_ERR, "Good error code.");
|
||||
}
|
||||
|
||||
let objectStore =
|
||||
db.transaction("Foo", "readwrite").objectStore("Foo");
|
||||
|
||||
@ -126,10 +108,10 @@
|
||||
|
||||
url = URL.createObjectURL(new Blob(["(", workerScript.toString(), ")()"]));
|
||||
|
||||
let worker3 = new Worker(url);
|
||||
let worker2 = new Worker(url);
|
||||
URL.revokeObjectURL(url);
|
||||
worker3.postMessage(name);
|
||||
worker3.onmessage = grabEventAndContinueHandler;
|
||||
worker2.postMessage(name);
|
||||
worker2.onmessage = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
is(event.data, "success", "Good response.");
|
||||
@ -137,7 +119,6 @@
|
||||
todo(false, "Terminate all workers at the end of the test to work around bug 1340941.");
|
||||
worker1.terminate();
|
||||
worker2.terminate();
|
||||
worker3.terminate();
|
||||
|
||||
finishTest();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user