Merge branch 'master' into pr/MeMark2/874

This commit is contained in:
Matthew Riley MacPherson (tofumatt) 2020-06-05 00:21:49 +01:00
commit 1f7ca5d651
No known key found for this signature in database
GPG Key ID: 244CF08D60266A0C
29 changed files with 518 additions and 11894 deletions

5
.huskyrc Normal file
View File

@ -0,0 +1,5 @@
{
"hooks": {
"pre-commit": "lint-staged"
}
}

6
.lintstagedrc Normal file
View File

@ -0,0 +1,6 @@
{
"{src,test}/**/*.js": [
"prettier --write",
"git add"
]
}

1
.npmrc Normal file
View File

@ -0,0 +1 @@
package-lock=false

View File

@ -3,7 +3,7 @@ before_install:
- bower install
language: node_js
node_js:
- '6'
- '10'
env:
global:
secure: LSmHs32nmcjgp3/5hQASgIPUDF/zexvwV/XASRYCDkwJRllDZ8n8wIvHx+D1QVcotx7jSAVEKM2tcfMq/JLXVHUmNNpeG9maUMfZAHA7xFlAo5GNAG3p/rqYe3tan9Xum+Is6A71kXTVnaVyOTG5ApEyj8QUwPfHpv1ziGJu72Y=

View File

