Bug 1363982 - Update web-platform-tests to revision db6ed4bb451e44748cbb9af69d0a01c17a33571a a=testonly

MozReview-Commit-ID: KjIquC2PKKI


--HG--
rename : testing/web-platform/tests/WebCryptoAPI/derive_bits_keys/test_ecdh_bits.html => testing/web-platform/tests/WebCryptoAPI/derive_bits_keys/test_ecdh_bits.https.html
rename : testing/web-platform/tests/WebCryptoAPI/derive_bits_keys/test_ecdh_keys.html => testing/web-platform/tests/WebCryptoAPI/derive_bits_keys/test_ecdh_keys.https.html
rename : testing/web-platform/tests/WebCryptoAPI/derive_bits_keys/test_hkdf.html => testing/web-platform/tests/WebCryptoAPI/derive_bits_keys/test_hkdf.https.html
rename : testing/web-platform/tests/WebCryptoAPI/digest/test_digest.html => testing/web-platform/tests/WebCryptoAPI/digest/test_digest.https.html
rename : testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_aes_cbc.html => testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_aes_cbc.https.html
rename : testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_aes_ctr.html => testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_aes_ctr.https.html
rename : testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_aes_gcm.html => testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_aes_gcm.https.html
rename : testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep.html => testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_aes-cbc.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_aes-cbc.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_aes-ctr.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_aes-ctr.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-CBC.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-CBC.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-CTR.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-CTR.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-GCM.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-GCM.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-KW.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-KW.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_ECDH.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_ECDH.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_ECDSA.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_ECDSA.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_HMAC.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_HMAC.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_RSA-OAEP.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_RSA-OAEP.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_RSA-PSS.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_RSA-PSS.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_RSASSA-PKCS1-v1_5.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_RSASSA-PKCS1-v1_5.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-CBC.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-CBC.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-CTR.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-CTR.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-GCM.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-GCM.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-KW.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-KW.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_ECDH.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_ECDH.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_ECDSA.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_ECDSA.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_HMAC.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_HMAC.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_RSA-PSS.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_RSA-PSS.https.html
rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_RSASSA-PKCS1-v1_5.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_RSASSA-PKCS1-v1_5.https.html
rename : testing/web-platform/tests/WebCryptoAPI/import_export/test_ec_importKey.html => testing/web-platform/tests/WebCryptoAPI/import_export/test_ec_importKey.https.html
rename : testing/web-platform/tests/WebCryptoAPI/import_export/test_rsa_importKey.html => testing/web-platform/tests/WebCryptoAPI/import_export/test_rsa_importKey.https.html
rename : testing/web-platform/tests/WebCryptoAPI/import_export/test_symmetric_importKey.html => testing/web-platform/tests/WebCryptoAPI/import_export/test_symmetric_importKey.https.html
rename : testing/web-platform/tests/WebCryptoAPI/sign_verify/test_ecdsa.html => testing/web-platform/tests/WebCryptoAPI/sign_verify/test_ecdsa.https.html
rename : testing/web-platform/tests/WebCryptoAPI/sign_verify/test_hmac.html => testing/web-platform/tests/WebCryptoAPI/sign_verify/test_hmac.https.html
rename : testing/web-platform/tests/WebCryptoAPI/sign_verify/test_rsa_pkcs.html => testing/web-platform/tests/WebCryptoAPI/sign_verify/test_rsa_pkcs.https.html
rename : testing/web-platform/tests/WebCryptoAPI/sign_verify/test_rsa_pss.html => testing/web-platform/tests/WebCryptoAPI/sign_verify/test_rsa_pss.https.html
rename : testing/web-platform/tests/WebCryptoAPI/wrapKey_unwrapKey/test_wrapKey_unwrapKey.html => testing/web-platform/tests/WebCryptoAPI/wrapKey_unwrapKey/test_wrapKey_unwrapKey.https.html
rename : testing/web-platform/tests/html/browsers/windows/browsing-context-names/browsing-context-_blank.html => testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-001.html
rename : testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/parent-iframe-3.html => testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-003-iframe.html
rename : testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/parent-iframe-2.html => testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/open-in-_parent.html
rename : testing/web-platform/tests/presentation-api/receiving-ua/support/idlharness_receiving-ua.https.html => testing/web-platform/tests/presentation-api/receiving-ua/support/idlharness_receiving-ua.html
rename : testing/web-platform/tests/tools/LICENSE => testing/web-platform/tests/tools/wptrunner/LICENSE
rename : testing/web-platform/tests/auxclick/auxclick_event-manual.html => testing/web-platform/tests/uievents/auxclick/auxclick_event-manual.html
rename : testing/web-platform/tests/webrtc/rtcpeerconnection/rtcconfiguration-icecandidatepoolsize.html => testing/web-platform/tests/webrtc/RTCConfiguration-iceCandidatePoolSize.html
rename : testing/web-platform/tests/webrtc/rtcpeerconnection/rtcpeerconnection-constructor.html => testing/web-platform/tests/webrtc/RTCPeerConnection-constructor.html
rename : testing/web-platform/tests/webrtc/rtcpeerconnection/iceGatheringState.html => testing/web-platform/tests/webrtc/RTCPeerConnection-iceGatheringState.html
rename : testing/web-platform/tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html => testing/web-platform/tests/webrtc/RTCPeerConnection-idl.html
This commit is contained in:
James Graham 2017-05-05 18:42:42 +01:00
Родитель 844f99874d
Коммит b598a77d59
1345 изменённых файлов: 83932 добавлений и 9231 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,2 +1,2 @@
local: 0000000000000000000000000000000000000000
upstream: 8181d7f09ee35cb521452bb727a48a1667901afd
local: 0b255199db9d6a6f189b89b7906f99155bde3726
upstream: 72d174747fe176cbefcba315b445fac99d3dbfb2

Просмотреть файл

@ -0,0 +1,6 @@
comment:
require_changes: yes
ignore:
- "**"
- "!tools/.*"

14
testing/web-platform/tests/.gitmodules поставляемый
Просмотреть файл

@ -1,14 +1,12 @@
[submodule "resources"]
path = resources
url = https://github.com/w3c/testharness.js.git
ignore = dirty
[submodule "tools"]
path = tools
url = https://github.com/w3c/wpt-tools.git
ignore = dirty
[submodule "css/tools/apiclient"]
path = css/tools/apiclient
url = https://github.com/w3c/csswg-apiclient.git
[submodule "css/tools/w3ctestlib"]
path = css/tools/w3ctestlib
url = https://github.com/w3c/csswg-w3ctestlib.git
[submodule "tools/html5lib/html5lib/tests/testdata"]
path = tools/html5lib/html5lib/tests/testdata
url = https://github.com/html5lib/html5lib-tests.git
[submodule "resources/webidl2/test/widlproc"]
path = resources/webidl2/test/widlproc
url = https://github.com/dontcallmedom/widlproc.git

Просмотреть файл

@ -1,6 +1,9 @@
dist: trusty
sudo: required
language: python
branches:
only:
- master
addons:
hosts:
- web-platform.test
@ -18,6 +21,7 @@ install:
- pip install -U requests
env: # required at the top-level for allow_failures to work below
matrix:
fast_finish: true
include:
- os: linux
python: "2.7"
@ -48,10 +52,21 @@ matrix:
env:
- secure: "YTSXPwI0DyCA1GhYrLT9KMEV6b7QQKuEeaQgeFDP38OTzJ1+cIj3CC4SRNqbnJ/6SJwPGcdqSxLuV8m4e5HFFnyCcQnJe6h8EMsTehZ7W3j/fP9UYrJqYqvGpe3Vj3xblO5pwBYmq7sg3jAmmuCgAgOW6VGf7cRMucrsmFeo7VM="
- SCRIPT=ci_stability.sh PRODUCT=chrome:unstable
- python: 2.7
env: TOXENV=py27 HYPOTHESIS_PROFILE=ci SCRIPT=ci_unittest.sh
- python: 3.5
env: TOXENV=py35 HYPOTHESIS_PROFILE=ci SCRIPT=ci_unittest.sh
- python: 3.6
env: TOXENV=py36 HYPOTHESIS_PROFILE=ci SCRIPT=ci_unittest.sh
- python: pypy
env: TOXENV=pypy HYPOTHESIS_PROFILE=ci_pypy SCRIPT=ci_unittest.sh
exclude:
- env: # exclude empty env from the top-level above
allow_failures:
- env: SCRIPT=css/build-css-testsuites.sh
- env:
- secure: "YTSXPwI0DyCA1GhYrLT9KMEV6b7QQKuEeaQgeFDP38OTzJ1+cIj3CC4SRNqbnJ/6SJwPGcdqSxLuV8m4e5HFFnyCcQnJe6h8EMsTehZ7W3j/fP9UYrJqYqvGpe3Vj3xblO5pwBYmq7sg3jAmmuCgAgOW6VGf7cRMucrsmFeo7VM="
- SCRIPT=ci_stability.sh PRODUCT=chrome:unstable
script:
- bash $SCRIPT
cache:

Двоичные данные
testing/web-platform/tests/2dcontext/2x4.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.7 KiB

Двоичные данные
testing/web-platform/tests/2dcontext/4x2.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Просмотреть файл

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html class="reftest-wait">
<meta charset="utf-8">
<title>Canvas test: 2d.drawImage.crop.2x4</title>
<link rel="match" href="drawimage_html_image_14_ref.html">
<style>
html, body {
margin: 0;
}
</style>
<canvas id="dest" height="100" width="100"></canvas>
<script>
var sourceWidth = 256;
var sourceHeight = 512;
var smoothingEnabled = false;
var destCanvas = document.getElementById('dest');
var sourceImg = document.createElement('img');
sourceImg.src = '../2x4.png'
sourceImg.width = sourceWidth;
sourceImg.height = sourceHeight;
sourceImg.onload = function() {
var destCtx = destCanvas.getContext('2d');
destCtx.fillStyle = "#FF0000";
destCtx.fillRect(0, 0, destCanvas.width, destCanvas.height);
destCtx.imageSmoothingEnabled = smoothingEnabled;
destCtx.drawImage(sourceImg, 64, 64, 192, 448, 0, 0, 30, 70);
document.documentElement.classList.remove('reftest-wait');
}
</script>

Просмотреть файл

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<style>
html, body {
margin: 0;
}
#destination {
width: 100px;
height: 100px;
background-color: red;
background-image: url("../2x4.png");
background-position: -10px -10px;
background-size: 40px 80px;
background-repeat: no-repeat;
}
</style>
<body>
<div id="destination"></div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html class="reftest-wait">
<meta charset="utf-8">
<title>Canvas test: 2d.drawImage.crop.4x2</title>
<link rel="match" href="drawimage_html_image_15_ref.html">
<style>
html, body {
margin: 0;
}
</style>
<canvas id="dest" height="100" width="100"></canvas>
<script>
var sourceWidth = 512;
var sourceHeight = 256;
var smoothingEnabled = false;
var destCanvas = document.getElementById('dest');
var sourceImg = document.createElement('img');
sourceImg.src = '../4x2.png'
sourceImg.width = sourceWidth;
sourceImg.height = sourceHeight;
sourceImg.onload = function() {
var destCtx = destCanvas.getContext('2d');
destCtx.fillStyle = "#FF0000";
destCtx.fillRect(0, 0, destCanvas.width, destCanvas.height);
destCtx.imageSmoothingEnabled = smoothingEnabled;
destCtx.drawImage(sourceImg, 64, 64, 448, 192, 0, 0, 70, 30);
document.documentElement.classList.remove('reftest-wait');
}
</script>

