Skip to content

Test BigInt as keys and values in IndexedDB#9667

Closed
littledan wants to merge 1 commit intoweb-platform-tests:masterfrom
littledan:indexeddb-test
Closed

Test BigInt as keys and values in IndexedDB#9667
littledan wants to merge 1 commit intoweb-platform-tests:masterfrom
littledan:indexeddb-test

Conversation

@littledan
Copy link
Copy Markdown
Contributor

@littledan littledan commented Feb 26, 2018

BigInt and BigInt wrappers are supported in serialization, per
whatwg/html#3480
This support allows them to be used as IndexedDB values.

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
w3c/IndexedDB#231

BigInt and BigInt wrappers are supported in serialization, per
whatwg/html#3480
This support allows them to be used as IndexedDB values.

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
w3c/IndexedDB#231
Copy link
Copy Markdown
Contributor

@inexorabletash inexorabletash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tests!

"condition does not apply to initial value");
});

createdb(t).onupgradeneeded = function(e) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap the function in t.step_func() so that unexpected exceptions thrown in the async callback are tied to the test, e.g.

createdb(t).onupgradeneeded = t.step_func(e => { ... });


let i = 0;
function value(value, test) {
var t = async_test(document.title + " - " + (i++));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit: I find the async_test(t => { /*test body... */ }, description); form more readable, and it appears to be more common.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if the test name said something about what was being tested in this case; rather than document.title, how about "BigInts as values in IndexedDB"

This really helps implementers/reviewers when looking a big table of failures: you can tell what the failure was without reading the test.

Can this be passed in to the value() function rather than just using numbers, so it's clear what each case does?


</script>

<div id="log"></div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed; testharness will create this dynamically as needed

// https://github.com/whatwg/html/pull/3480
// This support allows them to be used as IndexedDB values.

let i = 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call this unique_test_id to make the usage clear?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But see below...

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Values</title>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe clarify the name: BigInts as Values and Keys in IndexedDB ?

};
}

value(1n, x => x === 1n);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add case where it's not the top-level record, e.g. {val: 1n} ?

// https://github.com/w3c/IndexedDB/pull/231

function invalidKey(key) {
var t = async_test(document.title + " - " + (i++));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as above, re: style and description.

function invalidKey(key) {
var t = async_test(document.title + " - " + (i++));

createdb(t).onupgradeneeded = function(e) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.step_func is needed here too.

@littledan
Copy link
Copy Markdown
Contributor Author

Thanks for this detailed review. I apologize for my delay in uploading a fixed-up PR. I intend to do so within 2-3 weeks; I'm just a bit busy with TC39 happening.

@littledan
Copy link
Copy Markdown
Contributor Author

Obsoleted by #10977

@littledan littledan closed this May 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants