forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more tests for IndexedDB exception
- rewrite the valid checkpoints from web-platform-tests#292
- Loading branch information
1 parent
b1d5005
commit 70f0fdd
Showing
15 changed files
with
447 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBDatabase.createObjectStore() - Attampt Create Exsists Object Store With Difference keyPath throw ConstraintError </title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBDatabase-createObjectStore-IDBObjectStore-DOMString-name-IDBObjectStoreParameters-optionalParameters"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var t = async_test(), | ||
open_rq = createdb(t); | ||
|
||
open_rq.onupgradeneeded = function (e) { | ||
var db = e.target.result; | ||
db.createObjectStore("store"); | ||
assert_throws("ConstraintError", function(){ | ||
db.createObjectStore("store", { | ||
keyPath: "key1", | ||
}); | ||
}); | ||
t.done(); | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBDatabase.transaction() - If storeNames is an empty list, the implementation must throw a DOMException of type InvalidAccessError</title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBDatabase-transaction-IDBTransaction-DOMString-sequence-DOMString--storeNames-IDBTransactionMode-mode"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var db, | ||
t = async_test(), | ||
open_rq = createdb(t); | ||
|
||
open_rq.onupgradeneeded = function() {}; | ||
open_rq.onsuccess = function(e) { | ||
db = e.target.result; | ||
assert_throws('InvalidAccessError', function() { db.transaction([]); }); | ||
t.done(); | ||
}; | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBObjectStore.add() - If the transaction this IDBObjectStore belongs to has its mode set to readonly, throw ReadOnlyError </title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBObjectStore-add-IDBRequest-any-value-any-key"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var db, | ||
t = async_test(); | ||
|
||
var open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function (event) { | ||
db = event.target.result; | ||
db.createObjectStore("store", {keyPath:"pKey"}); | ||
} | ||
|
||
open_rq.onsuccess = function (event) { | ||
var txn = db.transaction("store"); | ||
var ostore = txn.objectStore("store"); | ||
t.step(function(){ | ||
assert_throws("ReadOnlyError", function(){ | ||
ostore.add({ pKey: "primaryKey_0"}); | ||
}); | ||
}); | ||
t.done(); | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBObjectStore.add() - If the object store has been deleted, the implementation must throw a DOMException of type InvalidStateError </title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBObjectStore-add-IDBRequest-any-value-any-key"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var db, | ||
ostore, | ||
t = async_test(); | ||
|
||
var open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function (event) { | ||
db = event.target.result; | ||
ostore = db.createObjectStore("store", {keyPath:"pKey"}); | ||
db.deleteObjectStore("store"); | ||
} | ||
|
||
open_rq.onsuccess = function (event) { | ||
t.step(function(){ | ||
assert_throws("InvalidStateError", function(){ | ||
ostore.add({ pKey: "primaryKey_0"}); | ||
}); | ||
}); | ||
t.done(); | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBObjectStore.clear() - If the transaction this IDBObjectStore belongs to has its mode set to readonly, throw ReadOnlyError </title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBObjectStore-clear-IDBRequest"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var db, | ||
t = async_test(), | ||
records = [{ pKey: "primaryKey_0"}, | ||
{ pKey: "primaryKey_1"}]; | ||
|
||
var open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function (event) { | ||
db = event.target.result; | ||
var objStore = db.createObjectStore("store", {keyPath:"pKey"}); | ||
for (var i = 0; i < records.length; i++) { | ||
objStore.add(records[i]); | ||
} | ||
} | ||
|
||
open_rq.onsuccess = function (event) { | ||
var txn = db.transaction("store"); | ||
var ostore = txn.objectStore("store"); | ||
t.step(function(){ | ||
assert_throws("ReadOnlyError", function(){ | ||
ostore.clear(); | ||
}); | ||
}); | ||
t.done(); | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBObjectStore.clear() - If the object store has been deleted, the implementation must throw a DOMException of type InvalidStateError </title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBObjectStore-clear-IDBRequest"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var db, | ||
ostore, | ||
t = async_test(); | ||
|
||
var open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function (event) { | ||
db = event.target.result; | ||
ostore = db.createObjectStore("store", {keyPath:"pKey"}); | ||
db.deleteObjectStore("store"); | ||
} | ||
|
||
open_rq.onsuccess = function (event) { | ||
t.step(function(){ | ||
assert_throws("InvalidStateError", function(){ | ||
ostore.clear(); | ||
}); | ||
}); | ||
t.done(); | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBObjectStore.count() - If the object store has been deleted, the implementation must throw a DOMException of type InvalidStateError </title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBObjectStore-count-IDBRequest-any-key"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var db, | ||
ostore, | ||
t = async_test(); | ||
|
||
var open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function (event) { | ||
db = event.target.result; | ||
ostore = db.createObjectStore("store", {keyPath:"pKey"}); | ||
db.deleteObjectStore("store"); | ||
} | ||
|
||
open_rq.onsuccess = function (event) { | ||
t.step(function(){ | ||
assert_throws("InvalidStateError", function(){ | ||
ostore.count(); | ||
}); | ||
}); | ||
t.done(); | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBDatabase.createIndex() - If an index with the name name already exists in this object store, the implementation must throw a DOMException of type ConstraintError </title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBObjectStore-createIndex-IDBIndex-DOMString-name-DOMString-sequence-DOMString--keyPath-IDBIndexParameters-optionalParameters"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var t = async_test(), | ||
open_rq = createdb(t); | ||
|
||
open_rq.onupgradeneeded = function (e) { | ||
var db = e.target.result; | ||
var ostore = db.createObjectStore("store"); | ||
ostore.createIndex("a", "a"); | ||
assert_throws("ConstraintError", function(){ | ||
ostore.createIndex("a", "a"); | ||
}); | ||
t.done(); | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBDatabase.createIndex() - If keyPath is not a valid key path, the implementation must throw a DOMException of type SyntaxError </title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBObjectStore-createIndex-IDBIndex-DOMString-name-DOMString-sequence-DOMString--keyPath-IDBIndexParameters-optionalParameters"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var t = async_test(), | ||
open_rq = createdb(t); | ||
|
||
open_rq.onupgradeneeded = function (e) { | ||
var db = e.target.result; | ||
var ostore = db.createObjectStore("store"); | ||
assert_throws("SyntaxError", function(){ | ||
ostore.createIndex("ab", "."); | ||
}); | ||
t.done(); | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBDatabase.createIndex() - If the object store has been deleted, the implementation must throw a DOMException of type InvalidStateError </title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBObjectStore-createIndex-IDBIndex-DOMString-name-DOMString-sequence-DOMString--keyPath-IDBIndexParameters-optionalParameters"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var db, | ||
ostore, | ||
t = async_test(); | ||
|
||
var open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function (event) { | ||
db = event.target.result; | ||
ostore = db.createObjectStore("store"); | ||
db.deleteObjectStore("store"); | ||
} | ||
|
||
open_rq.onsuccess = function (event) { | ||
t.step(function(){ | ||
assert_throws("InvalidStateError", function(){ | ||
ostore.createIndex("index", "indexedProperty"); | ||
}); | ||
}); | ||
t.done(); | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBDatabase.createIndex() - Operate out versionchange throw InvalidStateError </title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBObjectStore-createIndex-IDBIndex-DOMString-name-DOMString-sequence-DOMString--keyPath-IDBIndexParameters-optionalParameters"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var db, | ||
t = async_test(); | ||
|
||
var open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function (event) { | ||
db = event.target.result; | ||
db.createObjectStore("store"); | ||
} | ||
|
||
open_rq.onsuccess = function (event) { | ||
var txn = db.transaction("store", "readwrite"); | ||
ostore = txn.objectStore("store"); | ||
t.step(function(){ | ||
assert_throws("InvalidStateError", function(){ | ||
ostore.createIndex("index", "indexedProperty"); | ||
}); | ||
}); | ||
t.done(); | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBObjectStore.delete() - If the transaction this IDBObjectStore belongs to has its mode set to readonly, throw ReadOnlyError</title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBObjectStore-delete-IDBRequest-any-key"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var db, | ||
t = async_test(), | ||
records = [{ pKey: "primaryKey_0"}, | ||
{ pKey: "primaryKey_1"}]; | ||
|
||
var open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function (event) { | ||
db = event.target.result; | ||
var objStore = db.createObjectStore("store", {keyPath:"pKey"}); | ||
for (var i = 0; i < records.length; i++) { | ||
objStore.add(records[i]); | ||
} | ||
} | ||
|
||
open_rq.onsuccess = function (event) { | ||
var txn = db.transaction("store"); | ||
var ostore = txn.objectStore("store"); | ||
t.step(function(){ | ||
assert_throws("ReadOnlyError", function(){ | ||
ostore.delete("primaryKey_0"); | ||
}); | ||
}); | ||
t.done(); | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>IDBObjectStore.delete() - If the object store has been deleted, the implementation must throw a DOMException of type InvalidStateError</title> | ||
<link rel="author" title="Intel" href="http://www.intel.com"> | ||
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBObjectStore-delete-IDBRequest-any-key"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="support.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var db, | ||
ostore, | ||
t = async_test(), | ||
records = [{ pKey: "primaryKey_0"}, | ||
{ pKey: "primaryKey_1"}]; | ||
|
||
var open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function (event) { | ||
db = event.target.result; | ||
ostore = db.createObjectStore("store", {keyPath:"pKey"}); | ||
db.deleteObjectStore("store"); | ||
} | ||
|
||
open_rq.onsuccess = function (event) { | ||
t.step(function(){ | ||
assert_throws("InvalidStateError", function(){ | ||
ostore.delete("primaryKey_0"); | ||
}); | ||
}); | ||
t.done(); | ||
} | ||
</script> | ||
|
Oops, something went wrong.