Просмотреть файл

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<style>
html, body {
margin: 0;
}
#destination {
width: 100px;
height: 100px;
background-color: red;
background-image: url("../4x2.png");
background-position: -10px -10px;
background-size: 80px 40px;
background-repeat: no-repeat;
}
</style>
<body>
<div id="destination"></div>
</body>
</html>

Просмотреть файл

@ -235,10 +235,6 @@ def genTestUtils(TESTOUTPUTDIR, IMAGEOUTPUTDIR, TEMPLATEFILE, NAME2DIRFILE, ISOF
r'assert_throws(new \1(), function() { \2; });',
code)
code = re.sub(r'@assert throws (.*);',
r'assert_throws(null, function() { \1; });',
code)
code = re.sub(r'@assert (.*) === (.*);',
lambda m: '_assertSame(%s, %s, "%s", "%s");'
% (m.group(1), m.group(2), escapeJS(m.group(1)), escapeJS(m.group(2)))

Просмотреть файл

@ -8,6 +8,7 @@
<script>
var db, count = 0,
t = async_test();
t.add_cleanup(function() { indexedDB.deleteDatabase('webworker101'); });
t.step(function() {
var worker = new Worker("idbworker.js");
@ -27,7 +28,4 @@
worker.postMessage(1);
})
</script>
<div id="log"></div>

Просмотреть файл

@ -7,180 +7,175 @@
<script>
var db, open;
function upgrade_func(t, db, tx) {
var objStore = db.createObjectStore("test");
objStore.createIndex("index", "");
setup(function() {
open = indexedDB.open('testdb-' + new Date().getTime());
open.onupgradeneeded = function(e) {
db = e.target.result;
var objStore = db.createObjectStore("test");
objStore.createIndex("index", "");
objStore.add("data", 1);
objStore.add("data2", 2);
}
objStore.add("data", 1);
objStore.add("data2", 2);
};
},
{ explicit_done: true });
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").openCursor();
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
t.done();
return;
}
var cursor = e.target.result;
open.onsuccess = function() {
switch(count) {
case 0:
assert_equals(cursor.value, "data")
assert_equals(cursor.key, 1)
cursor.advance(1)
assert_equals(cursor.value, "data")
assert_equals(cursor.key, 1)
break
case 1:
assert_equals(cursor.value, "data2")
assert_equals(cursor.key, 2)
cursor.advance(1)
assert_equals(cursor.value, "data2")
assert_equals(cursor.key, 2)
break
async_test(document.title + " - advance").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").openCursor();
default:
assert_unreached("Unexpected count: " + count)
}
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
this.done();
return;
}
var cursor = e.target.result;
count++;
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - advance"
);
switch(count) {
case 0:
assert_equals(cursor.value, "data")
assert_equals(cursor.key, 1)
cursor.advance(1)
assert_equals(cursor.value, "data")
assert_equals(cursor.key, 1)
break
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
case 1:
assert_equals(cursor.value, "data2")
assert_equals(cursor.key, 2)
cursor.advance(1)
assert_equals(cursor.value, "data2")
assert_equals(cursor.key, 2)
break
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
t.done();
return;
}
var cursor = e.target.result;
default:
assert_unreached("Unexpected count: " + count)
}
switch(count) {
case 0:
assert_equals(cursor.value, "data")
assert_equals(cursor.key, "data")
assert_equals(cursor.primaryKey, 1)
cursor.continue("data2")
assert_equals(cursor.value, "data")
assert_equals(cursor.key, "data")
assert_equals(cursor.primaryKey, 1)
break
count++;
});
rq.onerror = fail(this, "unexpected error")
});
case 1:
assert_equals(cursor.value, "data2")
assert_equals(cursor.key, "data2")
assert_equals(cursor.primaryKey, 2)
cursor.continue()
assert_equals(cursor.value, "data2")
assert_equals(cursor.key, "data2")
assert_equals(cursor.primaryKey, 2)
break
default:
assert_unreached("Unexpected count: " + count)
}
async_test(document.title + " - continue").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
count++;
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - continue"
);
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
this.done();
return;
}
var cursor = e.target.result;
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
switch(count) {
case 0:
assert_equals(cursor.value, "data")
assert_equals(cursor.key, "data")
assert_equals(cursor.primaryKey, 1)
cursor.continue("data2")
assert_equals(cursor.value, "data")
assert_equals(cursor.key, "data")
assert_equals(cursor.primaryKey, 1)
break
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
t.done();
return;
}
var cursor = e.target.result;
cursor.advance(1)
case 1:
assert_equals(cursor.value, "data2")
assert_equals(cursor.key, "data2")
assert_equals(cursor.primaryKey, 2)
cursor.continue()
assert_equals(cursor.value, "data2")
assert_equals(cursor.key, "data2")
assert_equals(cursor.primaryKey, 2)
break
switch(count) {
case 0:
assert_equals(cursor.value, "data")
assert_equals(cursor.key, "data")
assert_equals(cursor.primaryKey, 1)
break
default:
assert_unreached("Unexpected count: " + count)
}
case 1:
assert_equals(cursor.value, "data2")
assert_equals(cursor.key, "data2")
assert_equals(cursor.primaryKey, 2)
break
count++;
});
rq.onerror = fail(this, "unexpected error")
});
default:
assert_unreached("Unexpected count: " + count)
}
count++;
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - fresh advance still async"
);
async_test(document.title + " - fresh advance still async").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").openCursor();
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
this.done();
return;
}
var cursor = e.target.result;
cursor.advance(1)
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
t.done();
return;
}
var cursor = e.target.result;
cursor.continue()
switch(count) {
case 0:
assert_equals(cursor.value, "data")
assert_equals(cursor.key, "data")
assert_equals(cursor.primaryKey, 1)
break
switch(count) {
case 0:
assert_equals(cursor.value, "data")
assert_equals(cursor.key, 1)
break
case 1:
assert_equals(cursor.value, "data2")
assert_equals(cursor.key, "data2")
assert_equals(cursor.primaryKey, 2)
break
case 1:
assert_equals(cursor.value, "data2")
assert_equals(cursor.key, 2)
break
default:
assert_unreached("Unexpected count: " + count)
}
count++;
});
rq.onerror = fail(this, "unexpected error")
});
async_test(document.title + " - fresh continue still async").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").openCursor();
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
this.done();
return;
}
var cursor = e.target.result;
cursor.continue()
switch(count) {
case 0:
assert_equals(cursor.value, "data")
assert_equals(cursor.key, 1)
break
case 1:
assert_equals(cursor.value, "data2")
assert_equals(cursor.key, 2)
break
default:
assert_unreached("Unexpected count: " + count)
}
count++;
});
rq.onerror = fail(this, "unexpected error")
});
// Stop blocking the testing system from hereon
done();
}
default:
assert_unreached("Unexpected count: " + count)
}
count++;
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - fresh continue still async"
);
</script>
<div id=log></div>

Просмотреть файл

@ -13,176 +13,180 @@
<script>
var db, open;
function upgrade_func(t, db, tx) {
var objStore = db.createObjectStore("test");
objStore.createIndex("index", "");
setup(function() {
open = indexedDB.open('testdb-' + new Date().getTime());
open.onupgradeneeded = function(e) {
db = e.target.result;
var objStore = db.createObjectStore("test");
objStore.createIndex("index", "");
objStore.add("data", 1);
objStore.add("data2", 2);
}
objStore.add("data", 1);
objStore.add("data2", 2);
};
},
{ explicit_done: true });
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
t.done();
return;
}
var cursor = e.target.result;
open.onsuccess = function() {
cursor.advance(1);
async_test(document.title + " - attempt to call advance twice").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
this.done();
return;
}
var cursor = e.target.result;
cursor.advance(1);
// Second try
assert_throws('InvalidStateError',
// Second try
assert_throws('InvalidStateError',
function() { cursor.advance(1); }, 'second advance');
assert_throws('InvalidStateError',
assert_throws('InvalidStateError',
function() { cursor.advance(3); }, 'third advance');
count++;
});
rq.onerror = fail(this, "unexpected error")
});
count++;
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - attempt to call advance twice"
);
indexeddb_test(
upgrade_func,
function(t, db) {
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
async_test(document.title + " - pass something other than number").step(function(e) {
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
rq.onsuccess = this.step_func(function(e) {
var cursor = e.target.result;
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance(document); });
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance({}); });
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance([]); });
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance(""); });
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance("1 2"); });
this.done();
});
rq.onerror = fail(this, "unexpected error")
});
t.done();
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - pass something other than number"
);
async_test(document.title + " - pass null/undefined").step(function(e) {
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
indexeddb_test(
upgrade_func,
function(t, db) {
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
rq.onsuccess = this.step_func(function(e) {
var cursor = e.target.result;
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance(null); });
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance(undefined); });
var myvar = null;
assert_throws({ name: "TypeError" },
var myvar = null;
assert_throws({ name: "TypeError" },
function() { cursor.advance(myvar); });
this.done();
});
rq.onerror = fail(this, "unexpected error")
});
t.done();
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - pass null/undefined"
);
async_test(document.title + " - missing argument").step(function(e) {
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
indexeddb_test(
upgrade_func,
function(t, db) {
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
rq.onsuccess = this.step_func(function(e) {
var cursor = e.target.result;
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance(); });
this.done();
});
rq.onerror = fail(this, "unexpected error")
});
t.done();
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - missing argument"
);
indexeddb_test(
upgrade_func,
function(t, db) {
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
async_test(document.title + " - pass negative numbers").step(function(e) {
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
rq.onsuccess = this.step_func(function(e) {
var cursor = e.target.result;
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance(-1); });
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance(NaN); });
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance(0); });
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance(-0); });
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance(Infinity); });
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance(-Infinity); });
var myvar = -999999;
assert_throws({ name: "TypeError" },
var myvar = -999999;
assert_throws({ name: "TypeError" },
function() { cursor.advance(myvar); });
this.done();
});
rq.onerror = fail(this, "unexpected error")
});
t.done();
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - pass negative numbers"
);
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
async_test(document.title + " - got value not set on exception").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
if (!cursor)
{
assert_equals(count, 2, "count runs");
t.done();
return;
}
rq.onsuccess = this.step_func(function(e) {
var cursor = e.target.result;
if (!cursor)
{
assert_equals(count, 2, "count runs");
this.done();
return;
}
assert_throws({ name: "TypeError" },
assert_throws({ name: "TypeError" },
function() { cursor.advance(0); });
cursor.advance(1);
count++;
});
rq.onerror = fail(this, "unexpected error")
});
// Stop blocking the testing system from hereon
done();
}
cursor.advance(1);
count++;
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - got value not set on exception"
);
</script>
<div id=log></div>

Просмотреть файл

