Skip to content

Commit

Permalink
Merge pull request #27 from quasicomputational/wpt-sync-2019-03-13
Browse files Browse the repository at this point in the history
Re-sync with upstream WPT.
  • Loading branch information
dumbmatter authored Mar 14, 2019
2 parents 552d2a4 + 9e30a7b commit b55bf9f
Show file tree
Hide file tree
Showing 472 changed files with 92,434 additions and 18,890 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
],
"dependencies": {
"core-js": "^2.4.1",
"glob": "^7.1.3",
"realistic-structured-clone": "^2.0.1",
"setimmediate": "^1.0.5"
},
Expand Down
5 changes: 5 additions & 0 deletions src/test/web-platform-tests/IndexedDB/META.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
spec: https://w3c.github.io/IndexedDB/
suggested_reviewers:
- odinho
- inexorabletash
- zqzhang
7 changes: 0 additions & 7 deletions src/test/web-platform-tests/IndexedDB/OWNERS

This file was deleted.

6 changes: 3 additions & 3 deletions src/test/web-platform-tests/IndexedDB/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
This directory contains the Indexed Database API test suite.

To run the tests in this test suite within a browser, go to: <http://w3c-test.org/IndexedDB/>.
To run the tests in this test suite within a browser, go to: <https://w3c-test.org/IndexedDB/>.

The latest Editor's Draft of Indexed Database API is: <http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html>.
The latest Editor's Draft of Indexed Database API is: <https://w3c.github.io/IndexedDB/>.

The latest W3C Technical Report of Indexed Database API is: <http://www.w3.org/TR/IndexedDB/>.
The latest W3C Technical Report of Indexed Database API is: <https://www.w3.org/TR/IndexedDB/>.

72 changes: 72 additions & 0 deletions src/test/web-platform-tests/IndexedDB/bigint_value.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>IndexedDB: BigInt keys and values</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>

<script>
// BigInt and BigInt objects are supported in serialization, per
// https://github.com/whatwg/html/pull/3480
// This support allows them to be used as IndexedDB values.

function value_test(value, predicate, name) {
async_test(t => {
t.step(function() {
assert_true(predicate(value),
"Predicate should return true for the initial value.");
});

createdb(t).onupgradeneeded = t.step_func(e => {
e.target.result
.createObjectStore("store")
.add(value, 1);

e.target.onsuccess = t.step_func(e => {
e.target.result
.transaction("store")
.objectStore("store")
.get(1)
.onsuccess = t.step_func(e =>
{
assert_true(predicate(e.target.result),
"Predicate should return true for the deserialized result.");
t.done();
});
});
});
}, "BigInts as values in IndexedDB - " + name);
}

value_test(1n,
x => x === 1n,
"primitive BigInt");
value_test(Object(1n),
x => typeof x === 'object' &&
x instanceof BigInt &&
x.valueOf() === 1n,
"BigInt object");
value_test({val: 1n},
x => x.val === 1n,
"primitive BigInt inside object");
value_test({val: Object(1n)},
x => x.val.valueOf() === 1n &&
x.val instanceof BigInt &&
x.val.valueOf() === 1n,
"BigInt object inside object");

// However, BigInt is not supported as an IndexedDB key; support
// has been proposed in the following PR, but that change has not
// landed at the time this patch was written
// https://github.com/w3c/IndexedDB/pull/231

function invalidKey(key, name) {
test(t => {
assert_throws("DataError", () => indexedDB.cmp(0, key));
}, "BigInts as keys in IndexedDB - " + name);
}

invalidKey(1n, "primitive BigInt");
// Still an error even if the IndexedDB patch lands
invalidKey(Object(1n), "BigInt object");
</script>
104 changes: 0 additions & 104 deletions src/test/web-platform-tests/IndexedDB/bindings-inject-key.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!doctype html>
<meta charset=utf-8>
<title>IndexedDB: ES bindings - Inject a key into a value - Keys bypass setters</title>
<meta name="help"
href="https://w3c.github.io/IndexedDB/#inject-key-into-value-keys-bypass-setters">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support-promises.js"></script>
<script>

promise_test(async t => {
const db = await createDatabase(t, db => {
db.createObjectStore('store');
});

let setter_called = false;
Object.defineProperty(Object.prototype, '10', {
configurable: true,
set: value => { setter_called = true; },
});
t.add_cleanup(() => { delete Object.prototype['10']; });

const tx = db.transaction('store', 'readwrite');
const result = await promiseForRequest(t, tx.objectStore('store').put(
'value', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'key']));

assert_false(setter_called,
'Setter should not be called for key result.');
assert_true(result.hasOwnProperty('10'),
'Result should have own-property overriding prototype setter.');
assert_equals(result[10], 'key',
'Result should have expected property.');
}, 'Returning keys to script should bypass prototype setters');

</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!doctype html>
<meta charset=utf-8>
<title>IndexedDB: ES bindings - Inject a key into a value - Values bypass chain</title>
<meta name="help"
href="https://w3c.github.io/IndexedDB/#inject-key-into-value-values-bypass-chain">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support-promises.js"></script>
<script>

promise_test(async t => {
const db = await createDatabase(t, db => {
db.createObjectStore('store', {autoIncrement: true, keyPath: 'a.b.c'});
});

Object.prototype.a = {b: {c: 'on proto'}};
t.add_cleanup(() => { delete Object.prototype.a; });

const tx = db.transaction('store', 'readwrite');
tx.objectStore('store').put({});
const result = await promiseForRequest(t, tx.objectStore('store').get(1));

assert_true(result.hasOwnProperty('a'),
'Result should have own-properties overriding prototype.');
assert_true(result.a.hasOwnProperty('b'),
'Result should have own-properties overriding prototype.');
assert_true(result.a.b.hasOwnProperty('c'),
'Result should have own-properties overriding prototype.');
assert_equals(result.a.b.c, 1,
'Own property should match primary key generator value');
assert_equals(Object.prototype.a.b.c, 'on proto',
'Prototype should not be modified');
}, 'Returning values to script should bypass prototype chain');

</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!doctype html>
<meta charset=utf-8>
<title>IndexedDB: ES bindings - Inject a key into a value - Values bypass
setters</title>
<meta name="help"
href="https://w3c.github.io/IndexedDB/#inject-key-into-value-values-bypass-setters">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support-promises.js"></script>
<script>

promise_test(async t => {
const db = await createDatabase(t, db => {
db.createObjectStore('store', {autoIncrement: true, keyPath: 'id'});
});

let setter_called = false;
Object.defineProperty(Object.prototype, 'id', {
configurable: true,
set: value => { setter_called = true; },
});
t.add_cleanup(() => { delete Object.prototype['id']; });

const tx = db.transaction('store', 'readwrite');
tx.objectStore('store').put({});
const result = await promiseForRequest(t, tx.objectStore('store').get(1));

assert_false(setter_called,
'Setter should not be called for key result.');
assert_true(result.hasOwnProperty('id'),
'Result should have own-property overriding prototype setter.');
assert_equals(result.id, 1,
'Own property should match primary key generator value');
}, 'Returning values to script should bypass prototype setters');

</script>
Loading

0 comments on commit b55bf9f

Please sign in to comment.