Remove WebSQL provider (last supported in v0.0.44)

This commit is contained in:
David Humphrey 2019-01-02 13:12:18 -05:00
parent bc861bfd4a
commit 1ad81f9bae
11 changed files with 59 additions and 335 deletions

View File

@ -60,7 +60,6 @@ The default provider is `Memory`, and you can switch it like so:
* tests/index.html?filer-provider=memory
* tests/index.html?filer-provider=indexeddb
* tests/index.html?filer-provider=websql
If you're writing tests, make sure you write them in the same style as existing tests, which are
provider agnostic. See [`tests/lib/test-utils.js`](tests/lib/test-utils.js) and how it gets used

View File

@ -4,23 +4,23 @@
### Filer
Filer is a POSIX-like file system for browsers.
Filer is a drop-in replacement for node's `fs` module, a POSIX-like file system
for browsers.
### Compatibility
Filer is known to work in the following browsers/versions, with the specified [Storage Providers](#providers):
Filer uses [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API)
and is [known to work in the following browsers/versions](https://caniuse.com/#feat=indexeddb):
* node.js: v0.10.*+
* IE: 10+ (IndexedDB)
* Firefox: 26+ (IndexedDB)
* Chrome: 31+ (IndexedDB, WebSQL)
* Safari: 7.0+ (WebSQL)
* Opera: 19+ (IndexedDB, WebSQL)
* iOS: 3.2+ (WebSQL)
* Android Browser: 2.1-4.4 (WebSQL), 4.4+ (IndexedDB)
NOTE: if you're interested in maximum compatibility, use the `Fallback` provider instead of `Default`.
See the section on [Storage Providers](#providers).
* IE: 10+
* Edge: 12+
* Firefox: 10+
* Chrome: 23+
* Safari: 10+
* Opera: 15+
* iOS: 10+
* Android Browser: 4.4+
### Contributing
@ -31,7 +31,7 @@ Want to join the fun? We'd love to have you! See [CONTRIBUTING](https://github.c
Filer can be obtained in a number of ways:
1. Via npm: `npm install filer`
3. Via unpkg: `<script src="https://unpkg.com/filer"></script>` or specify a version directly, for example: [https://unpkg.com/filer@1.0.1/dist/filer.min.js](https://unpkg.com/filer@1.0.1/dist/filer.min.js)
1. Via unpkg: `<script src="https://unpkg.com/filer"></script>` or specify a version directly, for example: [https://unpkg.com/filer@1.0.1/dist/filer.min.js](https://unpkg.com/filer@1.0.1/dist/filer.min.js)
### Loading and Usage
@ -76,11 +76,11 @@ they are invoked. Ensure proper ordering by chaining operations in callbacks.
To create a new file system or open an existing one, create a new `FileSystem`
instance. By default, a new [IndexedDB](https://developer.mozilla.org/en/docs/IndexedDB)
database is created for each file system. The file system can also use other
backend storage providers, for example [WebSQL](http://en.wikipedia.org/wiki/Web_SQL_Database)
or even RAM (i.e., for temporary storage). See the section on [Storage Providers](#providers).
backend storage providers, for example `Memory`. See the section on [Storage Providers](#providers).
<a name="overviewExample"></a>
```javascript
```js
var fs = new Filer.FileSystem();
fs.open('/myfile', 'w+', function(err, fd) {
if (err) throw err;
@ -162,15 +162,17 @@ it becomes ready.
#### Filer.FileSystem.providers - Storage Providers<a name="providers"></a>
Filer can be configured to use a number of different storage providers. The provider object encapsulates all aspects
of data access, making it possible to swap in different backend storage options. There are currently 4 different
providers to choose from:
Filer can be configured to use a number of different storage providers. The provider object encapsulates all aspects of data access, making it possible to swap in different backend storage options. There are currently 2 providers to choose from:
* `FileSystem.providers.IndexedDB()` - uses IndexedDB
* `FileSystem.providers.WebSQL()` - uses WebSQL
* `FileSystem.providers.Fallback()` - attempts to use IndexedDB if possible, falling-back to WebSQL if necessary
if necessary
* `FileSystem.providers.Memory()` - uses memory (not suitable for data that needs to survive the current session)
**NOTE**: previous versions of Filer also supported `FileSystem.providers.WebSQL()` and
`FileSystem.providers.Fallback()`, which could be used in browsers that supported
WebSQL but not IndexedDB. [WebSQL has been deprecated](https://www.w3.org/TR/webdatabase/),
and this functionality was removed in `v1.0.0`. If for some reason you still need it, use [`v0.0.44`](https://github.com/filerjs/filer/releases/tag/v0.0.44).
You can choose your provider when creating a `FileSystem`:
```javascript
@ -180,28 +182,20 @@ var providers = FileSystem.providers;
// Example 1: Use the default provider (currently IndexedDB)
var fs1 = new FileSystem();
// Example 2: Explicitly use IndexedDB
var fs2 = new FileSystem({ provider: new providers.IndexedDB() });
// Example 3: Use one of IndexedDB or WebSQL, whichever is supported
var fs3 = new FileSystem({ provider: new providers.Fallback() });
// Example 2: Use the Memory provider
var fs2 = new FileSystem({ provider: new providers.Memory() });
```
Every provider has an `isSupported()` method, which returns `true` if the browser supports this provider:
```javascript
if( Filer.FileSystem.providers.WebSQL.isSupported() ) {
// WebSQL provider will work in current environment...
if( Filer.FileSystem.providers.IndexedDB.isSupported() ) {
// IndexedDB provider will work in current environment...
}
```
You can also write your own provider if you need a different backend. See the code in `src/providers` for details.
A number of other providers have been written, including:
* node.js fs provider: https://github.com/humphd/filer-fs
* node.js Amazon S3 provider: https://github.com/alicoding/filer-s3
#### Filer.Buffer<a name="FilerBuffer"></a>
When reading and writing data, Filer follows node.js and uses [`Buffer`](http://nodejs.org/api/buffer.html).

53
package-lock.json generated
View File

@ -1402,7 +1402,7 @@
},
"util": {
"version": "0.10.3",
"resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
"dev": true,
"requires": {
@ -2453,7 +2453,8 @@
"base64-arraybuffer": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz",
"integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg="
"integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=",
"dev": true
},
"base64-js": {
"version": "1.3.0",
@ -2635,7 +2636,7 @@
},
"browserify-aes": {
"version": "1.2.0",
"resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
"dev": true,
"requires": {
@ -2672,7 +2673,7 @@
},
"browserify-rsa": {
"version": "4.0.1",
"resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
"dev": true,
"requires": {
@ -3389,7 +3390,7 @@
},
"concat-stream": {
"version": "1.6.2",
"resolved": "http://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
"dev": true,
"requires": {
@ -3819,7 +3820,7 @@
},
"create-hash": {
"version": "1.2.0",
"resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
"dev": true,
"requires": {
@ -3832,7 +3833,7 @@
},
"create-hmac": {
"version": "1.1.7",
"resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
"dev": true,
"requires": {
@ -4307,7 +4308,7 @@
},
"diffie-hellman": {
"version": "5.0.3",
"resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
"resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
"integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==",
"dev": true,
"requires": {
@ -7095,7 +7096,7 @@
},
"is-accessor-descriptor": {
"version": "0.1.6",
"resolved": "http://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
"resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
"integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=",
"dev": true,
"requires": {
@ -7174,7 +7175,7 @@
},
"is-data-descriptor": {
"version": "0.1.4",
"resolved": "http://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
"resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
"integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=",
"dev": true,
"requires": {
@ -7976,7 +7977,7 @@
},
"media-typer": {
"version": "0.3.0",
"resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=",
"dev": true
},
@ -9880,7 +9881,7 @@
},
"os-homedir": {
"version": "1.0.2",
"resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
"dev": true
},
@ -9896,7 +9897,7 @@
},
"os-tmpdir": {
"version": "1.0.2",
"resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=",
"dev": true
},
@ -10005,7 +10006,7 @@
},
"pako": {
"version": "0.2.9",
"resolved": "http://registry.npmjs.org/pako/-/pako-0.2.9.tgz",
"resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",
"integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=",
"dev": true
},
@ -10086,7 +10087,7 @@
},
"parse-asn1": {
"version": "5.1.1",
"resolved": "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz",
"resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz",
"integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==",
"dev": true,
"requires": {
@ -10151,7 +10152,7 @@
},
"path-browserify": {
"version": "0.0.0",
"resolved": "http://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz",
"resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz",
"integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=",
"dev": true
},
@ -10235,7 +10236,7 @@
},
"pify": {
"version": "2.3.0",
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
},
@ -11343,7 +11344,7 @@
},
"readable-stream": {
"version": "2.3.6",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true,
"requires": {
@ -11802,7 +11803,7 @@
},
"safe-regex": {
"version": "1.1.0",
"resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
"dev": true,
"requires": {
@ -11948,7 +11949,7 @@
},
"sha.js": {
"version": "2.4.11",
"resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
"dev": true,
"requires": {
@ -12322,7 +12323,7 @@
},
"sprintf-js": {
"version": "1.0.3",
"resolved": "http://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
"dev": true
},
@ -12392,7 +12393,7 @@
},
"stream-browserify": {
"version": "2.0.1",
"resolved": "http://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz",
"resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz",
"integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=",
"dev": true,
"requires": {
@ -12443,7 +12444,7 @@
},
"string_decoder": {
"version": "1.1.1",
"resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true,
"requires": {
@ -12644,7 +12645,7 @@
},
"through": {
"version": "2.3.8",
"resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
"dev": true
},
@ -12780,7 +12781,7 @@
},
"tty-browserify": {
"version": "0.0.0",
"resolved": "http://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
"integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=",
"dev": true
},
@ -13198,7 +13199,7 @@
},
"vm-browserify": {
"version": "0.0.4",
"resolved": "http://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
"resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
"integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=",
"dev": true,
"requires": {

View File

@ -46,7 +46,6 @@
"url": "https://github.com/filerjs/filer.git"
},
"dependencies": {
"base64-arraybuffer": "^0.1.5",
"es6-promisify": "^6.0.1",
"minimatch": "^3.0.4"
},

View File

@ -1,35 +1,8 @@
var IndexedDB = require('./indexeddb.js');
var WebSQL = require('./websql.js');
var Memory = require('./memory.js');
const IndexedDB = require('./indexeddb.js');
const Memory = require('./memory.js');
module.exports = {
IndexedDB: IndexedDB,
WebSQL: WebSQL,
Memory: Memory,
/**
* Convenience Provider references
*/
// The default provider to use when none is specified
Default: IndexedDB,
// The Fallback provider does automatic fallback checks
Fallback: (function() {
if(IndexedDB.isSupported()) {
return IndexedDB;
}
if(WebSQL.isSupported()) {
return WebSQL;
}
function NotSupported() {
throw '[Filer Error] Your browser doesn\'t support IndexedDB or WebSQL.';
}
NotSupported.isSupported = function() {
return false;
};
return NotSupported;
}())
Memory: Memory
};

View File

@ -1,170 +0,0 @@
var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME;
var FILE_STORE_NAME = require('../constants.js').FILE_STORE_NAME;
var WSQL_VERSION = require('../constants.js').WSQL_VERSION;
var WSQL_SIZE = require('../constants.js').WSQL_SIZE;
var WSQL_DESC = require('../constants.js').WSQL_DESC;
var Errors = require('../errors.js');
var base64ArrayBuffer = require('base64-arraybuffer');
function WebSQLContext(db, isReadOnly) {
var that = this;
this.getTransaction = function(callback) {
if(that.transaction) {
callback(that.transaction);
return;
}
// Either do readTransaction() (read-only) or transaction() (read/write)
db[isReadOnly ? 'readTransaction' : 'transaction'](function(transaction) {
that.transaction = transaction;
callback(transaction);
});
};
}
WebSQLContext.prototype.clear = function(callback) {
function onError(transaction, error) {
callback(error);
}
function onSuccess() {
callback(null);
}
this.getTransaction(function(transaction) {
transaction.executeSql('DELETE FROM ' + FILE_STORE_NAME + ';',
[], onSuccess, onError);
});
};
function _get(getTransaction, key, callback) {
function onSuccess(transaction, result) {
// If the key isn't found, return null
var value = result.rows.length === 0 ? null : result.rows.item(0).data;
callback(null, value);
}
function onError(transaction, error) {
callback(error);
}
getTransaction(function(transaction) {
transaction.executeSql('SELECT data FROM ' + FILE_STORE_NAME + ' WHERE id = ? LIMIT 1;',
[key], onSuccess, onError);
});
}
WebSQLContext.prototype.getObject = function(key, callback) {
_get(this.getTransaction, key, function(err, result) {
if(err) {
return callback(err);
}
try {
if(result) {
result = JSON.parse(result);
}
} catch(e) {
return callback(e);
}
callback(null, result);
});
};
WebSQLContext.prototype.getBuffer = function(key, callback) {
_get(this.getTransaction, key, function(err, result) {
if(err) {
return callback(err);
}
// Deal with zero-length ArrayBuffers, which will be encoded as ''
if(result || result === '') {
var arrayBuffer = base64ArrayBuffer.decode(result);
result = Buffer.from(arrayBuffer);
}
callback(null, result);
});
};
function _put(getTransaction, key, value, callback) {
function onSuccess() {
callback(null);
}
function onError(transaction, error) {
callback(error);
}
getTransaction(function(transaction) {
transaction.executeSql('INSERT OR REPLACE INTO ' + FILE_STORE_NAME + ' (id, data) VALUES (?, ?);',
[key, value], onSuccess, onError);
});
}
WebSQLContext.prototype.putObject = function(key, value, callback) {
var json = JSON.stringify(value);
_put(this.getTransaction, key, json, callback);
};
WebSQLContext.prototype.putBuffer = function(key, uint8BackedBuffer, callback) {
var base64 = base64ArrayBuffer.encode(uint8BackedBuffer.buffer);
_put(this.getTransaction, key, base64, callback);
};
WebSQLContext.prototype.delete = function(key, callback) {
function onSuccess() {
callback(null);
}
function onError(transaction, error) {
callback(error);
}
this.getTransaction(function(transaction) {
transaction.executeSql('DELETE FROM ' + FILE_STORE_NAME + ' WHERE id = ?;',
[key], onSuccess, onError);
});
};
function WebSQL(name) {
this.name = name || FILE_SYSTEM_NAME;
this.db = null;
}
WebSQL.isSupported = function() {
return !!global.openDatabase;
};
WebSQL.prototype.open = function(callback) {
var that = this;
// Bail if we already have a db open
if(that.db) {
return callback();
}
var db = global.openDatabase(that.name, WSQL_VERSION, WSQL_DESC, WSQL_SIZE);
if(!db) {
callback('[WebSQL] Unable to open database.');
return;
}
function onError(transaction, error) {
if (error.code === 5) {
callback(new Errors.EINVAL('WebSQL cannot be accessed. If private browsing is enabled, disable it.'));
}
callback(error);
}
function onSuccess() {
that.db = db;
callback();
}
// Create the table and index we'll need to store the fs data.
db.transaction(function(transaction) {
function createIndex(transaction) {
transaction.executeSql('CREATE INDEX IF NOT EXISTS idx_' + FILE_STORE_NAME + '_id' +
' on ' + FILE_STORE_NAME + ' (id);',
[], onSuccess, onError);
}
transaction.executeSql('CREATE TABLE IF NOT EXISTS ' + FILE_STORE_NAME + ' (id unique, data TEXT);',
[], createIndex, onError);
});
};
WebSQL.prototype.getReadOnlyContext = function() {
return new WebSQLContext(this.db, true);
};
WebSQL.prototype.getReadWriteContext = function() {
return new WebSQLContext(this.db, false);
};
module.exports = WebSQL;

View File

@ -52,7 +52,6 @@ require('./spec/fs.copyFile.spec');
// Filer.FileSystem.providers.*
require('./spec/providers/providers.spec');
require('./spec/providers/providers.indexeddb.spec');
require('./spec/providers/providers.websql.spec');
require('./spec/providers/providers.memory.spec');
require('./spec/providers/serializable-memory-provider.spec');

View File

@ -1,6 +1,5 @@
var Filer = require('../../src');
var IndexedDBTestProvider = require('./indexeddb.js');
var WebSQLTestProvider = require('./websql.js');
var MemoryTestProvider = require('./memory.js');
var Url = require('url');
@ -16,13 +15,8 @@ function uniqueName() {
function findBestProvider() {
var providers = Filer.FileSystem.providers;
if(providers.IndexedDB.isSupported()) {
return IndexedDBTestProvider;
}
if(providers.WebSQL.isSupported()) {
return WebSQLTestProvider;
}
return MemoryTestProvider;
return providers.IndexedDB.isSupported() ?
IndexedDBTestProvider : MemoryTestProvider;
}
function getUrlParams() {
@ -61,9 +55,6 @@ function setup(callback) {
case 'indexeddb':
_provider = new IndexedDBTestProvider(name);
break;
case 'websql':
_provider = new WebSQLTestProvider(name);
break;
case 'memory':
_provider = new MemoryTestProvider(name);
break;
@ -158,7 +149,6 @@ module.exports = {
provider: provider,
providers: {
IndexedDB: IndexedDBTestProvider,
WebSQL: WebSQLTestProvider,
Memory: MemoryTestProvider
},
cleanup: cleanup,

View File

@ -1,49 +0,0 @@
var Filer = require('../../src');
var needsCleanup = [];
if(global.addEventListener) {
global.addEventListener('beforeunload', function() {
needsCleanup.forEach(function(f) { f(); });
});
}
function WebSQLTestProvider(name) {
var _done = false;
var that = this;
function cleanup(callback) {
callback = callback || function(){};
if(!that.provider || _done) {
return callback();
}
// Provider is there, but db was never touched
if(!that.provider.db) {
return callback();
}
var context = that.provider.getReadWriteContext();
context.clear(function() {
that.provider = null;
_done = true;
callback();
});
}
function init() {
if(that.provider) {
return;
}
that.provider = new Filer.FileSystem.providers.WebSQL(name);
needsCleanup.push(cleanup);
}
this.init = init;
this.cleanup = cleanup;
}
WebSQLTestProvider.isSupported = function() {
return Filer.FileSystem.providers.WebSQL.isSupported();
};
module.exports = WebSQLTestProvider;

View File

@ -10,10 +10,6 @@ describe('Filer.FileSystem.providers', function() {
expect(Filer.FileSystem.providers.IndexedDB).to.be.a('function');
});
it('has WebSQL constructor', function() {
expect(Filer.FileSystem.providers.WebSQL).to.be.a('function');
});
it('has Memory constructor', function() {
expect(Filer.FileSystem.providers.Memory).to.be.a('function');
});
@ -21,8 +17,4 @@ describe('Filer.FileSystem.providers', function() {
it('has a Default constructor', function() {
expect(Filer.FileSystem.providers.Default).to.be.a('function');
});
it('has Fallback constructor', function() {
expect(Filer.FileSystem.providers.Fallback).to.be.a('function');
});
});

View File

@ -1,4 +0,0 @@
var util = require('../../lib/test-utils.js');
var providerBase = require('./providers.base.js');
providerBase('WebSQL', util.providers.WebSQL);