@ -7,237 +7,241 @@
<script>
var db, open;
function upgrade_func(t, db, tx) {
var objStore = db.createObjectStore("test");
objStore.createIndex("index", "");
setup(function() {
open = indexedDB.open("testdb-" + new Date().getTime());
open.onupgradeneeded = function(e) {
db = e.target.result;
var objStore = db.createObjectStore("test");
objStore.createIndex("index", "");
objStore.add("cupcake", 5);
objStore.add("pancake", 3); // Yes, it is intended
objStore.add("pie", 1);
objStore.add("pie", 4);
objStore.add("taco", 2);
}
objStore.add("cupcake", 5);
objStore.add("pancake", 3); // Yes, it is intended
objStore.add("pie", 1);
objStore.add("pie", 4);
objStore.add("taco", 2);
};
},
{ explicit_done: true });
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 3, "count");
t.done();
return;
}
var cursor = e.target.result;
open.onsuccess = function() {
switch(count) {
case 0:
assert_equals(cursor.value, "cupcake");
assert_equals(cursor.primaryKey, 5);
break;
async_test(document.title + " - advances").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 1);
break;
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 3, "count");
this.done();
return;
}
var cursor = e.target.result;
case 2:
assert_equals(cursor.value, "taco");
assert_equals(cursor.primaryKey, 2);
break;
switch(count) {
case 0:
assert_equals(cursor.value, "cupcake");
assert_equals(cursor.primaryKey, 5);
break;
default:
assert_unreached("Unexpected count: " + count);
}
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 1);
break;
count++;
cursor.advance(2);
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - advances"
);
case 2:
assert_equals(cursor.value, "taco");
assert_equals(cursor.primaryKey, 2);
break;
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor(null, "prev");
default:
assert_unreached("Unexpected count: " + count);
}
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 3, "count");
t.done();
return;
}
var cursor = e.target.result;
count++;
cursor.advance(2);
});
rq.onerror = fail(this, "unexpected error")
});
switch(count) {
case 0:
assert_equals(cursor.value, "taco");
assert_equals(cursor.primaryKey, 2);
break;
async_test(document.title + " - advances backwards").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor(null, "prev");
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 1);
break;
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 3, "count");
this.done();
return;
}
var cursor = e.target.result;
case 2:
assert_equals(cursor.value, "cupcake");
assert_equals(cursor.primaryKey, 5);
break;
switch(count) {
case 0:
assert_equals(cursor.value, "taco");
assert_equals(cursor.primaryKey, 2);
break;
default:
assert_unreached("Unexpected count: " + count);
}
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 1);
break;
count++;
cursor.advance(2);
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - advances backwards"
);
case 2:
assert_equals(cursor.value, "cupcake");
assert_equals(cursor.primaryKey, 5);
break;
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor();
default:
assert_unreached("Unexpected count: " + count);
}
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 1, "count");
t.done();
return;
}
var cursor = e.target.result;
count++;
cursor.advance(2);
});
rq.onerror = fail(this, "unexpected error")
});
switch(count) {
case 0:
assert_equals(cursor.value, "cupcake");
assert_equals(cursor.primaryKey, 5);
break;
async_test(document.title + " - skip far forward").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor();
default:
assert_unreached("Unexpected count: " + count);
}
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 1, "count");
this.done();
return;
}
var cursor = e.target.result;
count++;
cursor.advance(100000);
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - skip far forward"
);
switch(count) {
case 0:
assert_equals(cursor.value, "cupcake");
assert_equals(cursor.primaryKey, 5);
break;
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor(IDBKeyRange.lowerBound("cupcake", true));
default:
assert_unreached("Unexpected count: " + count);
}
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, "count");
t.done();
return;
}
var cursor = e.target.result;
count++;
cursor.advance(100000);
});
rq.onerror = fail(this, "unexpected error")
});
switch(count) {
case 0:
assert_equals(cursor.value, "pancake");
assert_equals(cursor.primaryKey, 3);
break;
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 4);
break;
async_test(document.title + " - within range").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor(IDBKeyRange.lowerBound("cupcake", true));
default:
assert_unreached("Unexpected count: " + count);
}
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, "count");
this.done();
return;
}
var cursor = e.target.result;
count++;
cursor.advance(2);
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - within range"
);
switch(count) {
case 0:
assert_equals(cursor.value, "pancake");
assert_equals(cursor.primaryKey, 3);
break;
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor("pancake");
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 4);
break;
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 1, "count");
t.done();
return;
}
var cursor = e.target.result;
default:
assert_unreached("Unexpected count: " + count);
}
switch(count) {
case 0:
assert_equals(cursor.value, "pancake");
assert_equals(cursor.primaryKey, 3);
break;
count++;
cursor.advance(2);
});
rq.onerror = fail(this, "unexpected error")
});
default:
assert_unreached("Unexpected count: " + count);
}
count++;
cursor.advance(1);
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - within single key range"
);
async_test(document.title + " - within single key range").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor("pancake");
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor("pie");
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 1, "count");
this.done();
return;
}
var cursor = e.target.result;
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, "count");
t.done();
return;
}
var cursor = e.target.result;
switch(count) {
case 0:
assert_equals(cursor.value, "pancake");
assert_equals(cursor.primaryKey, 3);
break;
switch(count) {
case 0:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 1);
break;
default:
assert_unreached("Unexpected count: " + count);
}
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 4);
break;
count++;
cursor.advance(1);
});
rq.onerror = fail(this, "unexpected error")
});
default:
assert_unreached("Unexpected count: " + count);
}
async_test(document.title + " - within single key range, with several results").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor("pie");
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, "count");
this.done();
return;
}
var cursor = e.target.result;
switch(count) {
case 0:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 1);
break;
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 4);
break;
default:
assert_unreached("Unexpected count: " + count);
}
count++;
cursor.advance(1);
});
rq.onerror = fail(this, "unexpected error")
});
// Stop blocking the testing system from hereon
done();
}
count++;
cursor.advance(1);
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - within single key range, with several results"
);
</script>
<div id="log"></div>

Просмотреть файл

@ -9,232 +9,240 @@
<script>
var db, open;
var store = [ { value: "cupcake", key: 5 },
{ value: "pancake", key: 3 },
{ value: "pie", key: 1 },
{ value: "pie", key: 4 },
{ value: "taco", key: 2 } ];
var store = [ { value: "cupcake", key: 5 },
{ value: "pancake", key: 3 },
{ value: "pie", key: 1 },
{ value: "pie", key: 4 },
{ value: "taco", key: 2 } ];
setup(function() {
open = indexedDB.open('testdb-' + new Date().getTime());
open.onupgradeneeded = function(e) {
var os, i;
db = e.target.result;
os = db.createObjectStore("test");
os.createIndex("index", "");
function upgrade_func(t, db, tx) {
var db, open;
for (i = 0; i < store.length; i++)
os.add(store[i].value, store[i].key);
};
},
{ explicit_done: true });
var os, i;
os = db.createObjectStore("test");
os.createIndex("index", "");
for (i = 0; i < store.length; i++)
os.add(store[i].value, store[i].key);
}
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 5, 'count');
t.done();
return;
}
var cursor = e.target.result;
assert_equals(cursor.value, store[count].value);
assert_equals(cursor.primaryKey, store[count].key);
cursor.continue();
count++;
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - continues"
);
open.onsuccess = function() {
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 3, 'count');
t.done();
return;
}
var cursor = e.target.result;
switch(count) {
case 0:
assert_equals(cursor.value, "cupcake");
assert_equals(cursor.primaryKey, 5);
cursor.continue("pie");
break;
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 1);
cursor.continue("taco");
break;
case 2:
assert_equals(cursor.value, "taco");
assert_equals(cursor.primaryKey, 2);
cursor.continue();
break;
default:
assert_unreached("Unexpected count: " + count);
}
count++;
});
rq.onerror = t.unreached_func("unexpected error")
},
document.title + " - with given key"
);
async_test(document.title + " - continues").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor();
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 5, 'count');
this.done();
return;
}
var cursor = e.target.result;
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 1, 'count');
t.done();
return;
}
var cursor = e.target.result;
assert_equals(cursor.value, store[count].value);
assert_equals(cursor.primaryKey, store[count].key);
switch(count) {
case 0:
assert_equals(cursor.value, "cupcake");
assert_equals(cursor.primaryKey, 5);
break;
cursor.continue();
default:
assert_unreached("Unexpected count: " + count);
}
count++;
});
rq.onerror = fail(this, "unexpected error")
});
count++;
cursor.continue([]); // Arrays are always bigger than strings
});
rq.onerror = t.unreached_func("unexpected error2")
},
document.title + " - skip far forward"
);
async_test(document.title + " - with given key").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index").openCursor();
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor(IDBKeyRange.lowerBound("cupcake", true));
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 3, 'count');
this.done();
return;
}
var cursor = e.target.result;
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
t.done();
return;
}
var cursor = e.target.result;
switch(count) {
case 0:
assert_equals(cursor.value, "cupcake");
assert_equals(cursor.primaryKey, 5);
cursor.continue("pie");
break;
switch(count) {
case 0:
assert_equals(cursor.value, "pancake");
assert_equals(cursor.primaryKey, 3);
cursor.continue("pie");
break;
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 1);
cursor.continue("taco");
break;
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 1);
cursor.continue("zzz");
break;
case 2:
assert_equals(cursor.value, "taco");
assert_equals(cursor.primaryKey, 2);
cursor.continue();
break;
default:
assert_unreached("Unexpected count: " + count);
}
default:
assert_unreached("Unexpected count: " + count);
}
count++;
});
rq.onerror = fail(this, "unexpected error")
});
count++;
});
rq.onerror = t.unreached_func("unexpected error1")
},
document.title + " - within range"
);
async_test(document.title + " - skip far forward").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor();
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor("pancake");
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 1, 'count');
this.done();
return;
}
var cursor = e.target.result;
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 1, 'count');
t.done();
return;
}
var cursor = e.target.result;
switch(count) {
case 0:
assert_equals(cursor.value, "cupcake");
assert_equals(cursor.primaryKey, 5);
break;
switch(count) {
case 0:
assert_equals(cursor.value, "pancake");
assert_equals(cursor.primaryKey, 3);
cursor.continue("pie");
break;
default:
assert_unreached("Unexpected count: " + count);
}
default:
assert_unreached("Unexpected count: " + count);
}
count++;
cursor.continue([]); // Arrays are always bigger than strings
count++;
});
rq.onerror = t.unreached_func("unexpected error1")
},
document.title + " - within single key range"
);
});
rq.onerror = fail(this, "unexpected error2")
});
indexeddb_test(
upgrade_func,
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor("pie");
rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
t.done();
return;
}
var cursor = e.target.result;
async_test(document.title + " - within range").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor(IDBKeyRange.lowerBound("cupcake", true));
switch(count) {
case 0:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 1);
cursor.continue();
break;
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
this.done();
return;
}
var cursor = e.target.result;
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 4);
cursor.continue();
break;
switch(count) {
case 0:
assert_equals(cursor.value, "pancake");
assert_equals(cursor.primaryKey, 3);
cursor.continue("pie");
break;
default:
assert_unreached("Unexpected count: " + count);
}
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 1);
cursor.continue("zzz");
break;
default:
assert_unreached("Unexpected count: " + count);
}
count++;
});
rq.onerror = fail(this, "unexpected error1")
});
async_test(document.title + " - within single key range").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor("pancake");
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 1, 'count');
this.done();
return;
}
var cursor = e.target.result;
switch(count) {
case 0:
assert_equals(cursor.value, "pancake");
assert_equals(cursor.primaryKey, 3);
cursor.continue("pie");
break;
default:
assert_unreached("Unexpected count: " + count);
}
count++;
});
rq.onerror = fail(this, "unexpected error1")
});
async_test(document.title + " - within single key range, with several results").step(function(e) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("index")
.openCursor("pie");
rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
assert_equals(count, 2, 'count');
this.done();
return;
}
var cursor = e.target.result;
switch(count) {
case 0:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 1);
cursor.continue();
break;
case 1:
assert_equals(cursor.value, "pie");
assert_equals(cursor.primaryKey, 4);
cursor.continue();
break;
default:
assert_unreached("Unexpected count: " + count);
}
count++;
});
rq.onerror = fail(this, "unexpected error1")
});
// Stop blocking the testing system from hereon
done();
}
count++;
});
rq.onerror = t.unreached_func("unexpected error1")
},
document.title + " - within single key range, with several results"
);
</script>
<div id="log"></div>

Просмотреть файл

@ -45,12 +45,12 @@ indexeddb_test(
store.deleteIndex("idx");
});
txn.oncomplete = function() {
txn.oncomplete = t.step_func(function() {
assert_throws("TransactionInactiveError", function() {
cursor.continuePrimaryKey("A", 4);
}, "transaction-state check should precede deletion check");
t.done();
};
});
},
null,
"TransactionInactiveError v.s. InvalidStateError(deleted index)"
@ -378,5 +378,3 @@ indexeddb_test(
"DataError(keys are larger then current one) in 'prev' direction"
);
</script>
<div id="log"></div>

Просмотреть файл

@ -16,6 +16,10 @@ async_test(function(t) {
open.onupgradeneeded = t.step_func(function() {
var db = open.result;
t.add_cleanup(function() {
db.close();
indexedDB.deleteDatabase(db.name);
});
var store = db.createObjectStore('store');
store.put('a', 1).onerror = t.unreached_func('put should not fail');
var request = store.openCursor();
@ -60,6 +64,10 @@ async_test(function(t) {
open.onupgradeneeded = t.step_func(function() {
var db = open.result;
t.add_cleanup(function() {
db.close();
indexedDB.deleteDatabase(db.name);
});
var store = db.createObjectStore('store', {keyPath: 'pk'});
var index = store.createIndex('index', 'ik', {multiEntry: true});
store.put({pk: 'a', ik: [1,2,3]}).onerror =

Просмотреть файл

@ -15,69 +15,46 @@
<script src="support.js"></script>
<script>
var records = [ 1337, "Alice", "Bob", "Bob", "Greg", "Åke", ["Anne"] ];
var directions = ["next", "prev", "nextunique", "prevunique"];
var tests = {};
directions.forEach(function(dir) {
tests[dir] = async_test(document.title + ' - ' + dir);
});
var open_rq = indexedDB.open("testdb-" + new Date().getTime() + Math.random());
open_rq.onupgradeneeded = function(e) {
var objStore = e.target.result.createObjectStore("test");
objStore.createIndex("idx", "name");
for (var i = 0; i < records.length; i++)
objStore.add({ name: records[i] }, i);
};
open_rq.onsuccess = function(e) {
var db = e.target.result;
db.onerror = fail_helper("db.onerror");
var records = [ 1337, "Alice", "Bob", "Bob", "Greg", "Åke", ["Anne"] ];
var cases = [
{dir: 'next', expect: ['Alice:1', 'Bob:2', 'Bob:3', 'Greg:4']},
{dir: 'prev', expect: ['Greg:4', 'Bob:3', 'Bob:2', 'Alice:1']},
{dir: 'nextunique', expect: ['Alice:1', 'Bob:2', 'Greg:4']},
{dir: 'prevunique', expect: ['Greg:4', 'Bob:2', 'Alice:1']}
];
// The tests
testdir('next', ['Alice:1', 'Bob:2', 'Bob:3', 'Greg:4']);
testdir('prev', ['Greg:4', 'Bob:3', 'Bob:2', 'Alice:1']);
testdir('nextunique', ['Alice:1', 'Bob:2', 'Greg:4']);
testdir('prevunique', ['Greg:4', 'Bob:2', 'Alice:1']);
cases.forEach(function(testcase) {
var dir = testcase.dir;
var expect = testcase.expect;
indexeddb_test(
function(t, db, tx) {
var objStore = db.createObjectStore("test");
objStore.createIndex("idx", "name");
// Test function
function testdir(dir, expect) {
var count = 0;
var t = tests[dir];
var rq = db.transaction("test").objectStore("test").index("idx").openCursor(IDBKeyRange.bound("AA", "ZZ"), dir);
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
if (!cursor) {
assert_equals(count, expect.length, "cursor runs");
t.done();
}
assert_equals(cursor.value.name + ":" + cursor.primaryKey, expect[count], "cursor.value");
count++;
cursor.continue();
});
rq.onerror = t.step_func(function(e) {
e.preventDefault();
e.stopPropagation();
assert_unreached("rq.onerror - " + e.message);
});
for (var i = 0; i < records.length; i++)
objStore.add({ name: records[i] }, i);
},
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("idx").openCursor(IDBKeyRange.bound("AA", "ZZ"), dir);
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
if (!cursor) {
assert_equals(count, expect.length, "cursor runs");
t.done();
}
};
// Fail handling
function fail_helper(name) {
return function() {
directions.forEach(function(dir) {
tests[dir].step(function() { assert_unreached(name); });
});
};
}
open_rq.onblocked = fail_helper('open_rq.onblocked');
open_rq.onerror = fail_helper('open_rq.onerror');
assert_equals(cursor.value.name + ":" + cursor.primaryKey, expect[count], "cursor.value");
count++;
cursor.continue();
});
rq.onerror = t.step_func(function(e) {
e.preventDefault();
e.stopPropagation();
assert_unreached("rq.onerror - " + e.message);
});
},
document.title + ' - ' + dir
)
});
</script>
<div id=log> </div>

Просмотреть файл

@ -13,69 +13,45 @@
<script src="support.js"></script>
<script>
var records = [ "Alice", "Bob", "Bob", "Greg" ];
var directions = ["next", "prev", "nextunique", "prevunique"];
var tests = {};
var records = [ "Alice", "Bob", "Bob", "Greg" ];
var cases = [
{dir: 'next', expect: ['Alice:0', 'Bob:1', 'Bob:2', 'Greg:3']},
{dir: 'prev', expect: ['Greg:3', 'Bob:2', 'Bob:1', 'Alice:0']},
{dir: 'nextunique', expect: ['Alice:0', 'Bob:1', 'Greg:3']},
{dir: 'prevunique', expect: ['Greg:3', 'Bob:1', 'Alice:0']},
];
directions.forEach(function(dir) {
tests[dir] = async_test(document.title + ' - ' + dir);
});
cases.forEach(function(testcase) {
var dir = testcase.dir;
var expect = testcase.expect;
indexeddb_test(
function(t, db, tx) {
var objStore = db.createObjectStore("test");
objStore.createIndex("idx", "name");
var open_rq = indexedDB.open("testdb-" + new Date().getTime() + Math.random());
open_rq.onupgradeneeded = function(e) {
var objStore = e.target.result.createObjectStore("test");
objStore.createIndex("idx", "name");
for (var i = 0; i < records.length; i++)
objStore.add({ name: records[i] }, i);
};
open_rq.onsuccess = function(e) {
var db = e.target.result;
db.onerror = fail_helper("db.onerror");
// The tests
testdir('next', ['Alice:0', 'Bob:1', 'Bob:2', 'Greg:3']);
testdir('prev', ['Greg:3', 'Bob:2', 'Bob:1', 'Alice:0']);
testdir('nextunique', ['Alice:0', 'Bob:1', 'Greg:3']);
testdir('prevunique', ['Greg:3', 'Bob:1', 'Alice:0']);
// Test function
function testdir(dir, expect) {
var count = 0;
var t = tests[dir];
var rq = db.transaction("test").objectStore("test").index("idx").openCursor(undefined, dir);
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
if (!cursor) {
assert_equals(count, expect.length, "cursor runs");
t.done();
}
assert_equals(cursor.value.name + ":" + cursor.primaryKey, expect[count], "cursor.value");
count++;
cursor.continue();
});
rq.onerror = t.step_func(function(e) {
e.preventDefault();
e.stopPropagation();
assert_unreached("rq.onerror - " + e.message);
});
for (var i = 0; i < records.length; i++)
objStore.add({ name: records[i] }, i);
},
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").index("idx").openCursor(undefined, dir);
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
if (!cursor) {
assert_equals(count, expect.length, "cursor runs");
t.done();
}
};
// Fail handling
function fail_helper(name) {
return function() {
directions.forEach(function(dir) {
tests[dir].step(function() { assert_unreached(name); });
});
};
}
open_rq.onblocked = fail_helper('open_rq.onblocked');
open_rq.onerror = fail_helper('open_rq.onerror');
assert_equals(cursor.value.name + ":" + cursor.primaryKey, expect[count], "cursor.value");
count++;
cursor.continue();
});
rq.onerror = t.step_func(function(e) {
e.preventDefault();
e.stopPropagation();
assert_unreached("rq.onerror - " + e.message);
});
},
document.title + ' - ' + dir
);
});
</script>
<div id=log> </div>

Просмотреть файл

@ -11,68 +11,44 @@
<script src="support.js"></script>
<script>
var records = [ 1337, "Alice", "Bob", "Greg", "Åke", ["Anne"] ];
var directions = ["next", "prev", "nextunique", "prevunique"];
var tests = {};
directions.forEach(function(dir) {
tests[dir] = async_test(document.title + ' - ' + dir);
});
var open_rq = indexedDB.open("testdb-" + new Date().getTime() + Math.random());
open_rq.onupgradeneeded = function(e) {
var objStore = e.target.result.createObjectStore("test");
var records = [ 1337, "Alice", "Bob", "Greg", "Åke", ["Anne"] ];
var directions = ["next", "prev", "nextunique", "prevunique"];
var cases = [
{dir: 'next', expect: ['Alice', 'Bob', 'Greg']},
{dir: 'prev', expect: ['Greg', 'Bob', 'Alice']},
{dir: 'nextunique', expect: ['Alice', 'Bob', 'Greg']},
{dir: 'prevunique', expect: ['Greg', 'Bob', 'Alice']},
];
cases.forEach(function(testcase) {
var dir = testcase.dir;
var expect = testcase.expect;
indexeddb_test(
function(t, db, tx) {
var objStore = db.createObjectStore("test");
for (var i = 0; i < records.length; i++)
objStore.add(records[i], records[i]);
};
open_rq.onsuccess = function(e) {
var db = e.target.result;
db.onerror = fail_helper("db.onerror");
// The tests
testdir('next', ['Alice', 'Bob', 'Greg']);
testdir('prev', ['Greg', 'Bob', 'Alice']);
testdir('nextunique', ['Alice', 'Bob', 'Greg']);
testdir('prevunique', ['Greg', 'Bob', 'Alice']);
// Test function
function testdir(dir, expect) {
var count = 0;
var t = tests[dir];
var rq = db.transaction("test").objectStore("test").openCursor(IDBKeyRange.bound("AA", "ZZ"), dir);
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
if (!cursor) {
assert_equals(count, expect.length, "cursor runs");
t.done();
}
assert_equals(cursor.value, expect[count], "cursor.value");
count++;
cursor.continue();
});
rq.onerror = t.step_func(function(e) {
e.preventDefault();
e.stopPropagation();
assert_unreached("rq.onerror - " + e.message);
});
objStore.add(records[i], records[i]);
},
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").openCursor(IDBKeyRange.bound("AA", "ZZ"), dir);
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
if (!cursor) {
assert_equals(count, expect.length, "cursor runs");
t.done();
}
};
// Fail handling
function fail_helper(name) {
return function() {
directions.forEach(function(dir) {
tests[dir].step(function() { assert_unreached(name); });
});
};
}
open_rq.onblocked = fail_helper('open_rq.onblocked');
open_rq.onerror = fail_helper('open_rq.onerror');
assert_equals(cursor.value, expect[count], "cursor.value");
count++;
cursor.continue();
});
rq.onerror = t.step_func(function(e) {
e.preventDefault();
e.stopPropagation();
assert_unreached("rq.onerror - " + e.message);
});
},
document.title + ' - ' + dir
);
});
</script>
<div id=log> </div>

