mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
76 lines
1.3 KiB
HTML
76 lines
1.3 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test for DataStore - duplicate keys</title>
|
|
</head>
|
|
<body>
|
|
<div id="container"></div>
|
|
<script type="application/javascript;version=1.7">
|
|
|
|
var gStore;
|
|
var gEvent;
|
|
var gChangeId;
|
|
|
|
function ok(a, msg) {
|
|
alert((a ? 'OK' : 'KO')+ ' ' + msg)
|
|
}
|
|
|
|
function is(a, b, msg) {
|
|
ok(a === b, msg);
|
|
}
|
|
|
|
function cbError() {
|
|
alert('KO error');
|
|
}
|
|
|
|
function finish() {
|
|
alert('DONE');
|
|
}
|
|
|
|
function testGetDataStores() {
|
|
navigator.getDataStores('foo').then(function(stores) {
|
|
gStore = stores[0];
|
|
runTest();
|
|
}, cbError);
|
|
}
|
|
|
|
function testAdd(success) {
|
|
gStore.add({ a: 42 }, 'test').then(function() {
|
|
is(success, true, "Record added");
|
|
runTest();
|
|
}, function(e) {
|
|
is(success, false, "Record failed");
|
|
ok(e instanceof DOMError, "DOMError received");
|
|
is(e.name, 'ConstraintError', 'e.name: ConstraintError');
|
|
is(e.message, '', 'e.message');
|
|
runTest();
|
|
});
|
|
}
|
|
|
|
var tests = [
|
|
// Test for GetDataStore
|
|
testGetDataStores,
|
|
|
|
// add
|
|
function() { testAdd(true); },
|
|
|
|
// add duplicate
|
|
function() { testAdd(false); }
|
|
];
|
|
|
|
function runTest() {
|
|
if (!tests.length) {
|
|
finish();
|
|
return;
|
|
}
|
|
|
|
var test = tests.shift();
|
|
test();
|
|
}
|
|
|
|
runTest();
|
|
</script>
|
|
</body>
|
|
</html>
|