@ -138,24 +138,6 @@ module.exports = exports = function(grunt) {
eslint: {
target: sourceFiles
},
mocha: {
unit: {
options: {
urls: [
'http://localhost:9999/test/test.main.html',
'http://localhost:9999/test/test.min.html',
'http://localhost:9999/test/test.polyfill.html',
'http://localhost:9999/test/test.callwhenready.html',
'http://localhost:9999/test/test.customdriver.html',
'http://localhost:9999/test/test.faultydriver.html',
'http://localhost:9999/test/test.nodriver.html',
'http://localhost:9999/test/test.browserify.html',
'http://localhost:9999/test/test.require.html',
'http://localhost:9999/test/test.webpack.html'
]
}
}
},
'saucelabs-mocha': {
all: {
options: {
@ -240,6 +222,77 @@ module.exports = exports = function(grunt) {
'mocha'
];
grunt.registerTask('test:local', testTasks.slice());
grunt.registerTask('mocha', 'custom function to run mocha tests', function() {
const {runner} = require('mocha-headless-chrome');
const fs = require('fs');
const path = require('path');
var done = this.async();
var tempErrLogs = fs.createWriteStream('temp.test.log');
var oldStdErr = process.stderr.write;
var totaltestsPassed = 0;
var totaltestsFailed = 0;
var totalDuration = 0;
var asset = path.join.bind(null, __dirname,
'node_modules/puppeteer/.local-chromium/linux-686378');
var urls = [
'http://localhost:9999/test/test.main1.html',
'http://localhost:9999/test/test.min.html',
'http://localhost:9999/test/test.polyfill.html',
'http://localhost:9999/test/test.customdriver.html',
'http://localhost:9999/test/test.faultydriver.html',
'http://localhost:9999/test/test.nodriver.html',
'http://localhost:9999/test/test.browserify.html',
'http://localhost:9999/test/test.callwhenready.html',
'http://localhost:9999/test/test.require.html',
'http://localhost:9999/test/test.webpack.html'
];
grunt.util.async.forEachSeries(urls, async function(url, next) {
const options = {
file: url, // test page path
reporter: 'dot', // mocha reporter name
width: 800, // viewport width
height: 600, // viewport height
timeout: 60000, // timeout in ms
executablePath: asset('chrome-linux/chrome'),// chrome executable path
visible: false, // show chrome window
args: ['no-sandbox'] // chrome arguments
};
console.log('Testing: ' + url + '\n\n');
process.stderr.write = tempErrLogs.write.bind(tempErrLogs);
await runner(options)
.then(obj => {
process.stderr.write = oldStdErr;
if (obj.result.stats.passes) {
totaltestsPassed += obj.result.stats.passes;
totalDuration += obj.result.stats.duration;
}
if (obj.result.stats.failures) {
totaltestsFailed += obj.result.stats.failures;
}
})
.catch(err => {
process.stderr.write = oldStdErr;
console.error(err);
process.exit(1);
});
next();
},function() {
grunt.log.oklns(totaltestsPassed + ' passed! (' + totalDuration/1000 + 's)');
if (totaltestsFailed > 0) {
grunt.log.errorlns(totaltestsFailed + ' failed!');
done(false);
} else {
done(true);
}
});
});
// Run tests using Sauce Labs if we are on Travis or have locally
// available Sauce Labs credentials. Use `grunt test:local` to skip

208
LICENSE
View File

@ -1,13 +1,201 @@
Copyright 2014 Mozilla
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
http://www.apache.org/licenses/LICENSE-2.0
1. Definitions.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2014 Mozilla
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -4,6 +4,7 @@
[![Dependency Status](https://img.shields.io/david/localForage/localForage.svg)](https://david-dm.org/localForage/localForage)
[![npm](https://img.shields.io/npm/dm/localforage.svg?maxAge=2592000)](https://npmcharts.com/compare/localforage?minimal=true)
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/localforage/badge?style=rounded)](https://www.jsdelivr.com/package/npm/localforage)
[![minzipped size](https://badgen.net/bundlephobia/minzip/localforage)](https://bundlephobia.com/result?p=localforage@1.7.3)
localForage is a fast and simple storage library for JavaScript. localForage
improves the offline experience of your web app by using asynchronous storage
@ -36,15 +37,7 @@ localForage is compatible with [browserify](http://browserify.org/).
Lost? Need help? Try the
[localForage API documentation](https://localforage.github.io/localForage). [localForage API文档也有中文版。](https://localforage.docschina.org)
If you're having trouble using the library, running the tests, or want to contribute
to localForage, you can visit
[irc.freenode.net](https://freenode.net/) and head to the `#localforage`
channel to ask questions about localForage.
You can ask [**tofumatt**][tofumatt] about localForage in IRC, who
is usually online from 10am-8pm GMT.
[tofumatt]: http://tofumatt.com/
If you're having trouble using the library, running the tests, or want to contribute to localForage, please look through the [existing issues](https://github.com/localForage/localForage/issues) for your problem first before creating a new one. If you still need help, [feel free to file an issue](https://github.com/localForage/localForage/issues/new).
## Safari 10.1+
@ -84,6 +77,20 @@ localforage.setItem('key', 'value').then(function () {
});
```
Or, use `async`/`await`:
```js
try {
const value = await localforage.getItem('somekey');
// This code runs once the value has been loaded
// from the offline store.
console.log(value);
} catch (err) {
// This code runs if there were any errors.
console.log(err);
}
```
For more examples, please visit [the API docs](https://localforage.github.io/localForage).
## Storing Blobs, TypedArrays, and other JS objects
@ -200,6 +207,7 @@ have drivers for the following frameworks:
* [Backbone](https://github.com/localForage/localForage-backbone)
* [Ember](https://github.com/genkgo/ember-localforage-adapter)
* [Vue](https://github.com/dmlzj/vlf)
* [NuxtJS](https://github.com/nuxt-community/localforage-module)
If you have a driver you'd like listed, please
[open an issue](https://github.com/localForage/localForage/issues/new) to have it
@ -250,6 +258,15 @@ a browser environment. Local tests are run on a headless WebKit (using
When you submit a pull request, tests will be run against all browsers that
localForage supports on Travis CI using [Sauce Labs](https://saucelabs.com/).
## Library Size
As of version 1.7.3 the payload added to your app is rather small. Served using gzip compression, localForage will add less than 10k to your total bundle size:
<dl>
<dt>minified</dt><dd>`~29kB`</dd>
<dt>gzipped</dt><dd>`~8.8kB`</dd>
<dt>brotli'd</dt><dd>`~7.8kB`</dd>
</dl>
# License
This program is free software; it is distributed under an

View File

@ -20,7 +20,7 @@
"devDependencies": {
"es6-promise": "~1.0.0",
"requirejs": "~2.1.10",
"mocha": "~1.18.2",
"mocha": "~3.4.2",
"expect": "~0.3.1",
"assert": "~0.1.0",
"modernizr": "~2.8.1"

4
dist/localforage.js vendored
View File

@ -376,7 +376,7 @@ function isIndexedDBValid() {
try {
// Initialize IndexedDB; fall back to vendor-prefixed versions
// if needed.
if (!idb) {
if (!idb || !idb.open) {
return false;
}
// We mimic PouchDB here;
@ -978,7 +978,7 @@ function iterate(iterator, callback) {
}
var result = iterator(value, cursor.key, iterationNumber++);
// when the iterator callback retuns any
// when the iterator callback returns any
// (non-`undefined`) value, then we stop
// the iteration immediately
if (result !== void 0) {

File diff suppressed because one or more lines are too long

View File

@ -40,7 +40,7 @@ function isIndexedDBValid() {
try {
// Initialize IndexedDB; fall back to vendor-prefixed versions
// if needed.
if (!idb) {
if (!idb || !idb.open) {
return false;
}
// We mimic PouchDB here;
@ -642,7 +642,7 @@ function iterate(iterator, callback) {
}
var result = iterator(value, cursor.key, iterationNumber++);
// when the iterator callback retuns any
// when the iterator callback returns any
// (non-`undefined`) value, then we stop
// the iteration immediately
if (result !== void 0) {

File diff suppressed because one or more lines are too long

View File

@ -31,8 +31,8 @@ localForage includes a localStorage-backed fallback store for browsers with no I
# Install via npm:
npm install localforage
# Or with bower:
bower install localforage
# Or, with yarn:
yarn add localforage
```
```html
@ -40,7 +40,7 @@ bower install localforage
<script>console.log('localforage is: ', localforage);</script>
```
To use localForage, [download the latest release](https://github.com/mozilla/localForage/releases) or install with [npm](https://www.npmjs.org/) (`npm install localforage`) or [bower](http://bower.io/) (`bower install localforage`).
To use localForage, [download the latest release](https://github.com/mozilla/localForage/releases) or install with [npm](https://www.npmjs.org/) (`npm install localforage`) or [yarn](http://yarnpkg.com/) (`yarn add localforage`).
Then simply include the JS file and start using localForage: `<script src="localforage.js"></script>`. You don't need to run any init method or wait for any `onready` events.
@ -66,6 +66,19 @@ localforage.getItem('somekey', function(err, value) {
// loaded from the offline store.
console.log(value);
});
Or, use `async`/`await`:
```js
try {
const value = await localforage.getItem('somekey');
// This code runs once the value has been loaded
// from the offline store.
console.log(value);
} catch (err) {
// This code runs if there were any errors.
console.log(err);
}
```
`getItem(key, successCallback)`
@ -504,7 +517,7 @@ Creates a new instance of localForage and returns it. Each object contains its o
```js
localforage.dropInstance().then(function() {
console.log('Dropped the store of the current instance').
console.log('Dropped the store of the current instance');
});
localforage.dropInstance({

11780
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,6 @@
},
"scripts": {
"build": "node -e \"require('grunt').cli()\" null build",
"precommit": "lint-staged",
"prettify": "prettier --write \"src/**/*.js\" \"test/**/*.js\"",
"publish-docs": "node -e \"require('grunt').cli()\" null copy build-rules-html publish-rules",
"serve": "node -e \"require('grunt').cli()\" null serve",
@ -45,17 +44,16 @@
"grunt-contrib-watch": "^0.5.0",
"grunt-es3-safe-recast": "^0.1.0",
"grunt-eslint": "^20.0.0",
"grunt-mocha": "^0.4.10",
"mocha-headless-chrome": "2.0.3",
"grunt-rollup": "^0.6.2",
"grunt-run": "^0.5.2",
"grunt-saucelabs": "^5.1.2",
"grunt-ts": "^6.0.0-beta.11",
"grunt-webpack": "^1.0.11",
"husky": "^0.14.3",
"lint-staged": "^5.0.0",
"husky": "^2.3.0",
"lint-staged": "^8.1.7",
"load-grunt-tasks": "^0.4.0",
"mocha": "^3.4.2",
"phantomjs": "^2.1.7",
"prettier": "~1.12.0",
"rollupify": "^0.1.0",
"script-loader": "^0.6.1",
@ -71,11 +69,5 @@
},
"dependencies": {
"lie": "3.1.1"
},
"lint-staged": {
"{src,test}/**/*.js": [
"prettier --write",
"git add"
]
}
}

View File

@ -575,7 +575,7 @@ function iterate(iterator, callback) {
iterationNumber++
);
// when the iterator callback retuns any
// when the iterator callback returns any
// (non-`undefined`) value, then we stop
// the iteration immediately
if (result !== void 0) {

View File

@ -4,7 +4,7 @@ function isIndexedDBValid() {
try {
// Initialize IndexedDB; fall back to vendor-prefixed versions
// if needed.
if (!idb) {
if (!idb || !idb.open) {
return false;
}
// We mimic PouchDB here;

View File

@ -51,7 +51,16 @@ describe('localForage', function() {
this.timeout(10000);
localforage.ready().then(
function() {
expect(localforage.driver()).to.be(appropriateDriver);
if (window.require) {
var appropriateDriver1 =
(localforage.supports(localforage.WEBSQL) &&
localforage.WEBSQL) ||
(localforage.supports(localforage.LOCALSTORAGE) &&
localforage.LOCALSTORAGE);
expect(localforage.driver()).to.be(appropriateDriver1);
} else {
expect(localforage.driver()).to.be(appropriateDriver);
}
done();
},
function(error) {
@ -196,6 +205,10 @@ describe('localForage', function() {
});
SUPPORTED_DRIVERS.forEach(function(driverName) {
if (this.require && 'asyncStorage' === driverName) {
console.warn('asyncStorage with requirejs not working well');
return;
}
describe(driverName + ' driver', function() {
'use strict';
@ -522,7 +535,7 @@ SUPPORTED_DRIVERS.forEach(function(driverName) {
});
});
it('should iterate [promise]', function(done) {
it('should iterate [promise]', function() {
var accumulator = {};
var iterationNumbers = [];
@ -556,7 +569,7 @@ SUPPORTED_DRIVERS.forEach(function(driverName) {
expect(accumulator.officeX).to.be('InitechX');
expect(accumulator.officeY).to.be('InitechY');
expect(iterationNumbers).to.eql([1, 2]);
done();
return;
});
});

View File

@ -5,6 +5,9 @@
<title>localForage Browserify Tests!</title>
<link rel="stylesheet" href="/bower_components/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="/bower_components/assert/assert.js"></script>
<script src="/bower_components/mocha/mocha.js"></script>
@ -14,12 +17,11 @@
<!-- Modernizr -->
<script src="/bower_components/modernizr/modernizr.js"></script>
<script> mocha.setup('bdd'); </script>
<!-- localForage -->
<script src="/test/localforage.browserify.js"></script>
<!-- Test runner -->
<script src="/test/runner.js"></script>
<!-- specs -->
<script src="/test/test.api.js"></script>
<script src="/test/test.config.js"></script>
@ -27,8 +29,11 @@
<script src="/test/test.drivers.js"></script>
<script src="/test/test.iframes.js"></script>
<script src="/test/test.webworkers.js"></script>
</head>
<body>
<div id="mocha"></div>
<!-- Disable warning -->
<script> window.console.warn = function(){}; </script>
<!-- Run tests -->
<script> mocha.run(); </script>
</body>
</html>

View File

@ -5,6 +5,9 @@
<title>localForage callWhenReady Tests!</title>
<link rel="stylesheet" href="/bower_components/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="/bower_components/assert/assert.js"></script>
<script src="/bower_components/mocha/mocha.js"></script>
@ -21,7 +24,6 @@
callWhenReady API method stubs -->
<script src="/test/test.callwhenready.js"></script>
<!-- Test runner -->
<script>
// Skip irrelevant config tests by mapping them to API tests so that
// they will not be called.
@ -32,10 +34,27 @@
}
}
});
var require = this.require;
if (require) {
requirejs.config({
paths: {
localforage: '/dist/localforage'
}
});
require(['localforage'], function(localforage) {
window.localforage = localforage;
require([
'/test/test.api.js',
'/test/test.config.js',
'/test/test.datatypes.js',
'/test/test.drivers.js',
'/test/test.iframes.js',
'/test/test.webworkers.js'
], mocha.run); // Run tests
});
}
// Disable warning
window.console.warn = function(){};
</script>
<script src="/test/runner.js"></script>
</head>
<body>
<div id="mocha"></div>
</body>
</html>

View File

@ -5,14 +5,16 @@
<title>localForage Custom Driver Tests!</title>
<link rel="stylesheet" href="/bower_components/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="/bower_components/assert/assert.js"></script>
<script src="/bower_components/mocha/mocha.js"></script>
<script src="/bower_components/expect/index.js"></script>
<!-- Test runner -->
<script src="/test/runner.js"></script>
<script> mocha.setup('bdd'); </script>
<!-- localForage -->
<script src="/dist/localforage.js"></script>
@ -22,8 +24,11 @@
<!-- specs -->
<script src="/test/test.customdriver.js"></script>
</head>
<body>
<div id="mocha"></div>
<!-- Disable warning -->
<script> window.console.warn = function(){}; </script>
<!-- Run tests -->
<script> mocha.run(); </script>
</body>
</html>

View File

@ -5,6 +5,9 @@
<title>localForage Tests!</title>
<link rel="stylesheet" href="/bower_components/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="/bower_components/assert/assert.js"></script>
<script src="/bower_components/mocha/mocha.js"></script>
@ -46,16 +49,18 @@
<!-- Modernizr -->
<script src="/bower_components/modernizr/modernizr.js"></script>
<!-- Test runner -->
<script src="/test/runner.js"></script>
<script> mocha.setup('bdd'); </script>
<!-- localForage -->
<script src="/dist/localforage.js"></script>
<!-- specs -->
<script src="/test/test.faultydriver.js"></script>
</head>
<body>
<div id="mocha"></div>
<!-- Disable warning -->
<script> window.console.warn = function(){}; </script>
<!-- Run tests -->
<script> mocha.run(); </script>
</body>
</html>

39
test/test.main1.html Normal file
View File

@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>localForage Tests!</title>
<link rel="stylesheet" href="/bower_components/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="/bower_components/assert/assert.js"></script>
<script src="/bower_components/mocha/mocha.js"></script>
<script src="/bower_components/expect/index.js"></script>
<!-- Modernizr -->
<script src="/bower_components/modernizr/modernizr.js"></script>
<script> mocha.setup('bdd'); </script>
<!-- localForage -->
<script src="/dist/localforage.js"></script>
<!-- specs -->
<script src="/test/test.api.js"></script>
<script src="/test/test.config.js"></script>
<script src="/test/test.datatypes.js"></script>
<script src="/test/test.drivers.js"></script>
<script src="/test/test.iframes.js"></script>
<script src="/test/test.webworkers.js"></script>
<script src="/test/test.serviceworkers.js"></script>
<!-- Disable warning -->
<script> window.console.warn = function(){}; </script>
<!-- Run tests -->
<script> mocha.run(); </script>
</body>
</html>

View File

@ -6,6 +6,9 @@
<link rel="stylesheet" type="text/css"
href="/bower_components/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="/bower_components/assert/assert.js"></script>
<script src="/bower_components/mocha/mocha.js"></script>
@ -15,8 +18,7 @@
<!-- Modernizr -->
<script src="/bower_components/modernizr/modernizr.js"></script>
<!-- Test runner -->
<script src="/test/runner.js"></script>
<script> mocha.setup('bdd'); </script>
<!-- localForage -->
<script src="/dist/localforage.min.js"></script>
@ -28,8 +30,11 @@
<script src="/test/test.drivers.js"></script>
<script src="/test/test.iframes.js"></script>
<script src="/test/test.webworkers.js"></script>
</head>
<body>
<div id="mocha"></div>
<!-- Disable warning -->
<script> window.console.warn = function(){}; </script>
<!-- Run tests -->
<script> mocha.run(); </script>
</body>
</html>

View File

@ -5,12 +5,17 @@
<title>localForage Tests!</title>
<link rel="stylesheet" href="/bower_components/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="/bower_components/assert/assert.js"></script>
<script src="/bower_components/mocha/mocha.js"></script>
<script src="/bower_components/expect/index.js"></script>
<script> mocha.setup('bdd'); </script>
<script>
// Virtually remove support for the drivers.
// This has to be done before localforage
@ -32,16 +37,18 @@
<!-- Modernizr -->
<script src="/bower_components/modernizr/modernizr.js"></script>
<!-- Test runner -->
<script src="/test/runner.js"></script>
<!-- localForage -->
<script src="/dist/localforage.js"></script>
<!-- specs -->
<script src="/test/test.nodriver.js"></script>
</head>
<body>
<div id="mocha"></div>
<!-- Disable warning -->
<script> window.console.warn = function(){}; </script>
<!-- Run tests -->
<script>this.mocha.run();</script>
</body>
</html>

View File

@ -9,10 +9,8 @@ describe('When No Drivers Are Available', function() {
];
it('agrees with Modernizr on storage drivers support', function() {
/* Used version of Modernizr doesn't support dissabling INDEXEDDB */
expect(localforage.supports(localforage.INDEXEDDB)).to.be(false);
expect(localforage.supports(localforage.INDEXEDDB)).to.be(
Modernizr.indexeddb
);
expect(localforage.supports(localforage.LOCALSTORAGE)).to.be(false);
expect(localforage.supports(localforage.LOCALSTORAGE)).to.be(

View File

@ -6,6 +6,9 @@
<link rel="stylesheet" type="text/css"
href="/bower_components/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script>
if (window.Promise) {
@ -20,16 +23,18 @@
<!-- Modernizr -->
<script src="/bower_components/modernizr/modernizr.js"></script>
<!-- Test runner -->
<script src="/test/runner.js"></script>
<script> mocha.setup('bdd'); </script>
<!-- localForage -->
<script src="/dist/localforage.min.js"></script>
<!-- specs -->
<script src="/test/test.api.js"></script>
</head>
<body>
<div id="mocha"></div>
<!-- Disable warning -->
<script> window.console.warn = function(){}; </script>
<!-- Run tests -->
<script> mocha.run(); </script>
</body>
</html>

View File

@ -5,6 +5,9 @@
<title>localForage require.js Tests!</title>
<link rel="stylesheet" href="/bower_components/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="/bower_components/assert/assert.js"></script>
<script src="/bower_components/mocha/mocha.js"></script>
@ -17,10 +20,30 @@
<!-- Modernizr -->
<script src="/bower_components/modernizr/modernizr.js"></script>
<!-- Test runner -->
<script src="/test/runner.js"></script>
</head>
<body>
<div id="mocha"></div>
<script> mocha.setup('bdd'); </script>
<script>
var require = this.require;
if (require) {
requirejs.config({
paths: {
localforage: '/dist/localforage'
}
});
require(['localforage'], function(localforage) {
window.localforage = localforage;
require([
'/test/test.api.js',
'/test/test.config.js',
'/test/test.datatypes.js',
'/test/test.drivers.js',
'/test/test.iframes.js',
'/test/test.webworkers.js'
], mocha.run); // Run tests
});
}
// Disable warning
window.console.warn = function(){};
</script>
</body>
</html>

View File

@ -5,6 +5,9 @@
<title>localForage WebPack Tests!</title>
<link rel="stylesheet" href="/bower_components/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="/bower_components/assert/assert.js"></script>
<script src="/bower_components/mocha/mocha.js"></script>
@ -17,8 +20,7 @@
<!-- localForage -->
<script src="/test/localforage.webpack.js"></script>
<!-- Test runner -->
<script src="/test/runner.js"></script>
<script> mocha.setup('bdd'); </script>
<!-- specs -->
<script src="/test/test.api.js"></script>
@ -27,8 +29,11 @@
<script src="/test/test.drivers.js"></script>
<script src="/test/test.iframes.js"></script>
<script src="/test/test.webworkers.js"></script>
</head>
<body>
<div id="mocha"></div>
<!-- Disable warning -->
<script> window.console.warn = function(){}; </script>
<!-- Run tests -->
<script> mocha.run(); </script>
</body>
</html>