Просмотреть файл

@ -13,68 +13,44 @@
<script src="support.js"></script>
<script>
var records = [ "Alice", "Bob", "Greg" ];
var directions = ["next", "prev", "nextunique", "prevunique"];
var tests = {};
var records = [ "Alice", "Bob", "Greg" ];
var directions = ["next", "prev", "nextunique", "prevunique"];
var cases = [
{dir: 'next', expect: ['Alice', 'Bob', 'Greg']},
{dir: 'prev', expect: ['Greg', 'Bob', 'Alice']},
{dir: 'nextunique', expect: ['Alice', 'Bob', 'Greg']},
{dir: 'prevunique', expect: ['Greg', 'Bob', 'Alice']},
];
directions.forEach(function(dir) {
tests[dir] = async_test(document.title + ' - ' + dir);
});
var open_rq = indexedDB.open("testdb-" + new Date().getTime() + Math.random());
open_rq.onupgradeneeded = function(e) {
var objStore = e.target.result.createObjectStore("test");
for (var i = 0; i < records.length; i++)
objStore.add(records[i], records[i]);
};
open_rq.onsuccess = function(e) {
var db = e.target.result;
db.onerror = fail_helper("db.onerror");
// The tests
testdir('next', ['Alice', 'Bob', 'Greg']);
testdir('prev', ['Greg', 'Bob', 'Alice']);
testdir('nextunique', ['Alice', 'Bob', 'Greg']);
testdir('prevunique', ['Greg', 'Bob', 'Alice']);
// Test function
function testdir(dir, expect) {
var count = 0;
var t = tests[dir];
var rq = db.transaction("test").objectStore("test").openCursor(undefined, dir);
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
if (!cursor) {
assert_equals(count, expect.length, "cursor runs");
t.done();
}
assert_equals(cursor.value, expect[count], "cursor.value");
count++;
cursor.continue();
});
rq.onerror = t.step_func(function(e) {
e.preventDefault();
e.stopPropagation();
assert_unreached("rq.onerror - " + e.message);
});
cases.forEach(function(testcase) {
var dir = testcase.dir;
var expect = testcase.expect;
indexeddb_test(
function(t, db, tx) {
var objStore = db.createObjectStore("test");
for (var i = 0; i < records.length; i++)
objStore.add(records[i], records[i]);
},
function(t, db) {
var count = 0;
var rq = db.transaction("test").objectStore("test").openCursor(undefined, dir);
rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
if (!cursor) {
assert_equals(count, expect.length, "cursor runs");
t.done();
}
};
// Fail handling
function fail_helper(name) {
return function() {
directions.forEach(function(dir) {
tests[dir].step(function() { assert_unreached(name); });
});
};
}
open_rq.onblocked = fail_helper('open_rq.onblocked');
open_rq.onerror = fail_helper('open_rq.onerror');
assert_equals(cursor.value, expect[count], "cursor.value");
count++;
cursor.continue();
});
rq.onerror = t.step_func(function(e) {
e.preventDefault();
e.stopPropagation();
assert_unreached("rq.onerror - " + e.message);
});
},
document.title + ' - ' + dir
);
});
</script>
<div id=log> </div>

Просмотреть файл

@ -17,6 +17,11 @@
open_rq.onupgradeneeded = function(e) {
db = e.target.result;
t.add_cleanup(function() {
db.close();
indexedDB.deleteDatabase(db.name);
});
var objStore = db.createObjectStore("test");
objStore.add("data", "key");
@ -69,5 +74,3 @@
cursor_direction("prevunique", "prevunique");
</script>
<div id="log"></div>

Просмотреть файл

@ -6,63 +6,61 @@
<script src="support.js"></script>
<script>
setup({ explicit_done: true });
function cursor_source_test(test_name, name, stringified_object, cursor_rq_func) {
indexeddb_test(
function(t, db, tx) {
var objStore = db.createObjectStore("my_objectstore");
objStore.createIndex("my_index", "");
var db;
var open_rq = indexedDB.open('testdb-' + new Date().getTime());
open_rq.onupgradeneeded = function(e) {
db = e.target.result;
var objStore = db.createObjectStore("my_objectstore");
objStore.createIndex("my_index", "");
objStore.add("data", 1);
objStore.add("data2", 2);
},
function(t, db) {
var cursor_rq = cursor_rq_func(db);
objStore.add("data", 1);
objStore.add("data2", 2);
};
cursor_rq.onsuccess = t.step_func(function(e) {
if (!e.target.result) {
return;
}
var cursor = e.target.result;
assert_readonly(cursor, 'source');
function cursor_source(name, stringified_object, cursor_rq) {
var cursor;
// Direct try
assert_true(cursor.source instanceof Object, "source isobject");
assert_equals(cursor.source + "", stringified_object, "source");
assert_equals(cursor.source.name, name, "name");
cursor_rq.onsuccess = this.step_func(function(e) {
if (!e.target.result) {
return;
}
cursor = e.target.result;
assert_readonly(cursor, 'source');
cursor.continue();
});
// Direct try
assert_true(cursor.source instanceof Object, "source isobject");
assert_equals(cursor.source + "", stringified_object, "source");
assert_equals(cursor.source.name, name, "name");
cursor_rq.transaction.oncomplete = t.step_func(function(e) {
t.done();
});
cursor.continue();
});
cursor_rq.transaction.onerror = t.step_func(function(e) {
assert_unreached("Transaction got error. " + (e.target.error ? e.target.error.name : "unknown"));
});
},
test_name
);
}
cursor_rq.transaction.oncomplete = this.step_func(function(e) {
this.done();
});
cursor_rq.transaction.onerror = this.step_func(function(e) {
assert_unreached("Transaction got error. " + (e.target.error ? e.target.error.name : "unknown"));
});
}
open_rq.onsuccess = function() {
async_test(document.title + ' - IDBObjectStore').step(function() {
cursor_source.call(this, "my_objectstore", "[object IDBObjectStore]", db.transaction("my_objectstore")
.objectStore("my_objectstore")
.openCursor());
});
async_test(document.title + ' - IDBIndex').step(function() {
cursor_source.call(this, "my_index", "[object IDBIndex]", db.transaction("my_objectstore")
.objectStore("my_objectstore")
.index("my_index")
.openCursor());
});
done();
};
cursor_source_test(
document.title + ' - IDBObjectStore',
"my_objectstore",
"[object IDBObjectStore]",
function(db) { return db.transaction("my_objectstore")
.objectStore("my_objectstore")
.openCursor(); }
);
cursor_source_test(
document.title + ' - IDBIndex',
"my_index",
"[object IDBIndex]",
function(db) { return db.transaction("my_objectstore")
.objectStore("my_objectstore")
.index("my_index")
.openCursor(); }
);
</script>
<div id="log"></div>

Просмотреть файл

@ -13,6 +13,7 @@
var open_rq = createdb(t);
open_rq.onupgradeneeded = function(e) {
db = e.target.result;
t.add_cleanup(function() { db.close(); indexedDB.deleteDatabase(db.name); });
var objStore = db.createObjectStore("test", { keyPath: "key" });
for (var i = 0; i < 500; i++)
@ -106,5 +107,3 @@
});
};
</script>
<div id="log"> </div>

Просмотреть файл

@ -18,6 +18,7 @@
var open_rq = createdb(t);
open_rq.onupgradeneeded = function(e) {
db = e.target.result;
t.add_cleanup(function() { db.close(); indexedDB.deleteDatabase(db.name); });
var objStore = db.createObjectStore("test", {keyPath:"pKey"});
for (var i = 0; i < records.length; i++)
@ -47,5 +48,3 @@
});
};
</script>
<div id="log"> </div>

Просмотреть файл

@ -18,6 +18,7 @@
var open_rq = createdb(t);
open_rq.onupgradeneeded = function(e) {
db = e.target.result;
t.add_cleanup(function() { db.close(); indexedDB.deleteDatabase(db.name); });
var objStore = db.createObjectStore("test", {keyPath:"pKey"});
for (var i = 0; i < records.length; i++)
@ -47,5 +48,3 @@
});
};
</script>
<div id="log"> </div>

Просмотреть файл

@ -45,10 +45,10 @@ indexeddb_test(
assert_throws('NotFoundError', () => {
db.transaction('no-such-store', 'versionchange');
}, '"No such store" check (NotFoundError) should precede ' +
'"invalid mode" check (InvalidAccessError)');
'"invalid mode" check (TypeError)');
t.done();
},
'IDBDatabase.transaction exception order: NotFoundError vs. InvalidAccessError'
'IDBDatabase.transaction exception order: NotFoundError vs. TypeError'
);
</script>

Просмотреть файл

@ -33,6 +33,7 @@ open_rq.onsuccess = function(e) {
assert_equals(blocked_fired, 1, 'block event fired #')
assert_equals(upgradeneeded_fired, 2, 'second upgradeneeded event fired #')
rq.result.close();
t.done();
});
rq.onerror = fail(t, 'Unexpected database deletion error');

Просмотреть файл

@ -7,11 +7,11 @@
<script src=support.js></script>
<script>
function invalid_optionalParameters(desc, params) {
function invalid_optionalParameters(desc, params, exception = "InvalidAccessError") {
var t = async_test(document.title + " - " + desc);
createdb(t).onupgradeneeded = function(e) {
assert_throws(null, function() {
assert_throws(exception, function() {
e.target.result.createObjectStore("store", params);
});
@ -20,9 +20,9 @@
}
invalid_optionalParameters("autoInc and empty keyPath", {autoIncrement: true, keyPath: ""});
invalid_optionalParameters("autoInc and keyPath array", {autoIncrement: true, keyPath: []});
invalid_optionalParameters("autoInc and keyPath array", {autoIncrement: true, keyPath: []}, "SyntaxError");
invalid_optionalParameters("autoInc and keyPath array 2", {autoIncrement: true, keyPath: ["hey"]});
invalid_optionalParameters("autoInc and keyPath object", {autoIncrement: true, keyPath: {a:"hey", b:2}});
invalid_optionalParameters("autoInc and keyPath object", {autoIncrement: true, keyPath: {a:"hey", b:2}}, "SyntaxError");
</script>

Просмотреть файл

@ -81,6 +81,8 @@
});
idx.getKey("Sicking").onsuccess = this.step_func(function(e) {
assert_equals(e.target.result, undefined, "getKey(Sicking)");
db3.close();
this.done();
});
});

Просмотреть файл

@ -51,6 +51,8 @@
count_done++;
assert_equals(count_done, 3, "count_done");
db2.close();
this.done();
});
});

Просмотреть файл

@ -17,6 +17,7 @@
var open_rq2 = window.indexedDB.open(db.name);
open_rq2.onsuccess = this.step_func(function(e) {
assert_equals(e.target.result.version, 13, "db.version")
e.target.result.close();
this.done();
});
open_rq2.onupgradeneeded = fail(this, 'Unexpected upgradeneeded')

Просмотреть файл

@ -8,13 +8,14 @@
<script>
var open_rq = createdb(async_test(), undefined, 13);
var did_upgrade = false;
var open_rq2;
open_rq.onupgradeneeded = function() {};
open_rq.onsuccess = function(e) {
var db = e.target.result;
db.close();
var open_rq2 = window.indexedDB.open(db.name, 14);
open_rq2 = window.indexedDB.open(db.name, 14);
open_rq2.onupgradeneeded = function() {};
open_rq2.onsuccess = this.step_func(open_previous_db);
open_rq2.onerror = fail(this, 'Unexpected error')
@ -24,6 +25,7 @@
var open_rq3 = window.indexedDB.open(e.target.result.name, 13);
open_rq3.onerror = this.step_func(function(e) {
assert_equals(e.target.error.name, 'VersionError', 'e.target.error.name')
open_rq2.result.close();
this.done();
});
open_rq3.onupgradeneeded = fail(this, 'Unexpected upgradeneeded')

Просмотреть файл

@ -8,13 +8,14 @@
<script>
var open_rq = createdb(async_test(), undefined, 13);
var did_upgrade = false;
var open_rq2;
open_rq.onupgradeneeded = function() {};
open_rq.onsuccess = function(e) {
var db = e.target.result;
db.close();
var open_rq2 = window.indexedDB.open(db.name, 14);
open_rq2 = window.indexedDB.open(db.name, 14);
open_rq2.onupgradeneeded = function() {
did_upgrade = true;
};
@ -26,6 +27,8 @@
var open_rq3 = window.indexedDB.open(e.target.result.name);
open_rq3.onsuccess = this.step_func(function(e) {
assert_equals(e.target.result.version, 14, "db.version")
open_rq2.result.close();
open_rq3.result.close();
this.done();
});
open_rq3.onupgradeneeded = fail(this, 'Unexpected upgradeneeded')

Просмотреть файл

@ -2,26 +2,14 @@
<title>IndexedDB: Test IDBIndex.getAll.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
setup({explicit_done: true});
var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
var ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
function doSetup(dbName, dbVersion, onsuccess) {
var delete_request = indexedDB.deleteDatabase(dbName);
delete_request.onerror = function() {
assert_unreached('deleteDatabase should not fail');
};
delete_request.onsuccess = function(e) {
var req = indexedDB.open(dbName, dbVersion);
req.onsuccess = onsuccess;
req.onerror = function() {
assert_unreached('open should not fail');
};
req.onupgradeneeded = function(evt) {
var connection = evt.target.result;
function getall_test(func, name) {
indexeddb_test(
function(t, connection, tx) {
var store = connection.createObjectStore('generated',
{autoIncrement: true, keyPath: 'id'});
var index = store.createIndex('test_idx', 'upper');
@ -61,8 +49,10 @@ function doSetup(dbName, dbVersion, onsuccess) {
store = connection.createObjectStore('empty', null);
index = store.createIndex('test_idx', 'upper');
};
};
},
func,
name
);
}
function createGetAllRequest(t, storeName, connection, range, maxCount) {
@ -74,9 +64,7 @@ function createGetAllRequest(t, storeName, connection, range, maxCount) {
return req;
}
doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
var connection = evt.target.result;
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection, 'C');
req.onsuccess = t.step_func(function(evt) {
var data = evt.target.result;
@ -87,7 +75,7 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'Single item get');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'empty', connection);
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result, [],
@ -96,7 +84,7 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'Empty object store');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection);
req.onsuccess = t.step_func(function(evt) {
var data = evt.target.result;
@ -107,7 +95,7 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'Get all keys');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection, undefined,
10);
req.onsuccess = t.step_func(function(evt) {
@ -119,7 +107,7 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'maxCount=10');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('G', 'M'));
req.onsuccess = t.step_func(function(evt) {
@ -130,7 +118,7 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'Get bound range');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('G', 'M'), 3);
req.onsuccess = t.step_func(function(evt) {
@ -142,7 +130,7 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'Get bound range with maxCount');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('G', 'K', false, true));
req.onsuccess = t.step_func(function(evt) {
@ -154,7 +142,7 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'Get upper excluded');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('G', 'K', true, false));
req.onsuccess = t.step_func(function(evt) {
@ -166,7 +154,7 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'Get lower excluded');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'generated',
connection, IDBKeyRange.bound(4, 15), 3);
req.onsuccess = t.step_func(function(evt) {
@ -177,7 +165,7 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'Get bound range (generated) with maxCount');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line',
connection, "Doesn't exist");
req.onsuccess = t.step_func(function(evt) {
@ -188,7 +176,7 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'Non existent key');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection,
undefined, 0);
req.onsuccess = t.step_func(function(evt) {
@ -200,7 +188,7 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'maxCount=0');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line-not-unique', connection,
'first');
req.onsuccess = t.step_func(function(evt) {
@ -212,7 +200,7 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'Retrieve multiEntry key');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line-multi', connection,
'vowel');
req.onsuccess = t.step_func(function(evt) {
@ -225,8 +213,4 @@ doSetup(location.pathname + '-IDBIndex.getAll', 1, function(evt) {
});
}, 'Retrieve one key multiple values');
// Explicit done needed in case async_test body fails synchronously.
done();
});
</script>

Просмотреть файл

@ -2,25 +2,14 @@
<title>IndexedDB: Test IDBIndex.getAllKeys.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
setup({explicit_done: true});
var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
function doSetup(dbName, dbVersion, onsuccess) {
var delete_request = indexedDB.deleteDatabase(dbName);
delete_request.onerror = function() {
assert_unreached('deleteDatabase should not fail');
};
delete_request.onsuccess = function(e) {
var req = indexedDB.open(dbName, dbVersion);
req.onsuccess = onsuccess;
req.onerror = function() {
assert_unreached('open should not fail');
};
req.onupgradeneeded = function(evt) {
var connection = evt.target.result;
function getall_test(func, name) {
indexeddb_test(
function(t, connection, tx) {
var store = connection.createObjectStore('generated',
{autoIncrement: true, keyPath: 'id'});
var index = store.createIndex('test_idx', 'upper');
@ -51,8 +40,10 @@ function doSetup(dbName, dbVersion, onsuccess) {
store = connection.createObjectStore('empty', null);
index = store.createIndex('test_idx', 'upper');
};
};
},
func,
name
);
}
function createGetAllKeysRequest(t, storeName, connection, range, maxCount) {
@ -64,9 +55,7 @@ function createGetAllKeysRequest(t, storeName, connection, range, maxCount) {
return req;
}
doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
var connection = evt.target.result;
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection, 'C');
req.onsuccess = t.step_func(function(evt) {
var data = evt.target.result;
@ -75,7 +64,7 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
});
}, 'Single item get');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'empty', connection);
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result, [],
@ -84,7 +73,7 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
});
}, 'Empty object store');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection);
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result, alphabet,
@ -93,7 +82,7 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
});
}, 'Get all keys');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'generated', connection);
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result,
@ -104,7 +93,7 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
});
}, 'Get all generated keys');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined,
10);
req.onsuccess = t.step_func(function(evt) {
@ -115,7 +104,7 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
});
}, 'maxCount=10');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('G', 'M'));
req.onsuccess = t.step_func(function(evt) {
@ -126,7 +115,7 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
});
}, 'Get bound range');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('G', 'M'), 3);
req.onsuccess = t.step_func(function(evt) {
@ -137,7 +126,7 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
});
}, 'Get bound range with maxCount');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('G', 'K', false, true));
req.onsuccess = t.step_func(function(evt) {
@ -148,7 +137,7 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
});
}, 'Get upper excluded');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('G', 'K', true, false));
req.onsuccess = t.step_func(function(evt) {
@ -159,7 +148,7 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
});
}, 'Get lower excluded');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'generated',
connection, IDBKeyRange.bound(4, 15), 3);
req.onsuccess = t.step_func(function(evt) {
@ -169,7 +158,7 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
});
}, 'Get bound range (generated) with maxCount');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line',
connection, "Doesn't exist");
req.onsuccess = t.step_func(function(evt) {
@ -180,7 +169,7 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
});
}, 'Non existent key');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
undefined, 0);
req.onsuccess = t.step_func(function(evt) {
@ -190,7 +179,7 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
});
}, 'maxCount=0');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line-multi', connection,
'vowel');
req.onsuccess = t.step_func(function(evt) {
@ -200,8 +189,4 @@ doSetup(location.pathname + '-IDBIndex.getAllKeys', 1, function(evt) {
req.onerror = t.unreached_func('getAllKeys request should succeed');
}, 'Retrieve multiEntry keys');
// Explicit done needed in case async_test body fails synchronously.
done();
});
</script>

Просмотреть файл

@ -0,0 +1,26 @@
<!doctype html>
<meta charset=utf-8>
<title>IndexedDB: IDBObjectStore index() when transaction is finished</title>
<link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idbobjectstore-index">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
indexeddb_test(
(t, db) => {
const store = db.createObjectStore('store');
store.createIndex('index', 'key_path');
},
(t, db) => {
const tx = db.transaction('store');
const store = tx.objectStore('store');
tx.abort();
assert_throws('InvalidStateError', () => store.index('index'),
'index() should throw if transaction is finished');
t.done();
},
'IDBObjectStore index() behavior when transaction is finished'
);
</script>

Просмотреть файл

@ -35,6 +35,7 @@
assert_throws('NotFoundError',
function() { index = objStore.index("index") });
assert_equals(index, undefined);
db.close();
t.done();
}
}

Просмотреть файл

