Bug 1565515 - Added test keys with scalar ArrayBuffer and arrays containing ArrayBuffer r=asuth,ttung

Differential Revision: https://phabricator.services.mozilla.com/D37856

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Simon Giesecke 2019-07-30 14:51:03 +00:00
Родитель 8a9fca7aca
Коммит 7db6d8f44b
1 изменённых файлов: 24 добавлений и 0 удалений

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

@ -30,6 +30,7 @@ function* testSteps() {
// Create test stores
let store = db.createObjectStore("store");
let enc = new TextEncoder();
// Test simple inserts
// Note: the keys must be in order
@ -121,6 +122,20 @@ function* testSteps() {
"\uFFFF",
"\uFFFF\x00",
"\uFFFFZZZ",
// Note: enc.encode returns an Uint8Array, which is a valid key, but when
// converting it back and forth, the result will be a plain ArrayBuffer,
// which is expected in comparisons below
// TODO is it ok that the information that the original key was an
// Uint8Array is lost?
new ArrayBuffer(0),
Uint8Array.from([0]).buffer,
Uint8Array.from([0, 0]).buffer,
Uint8Array.from([0, 1]).buffer,
Uint8Array.from([0, 1, 0]).buffer,
enc.encode("abc").buffer,
enc.encode("abcd").buffer,
enc.encode("xyz").buffer,
Uint8Array.from([0x80]).buffer,
[],
[-1 / 0],
[-1],
@ -150,6 +165,15 @@ function* testSteps() {
["abc\x00\x00def"],
["x", [[]]],
["x", [[[]]]],
// see comment on scalar ArrayBuffers above
[new ArrayBuffer(0)],
[new ArrayBuffer(0), "abc"],
[new ArrayBuffer(0), new ArrayBuffer(0)],
[new ArrayBuffer(0), enc.encode("abc").buffer],
[enc.encode("abc").buffer],
[enc.encode("abc").buffer, new ArrayBuffer(0)],
[enc.encode("abc").buffer, enc.encode("xyz").buffer],
[enc.encode("xyz").buffer],
[[]],
[[], "foo"],
[[], []],