@ -28,16 +28,17 @@
db.deleteObjectStore("store");
assert_equals(db.objectStoreNames.length, 0, "objectStoreNames.length after delete");
assert_throws(null, function() { objStore.add(2); });
assert_throws(null, function() { objStore.put(3); });
assert_throws(null, function() { objStore.get(1); });
assert_throws(null, function() { objStore.clear(); });
assert_throws(null, function() { objStore.count(); });
assert_throws(null, function() { objStore.delete(1); });
assert_throws(null, function() { objStore.openCursor(); });
assert_throws(null, function() { objStore.index("idx"); });
assert_throws(null, function() { objStore.deleteIndex("idx"); });
assert_throws(null, function() { objStore.createIndex("idx2", "a"); });
const exc = "InvalidStateError"
assert_throws(exc, function() { objStore.add(2); });
assert_throws(exc, function() { objStore.put(3); });
assert_throws(exc, function() { objStore.get(1); });
assert_throws(exc, function() { objStore.clear(); });
assert_throws(exc, function() { objStore.count(); });
assert_throws(exc, function() { objStore.delete(1); });
assert_throws(exc, function() { objStore.openCursor(); });
assert_throws(exc, function() { objStore.index("idx"); });
assert_throws(exc, function() { objStore.deleteIndex("idx"); });
assert_throws(exc, function() { objStore.createIndex("idx2", "a"); });
}
open_rq.onsuccess = function() {

Просмотреть файл

@ -2,25 +2,14 @@
<title>IndexedDB: Test IDBObjectStore.getAll.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
setup({explicit_done: true});
var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
function doSetup(dbName, dbVersion, onsuccess) {
var delete_request = indexedDB.deleteDatabase(dbName);
delete_request.onerror = function() {
assert_unreached('deleteDatabase should not fail');
};
delete_request.onsuccess = function(e) {
var req = indexedDB.open(dbName, dbVersion);
req.onsuccess = onsuccess;
req.onerror = function() {
assert_unreached('open should not fail');
};
req.onupgradeneeded = function(evt) {
var connection = evt.target.result;
function getall_test(func, name) {
indexeddb_test(
function(t, connection, tx) {
var store = connection.createObjectStore('generated',
{autoIncrement: true, keyPath: 'id'});
alphabet.forEach(function(letter) {
@ -33,8 +22,10 @@ function doSetup(dbName, dbVersion, onsuccess) {
});
store = connection.createObjectStore('empty', null);
};
};
},
func,
name
);
}
function createGetAllRequest(t, storeName, connection, range, maxCount) {
@ -45,9 +36,7 @@ function createGetAllRequest(t, storeName, connection, range, maxCount) {
return req;
}
doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
var connection = evt.target.result;
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection, 'c');
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result, ['value-c']);
@ -55,7 +44,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
});
}, 'Single item get');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'generated', connection, 3);
req.onsuccess = t.step_func(function(evt) {
var data = evt.target.result;
@ -67,7 +56,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
});
}, 'Single item get (generated key)');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'empty', connection);
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result, [],
@ -76,7 +65,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
});
}, 'getAll on empty object store');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection);
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result,
@ -85,7 +74,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
});
}, 'Get all values');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection, undefined,
10);
req.onsuccess = t.step_func(function(evt) {
@ -95,7 +84,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
});
}, 'Test maxCount');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('g', 'm'));
req.onsuccess = t.step_func(function(evt) {
@ -105,7 +94,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
});
}, 'Get bound range');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('g', 'm'), 3);
req.onsuccess = t.step_func(function(evt) {
@ -115,7 +104,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
});
}, 'Get bound range with maxCount');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('g', 'k', false, true));
req.onsuccess = t.step_func(function(evt) {
@ -125,7 +114,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
});
}, 'Get upper excluded');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('g', 'k', true, false));
req.onsuccess = t.step_func(function(evt) {
@ -135,7 +124,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
});
}, 'Get lower excluded');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'generated', connection,
IDBKeyRange.bound(4, 15), 3);
req.onsuccess = t.step_func(function(evt) {
@ -147,7 +136,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
});
}, 'Get bound range (generated) with maxCount');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection,
"Doesn't exist");
req.onsuccess = t.step_func(function(evt) {
@ -158,7 +147,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
req.onerror = t.unreached_func('getAll request should succeed');
}, 'Non existent key');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllRequest(t, 'out-of-line', connection, undefined, 0);
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result,
@ -167,8 +156,4 @@ doSetup(location.pathname + '-IDBObjectStore.getAll', 1, function(evt) {
});
}, 'zero maxCount');
// Explicit done needed in case async_test body fails synchronously.
done();
});
</script>

Просмотреть файл

@ -2,25 +2,14 @@
<title>IndexedDB: Test IDBObjectStore.getAllKeys.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
setup({explicit_done: true});
var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
function doSetup(dbName, dbVersion, onsuccess) {
var delete_request = indexedDB.deleteDatabase(dbName);
delete_request.onerror = function() {
assert_unreached('deleteDatabase should not fail');
};
delete_request.onsuccess = function(e) {
var req = indexedDB.open(dbName, dbVersion);
req.onsuccess = onsuccess;
req.onerror = function() {
assert_unreached('open should not fail');
};
req.onupgradeneeded = function(evt) {
var connection = evt.target.result;
function getall_test(func, name) {
indexeddb_test(
function(t, connection, tx) {
var store = connection.createObjectStore('generated',
{autoIncrement: true, keyPath: 'id'});
alphabet.forEach(function(letter) {
@ -33,8 +22,10 @@ function doSetup(dbName, dbVersion, onsuccess) {
});
store = connection.createObjectStore('empty', null);
};
};
},
func,
name
);
}
function createGetAllKeysRequest(t, storeName, connection, range, maxCount) {
@ -45,9 +36,7 @@ function createGetAllKeysRequest(t, storeName, connection, range, maxCount) {
return req;
}
doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
var connection = evt.target.result;
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection, 'c');
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result, ['c']);
@ -55,7 +44,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
});
}, 'Single item get');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'generated', connection, 3);
req.onsuccess = t.step_func(function(evt) {
var data = evt.target.result;
@ -65,7 +54,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
});
}, 'Single item get (generated key)');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'empty', connection);
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result, [],
@ -75,7 +64,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
});
}, 'getAllKeys on empty object store');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection);
req.onsuccess = t.step_func(function(evt) {
assert_array_equals(evt.target.result, alphabet);
@ -83,7 +72,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
});
}, 'Get all values');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined,
10);
req.onsuccess = t.step_func(function(evt) {
@ -92,7 +81,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
});
}, 'Test maxCount');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('g', 'm'));
req.onsuccess = t.step_func(function(evt) {
@ -101,7 +90,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
});
}, 'Get bound range');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('g', 'm'), 3);
req.onsuccess = t.step_func(function(evt) {
@ -110,7 +99,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
});
}, 'Get bound range with maxCount');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('g', 'k', false, true));
req.onsuccess = t.step_func(function(evt) {
@ -119,7 +108,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
});
}, 'Get upper excluded');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
IDBKeyRange.bound('g', 'k', true, false));
req.onsuccess = t.step_func(function(evt) {
@ -128,7 +117,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
});
}, 'Get lower excluded');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'generated', connection,
IDBKeyRange.bound(4, 15), 3);
req.onsuccess = t.step_func(function(evt) {
@ -139,7 +128,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
});
}, 'Get bound range (generated) with maxCount');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection,
"Doesn't exist");
req.onsuccess = t.step_func(function(evt) {
@ -151,7 +140,7 @@ doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
req.onerror = t.unreached_func('getAllKeys request should succeed');
}, 'Non existent key');
async_test(function(t) {
getall_test(function(t, connection) {
var req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined,
0);
req.onsuccess = t.step_func(function(evt) {
@ -160,8 +149,4 @@ doSetup(location.pathname + '-IDBObjectStore.getAllKeys', 1, function(evt) {
});
}, 'zero maxCount');
// Explicit done needed in case async_test body fails synchronously.
done();
});
</script>

Просмотреть файл

@ -4,17 +4,12 @@
<meta name=timeout content=long>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
function getkey_test(func, name) {
return async_test(function(t) {
var del = indexedDB.deleteDatabase(name);
del.onerror = t.unreached_func('deleteDatabase failed');
var open = indexedDB.open(name);
open.onerror = t.unreached_func('open failed');
open.onupgradeneeded = t.step_func(function() {
var db = open.result;
indexeddb_test(
function(t, db, tx) {
var basic = db.createObjectStore('basic');
var key_path_store = db.createObjectStore('key path',
{keyPath: 'id'});
@ -30,12 +25,10 @@ function getkey_test(func, name) {
key_generator_store.put('value: ' + i);
key_generator_and_path_store.put({});
}
});
open.onsuccess = t.step_func(function() {
var db = open.result;
func(t, db);
});
}, name);
},
func,
name
);
}
getkey_test(function(t, db) {

Просмотреть файл

@ -4,28 +4,17 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
var db, open;
setup(function() {
open = indexedDB.open('testdb-' + new Date().getTime());
open.onupgradeneeded = function(e) {
db = e.target.result;
indexeddb_test(
function(t, db, tx) {
var objStore = db.createObjectStore("test");
objStore.createIndex("index", "");
objStore.add("data", 1);
objStore.add("data2", 2);
};
},
{ explicit_done: true });
open.onsuccess = function() {
async_test(document.title + " - pass something other than number").step(function(e) {
},
function(t, db, tx) {
var idx = db.transaction("test").objectStore("test").index("index");
assert_throws("DataError",
@ -37,14 +26,8 @@
assert_throws("DataError",
function() { idx.openCursor({ lower: "a", lowerOpen: false, upper: null, upperOpen: false }); });
this.done();
});
// Stop blocking the testing system from hereon
done();
}
t.done();
},
document.title + " - pass something other than number"
);
</script>
<div id="log"></div>

Просмотреть файл

@ -2,26 +2,20 @@
<title>IDBObjectStore.openKeyCursor()</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
function store_test(func, name) {
async_test(function(t) {
var del = indexedDB.deleteDatabase(name);
del.onerror = t.unreached_func("deleteDatabase failed");
var open = indexedDB.open(name);
open.onupgradeneeded = t.step_func(function() {
var db = open.result;
var store = db.createObjectStore("store");
for (var i = 0; i < 10; ++i) {
store.put("value: " + i, i);
}
});
open.onsuccess = t.step_func(function() {
var db = open.result;
var tx = db.transaction("store");
var store = tx.objectStore("store");
func(t, db, tx, store);
});
indexeddb_test(
function(t, db, tx) {
var store = db.createObjectStore("store");
for (var i = 0; i < 10; ++i) {
store.put("value: " + i, i);
}
},
function(t, db) {
var tx = db.transaction("store");
var store = tx.objectStore("store");
func(t, db, tx, store);
}, name);
}

Просмотреть файл

@ -16,6 +16,12 @@ function upgradeneeded_test(upgrade_func, success_func, error_func, description)
var open_request = indexedDB.open(dbName);
open_request.onupgradeneeded = t.step_func(function() {
t.add_cleanup(function() {
if (open_request.result) {
open_request.result.close(),
indexedDB.deleteDatabase(dbName);
}
});
upgrade_func(t, open_request);
});
open_request.onsuccess = t.step_func(function() {

Просмотреть файл

@ -0,0 +1,24 @@
<!doctype html>
<meta charset=utf-8>
<title>IndexedDB: IDBTransaction objectStore() when transaction is finished</title>
<link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idbtransaction-objectstore">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
indexeddb_test(
(t, db) => {
db.createObjectStore('store');
},
(t, db) => {
const tx = db.transaction('store');
tx.abort();
assert_throws('InvalidStateError', () => tx.objectStore('store'),
'objectStore() should throw if transaction is finished');
t.done();
},
'IDBTransaction objectStore() behavior when transaction is finished'
);
</script>

Просмотреть файл

@ -6,41 +6,54 @@
<script src="support.js"></script>
<script>
var db,
t = async_test(document.title + " - request gotten by the handler"),
open_t = async_test(document.title + " - request returned by open()"),
async_test(function(t) {
var open_rq = indexedDB.open("idbtransaction-" + document.location + t.name);
open_rq = indexedDB.open("idbtransaction-" + new Date().getTime() + Math.random());
open_rq.onblocked = t.unreached_func('open_rq.onblocked');
open_rq.onerror = t.unreached_func('open_rq.onerror');
open_t.step(function() {
assert_equals(open_rq.transaction, null, "IDBOpenDBRequest.transaction");
assert_equals(open_rq.source, null, "IDBOpenDBRequest.source");
assert_equals(open_rq.readyState, "pending", "IDBOpenDBRequest.readyState");
assert_true(open_rq instanceof IDBOpenDBRequest, "open_rq instanceof IDBOpenDBRequest");
assert_equals(open_rq + "", "[object IDBOpenDBRequest]", "IDBOpenDBRequest (open_rq)");
open_t.done();
open_rq.onupgradeneeded = t.step_func(function(e) {
t.add_cleanup(function() {
open_rq.onerror = function(e) {
e.preventDefault();
};
open_rq.result.close();
indexedDB.deleteDatabase(open_rq.result.name);
});
open_rq.onupgradeneeded = t.step_func(function(e) {
assert_equals(e.target, open_rq, "e.target is reusing the same IDBOpenDBRequest");
assert_equals(e.target.transaction, open_rq.transaction, "IDBOpenDBRequest.transaction");
assert_equals(e.target, open_rq, "e.target is reusing the same IDBOpenDBRequest");
assert_equals(e.target.transaction, open_rq.transaction, "IDBOpenDBRequest.transaction");
assert_true(e.target.transaction instanceof IDBTransaction, "transaction instanceof IDBTransaction");
t.done();
assert_true(e.target.transaction instanceof IDBTransaction, "transaction instanceof IDBTransaction");
t.done();
});
}, document.title + " - request gotten by the handler");
async_test(function(t) {
var open_rq = indexedDB.open("idbtransaction-" + document.location + t.name);
assert_equals(open_rq.transaction, null, "IDBOpenDBRequest.transaction");
assert_equals(open_rq.source, null, "IDBOpenDBRequest.source");
assert_equals(open_rq.readyState, "pending", "IDBOpenDBRequest.readyState");
assert_true(open_rq instanceof IDBOpenDBRequest, "open_rq instanceof IDBOpenDBRequest");
assert_equals(open_rq + "", "[object IDBOpenDBRequest]", "IDBOpenDBRequest (open_rq)");
open_rq.onblocked = t.unreached_func('open_rq.onblocked');
open_rq.onerror = t.unreached_func('open_rq.onerror');
open_rq.onupgradeneeded = t.step_func(function() {
t.add_cleanup(function() {
open_rq.onerror = function(e) {
e.preventDefault();
};
open_rq.result.close();
indexedDB.deleteDatabase(open_rq.result.name);
});
t.done();
});
}, document.title + " - request returned by open()");
// Not plausible conditions...
function fail_helper(name) {
return function() {
t.step(function() { assert_unreached(name); });
open_t.step(function() { assert_unreached(name); });
};
}
open_rq.onblocked = fail_helper('open_rq.onblocked');
open_rq.onerror = fail_helper('open_rq.onerror');
</script>
<div id="log"></div>

Просмотреть файл

@ -73,7 +73,8 @@ indexeddb_test(function(t, db, tx) {
assert_array_equals(saved_tx.objectStoreNames, ['s2', 's3'],
'previous transaction objectStoreNames should be unchanged');
assert_array_equals(db.objectStoreNames, saved_tx.objectStoreNames,
'connection and transaction objectStoreNames should match');
'connection and transaction objectStoreNames should match');
db2.close();
t.done();
});
}, 'IDBTransaction.objectStoreNames - value after close');

Просмотреть файл

@ -106,30 +106,34 @@ function assert_key_equals(actual, expected, description) {
function indexeddb_test(upgrade_func, open_func, description, options) {
async_test(function(t) {
var options = Object.assign({upgrade_will_abort: false}, options);
options = Object.assign({upgrade_will_abort: false}, options);
var dbname = document.location + '-' + t.name;
var del = indexedDB.deleteDatabase(dbname);
del.onerror = t.unreached_func('deleteDatabase should succeed');
var open = indexedDB.open(dbname, 1);
if (!options.upgrade_will_abort) {
open.onsuccess = t.unreached_func('open should not succeed');
} else {
open.onerror = t.unreached_func('open should succeed');
}
open.onupgradeneeded = t.step_func(function() {
var db = open.result;
var tx = open.transaction;
upgrade_func(t, db, tx);
});
open.onsuccess = t.step_func(function() {
var db = open.result;
t.add_cleanup(function() {
// If open didn't succeed already, ignore the error.
open.onerror = function(e) {
e.preventDefault();
};
db.close();
indexedDB.deleteDatabase(db.name);
});
if (open_func)
open_func(t, db);
var tx = open.transaction;
upgrade_func(t, db, tx);
});
if (options.upgrade_will_abort) {
open.onsuccess = t.unreached_func('open should not succeed');
} else {
open.onerror = t.unreached_func('open should succeed');
open.onsuccess = t.step_func(function() {
var db = open.result;
if (open_func)
open_func(t, db);
});
}
}, description);
}

Просмотреть файл

@ -40,13 +40,6 @@ following entries are required:
If you are behind a proxy, you also need to make sure the domains above are
excluded from your proxy lookups.
Because web-platform-tests uses git submodules, you must ensure that
these are up to date. In the root of your checkout, run:
```
git submodule update --init --recursive
```
The test environment can then be started using
./serve
@ -77,6 +70,55 @@ like:
"ssl": {"openssl": {"binary": "/path/to/openssl"}}
```
<span id="submodules">Submodules</span>
=======================================
Some optional components of web-platform-tests (test components from
third party software and pieces of the CSS build system) are included
as submodules. To obtain these components run the following in the
root of your checkout:
```
git submodule update --init --recursive
```
Prior to commit `39d07eb01fab607ab1ffd092051cded1bdd64d78` submodules
were requried for basic functionality. If you are working with an
older checkout, the above command is required in all cases.
When moving between a commit prior to `39d07eb` and one after it git
may complain
```
$ git checkout master
error: The following untracked working tree files would be overwritten by checkout:
[…]
```
followed by a long list of files. To avoid this error remove
the `resources` and `tools` directories before switching branches:
```
$ rm -r resources/ tools/
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'
```
When moving in the opposite direction, i.e. to a commit that does have
submodules, you will need to `git submodule update`, as above. If git
throws an error like:
```
fatal: No url found for submodule path 'resources/webidl2/test/widlproc' in .gitmodules
Failed to recurse into submodule path 'resources/webidl2'
fatal: No url found for submodule path 'tools/html5lib' in .gitmodules
Failed to recurse into submodule path 'resources'
Failed to recurse into submodule path 'tools'
```
then remove the `tools` and `resources` directories, as above.
<span id="windows-notes">Windows Notes</span>
=============================================
@ -257,8 +299,8 @@ is [archived][ircarchive].
[contributing]: https://github.com/w3c/web-platform-tests/blob/master/CONTRIBUTING.md
[ircw3org]: https://www.w3.org/wiki/IRC
[ircarchive]: http://krijnhoetmer.nl/irc-logs/testing/
[mailarchive]: http://lists.w3.org/Archives/Public/public-test-infra/
[ircarchive]: http://logs.glob.uno/?c=w3%23testing
[mailarchive]: https://lists.w3.org/Archives/Public/public-test-infra/
Documentation
=============

Просмотреть файл

@ -1,5 +1,4 @@
function run_test() {
function run_test(testPasswordSize, testSaltSize) {
// May want to test prefixed implementations.
var subtle = self.crypto.subtle;
@ -28,7 +27,9 @@ function run_test() {
// and number of iterations. The derivations object is structured in
// that way, so navigate it to run tests and compare with correct results.
Object.keys(derivations).forEach(function(passwordSize) {
if (typeof testPasswordSize != 'undefined' && testPasswordSize != passwordSize) return;
Object.keys(derivations[passwordSize]).forEach(function(saltSize) {
if (typeof testSaltSize != 'undefined' && testSaltSize != saltSize) return;
Object.keys(derivations[passwordSize][saltSize]).forEach(function(hashName) {
Object.keys(derivations[passwordSize][saltSize][hashName]).forEach(function(iterations) {
var testName = passwordSize + " password, " + saltSize + " salt, " + hashName + ", with " + iterations + " iterations";

Просмотреть файл

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"empty", //password size
"empty" //salt size
);
</script>

Просмотреть файл

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"empty", //password size
"long" //salt size
);
</script>

Просмотреть файл

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"empty", //password size
"short" //salt size
);
</script>

Просмотреть файл

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"long", //password size
"empty" //salt size
);
</script>

Просмотреть файл

@ -15,5 +15,8 @@
<div id="log"></div>
<script>
run_test();
run_test(
"long", //password size
"long" //salt size
);
</script>

Просмотреть файл

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"long", //password size
"short" //salt size
);
</script>

Просмотреть файл

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"short", //password size
"empty" //salt size
);
</script>

Просмотреть файл

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"short", //password size
"long" //salt size
);
</script>

Просмотреть файл

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"short", //password size
"short" //salt size
);
</script>

Просмотреть файл

@ -1,5 +1,5 @@
function run_test(algorithmNames) {
function run_test(algorithmNames, slowTest) {
var subtle = crypto.subtle; // Change to test prefixed implementations
setup({explicit_timeout: true});
@ -74,7 +74,7 @@ function run_test(algorithmNames) {
// Test all valid sets of parameters for successful
// key generation.
testVectors.forEach(function(vector) {
allNameVariants(vector.name).forEach(function(name) {
allNameVariants(vector.name, slowTest).forEach(function(name) {
allAlgorithmSpecifiersFor(name).forEach(function(algorithm) {
allValidUsages(vector.usages, false, vector.mandatoryUsages).forEach(function(usages) {
[false, true].forEach(function(extractable) {

Просмотреть файл

@ -1,23 +0,0 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: generateKey() Successful Calls</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://www.w3.org/TR/WebCryptoAPI/#dfn-SubtleCrypto-method-generateKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/WebCryptoAPI/util/helpers.js"></script>
<script src="successes.js"></script>
<h1>generateKey Tests for Good Parameters</h1>
<p>
<strong>Warning!</strong> RSA key generation is intrinsically
very slow, so the related tests can take up to
several minutes to complete, depending on browser!
</p>
<div id="log"></div>
<script>
run_test(["RSA-OAEP"]);
</script>

Просмотреть файл

@ -19,5 +19,5 @@
<div id="log"></div>
<script>
run_test();
run_test(["RSA-OAEP"], true);
</script>

Просмотреть файл

@ -0,0 +1,45 @@
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>IDL check of WebCrypto</title>
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#crypto-interface">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/WebIDLParser.js></script>
<script src=/resources/idlharness.js></script>
</head>
<body>
<h1 class="instructions">Description</h1>
<p class="instructions">This test verifies that the implementations of the WebCrypto API match with its WebIDL definition.</p>
<div id='log'></div>
<script>
var file_input;
setup(function() {
var idl_array = new IdlArray();
var request = new XMLHttpRequest();
request.open("GET", "WebCryptoAPI.idl");
request.send();
request.onload = function() {
var idls = request.responseText;
idl_array.add_untested_idls("[PrimaryGlobal] interface Window { };");
idl_array.add_untested_idls("interface ArrayBuffer {};");
idl_array.add_untested_idls("interface ArrayBufferView {};");
idl_array.add_idls(idls);
idl_array.add_objects({"Crypto":["crypto"], "SubtleCrypto":["crypto.subtle"]});
idl_array.test();
done();
};
}, {explicit_done: true});
</script>

Просмотреть файл

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
async_test(function(t) {
assert_true(typeof crypto.subtle === 'undefined');
t.done();
}, "Non-secure context window does not have access to crypto.subtle");
async_test(function(t) {
var w = new Worker('../util/worker-report-crypto-subtle-presence.js');
w.onmessage = t.step_func(function (e) {
if (e.data.msg_type == 'subtle_crypto_found') {
assert_equals(e.data.msg_value, false);
t.done();
}
});
}, "Non-secure context worker does not have access to crypto.subtle");
</script>
</body>
</html>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше