From 72da3e36e3657a358c4e74b495e582262b40a016 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Mon, 24 Jun 2019 23:53:46 -0700 Subject: [PATCH] KV Storage: update to match IDL Along with https://chromium-review.googlesource.com/c/chromium/src/+/1670572, this aligns the KV Storage implementation with https://github.com/WICG/kv-storage/pull/68, which uses Web IDL to define the API. The observable changes are to: * Enumerability of methods * Adding @@toStringTag (affecting Object.prototype.toString.call) This includes web platform tests that abuse the current idlharness.js infrastructure, plus some ad-hoc hand-written tests that we expect to be generated by future versions of idlharness.js once the relevant Web IDL pull requests are merged. It removes the existing API surface tests and helpers in favor of idlharness.js. Bug: 931263 Change-Id: I9205d1a8b3040617cbb6200f825ba9ad250e61c5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1672137 Commit-Queue: Domenic Denicola Reviewed-by: Joshua Bell Cr-Commit-Position: refs/heads/master@{#671975} --- kv-storage/api-surface.https.html | 70 --------- kv-storage/entries.https.html | 6 +- kv-storage/helpers/class-assert.js | 139 ----------------- kv-storage/helpers/expose-as-global.html | 8 + kv-storage/helpers/iter-assert.js | 42 ++++++ kv-storage/interface.https.html | 175 ++++++++++++++++++++++ kv-storage/keys-values-entries.https.html | 23 +-- kv-storage/keys.https.html | 6 +- kv-storage/values.https.html | 6 +- 9 files changed, 236 insertions(+), 239 deletions(-) delete mode 100644 kv-storage/api-surface.https.html delete mode 100644 kv-storage/helpers/class-assert.js create mode 100644 kv-storage/helpers/expose-as-global.html create mode 100644 kv-storage/helpers/iter-assert.js create mode 100644 kv-storage/interface.https.html diff --git a/kv-storage/api-surface.https.html b/kv-storage/api-surface.https.html deleted file mode 100644 index 90e705862d599f..00000000000000 --- a/kv-storage/api-surface.https.html +++ /dev/null @@ -1,70 +0,0 @@ - - -KV Storage: API surface - - - - - diff --git a/kv-storage/entries.https.html b/kv-storage/entries.https.html index 0d1ab849a709bc..6af7dcf3b35201 100644 --- a/kv-storage/entries.https.html +++ b/kv-storage/entries.https.html @@ -7,7 +7,7 @@ \ No newline at end of file diff --git a/kv-storage/helpers/iter-assert.js b/kv-storage/helpers/iter-assert.js new file mode 100644 index 00000000000000..e1ac73c8e9abd0 --- /dev/null +++ b/kv-storage/helpers/iter-assert.js @@ -0,0 +1,42 @@ +export function iterResultCustom(o, expectedValue, expectedDone, valueAsserter, label) { + label = formatLabel(label); + + assert_equals(typeof expectedDone, "boolean", + `${label} iterResult assert usage check: expectedDone must be a boolean`); + + propertyKeys(o, ["value", "done"], [], label); + assert_equals(Object.getPrototypeOf(o), Object.prototype, `${label}prototype must be Object.prototype`); + valueAsserter(o.value, expectedValue, `${label}value`); + assert_equals(o.done, expectedDone, `${label}done`); +} + +export function iterResult(o, expectedValue, expectedDone, label) { + return iterResultCustom(o, expectedValue, expectedDone, assert_equals, label); +} + +export function iterResultsCustom(actualArray, expectedArrayOfArrays, valueAsserter, label) { + label = formatLabel(label); + + assert_equals(actualArray.length, expectedArrayOfArrays.length, + `${label} iterResults assert usage check: actual and expected must have the same length`); + + for (let i = 0; i < actualArray.length; ++i) { + const [expectedValue, expectedDone] = expectedArrayOfArrays[i]; + iterResultCustom(actualArray[i], expectedValue, expectedDone, valueAsserter, `${label}iter result ${i}`); + } +} + +export function iterResults(actualArray, expectedArrayOfArrays, label) { + return iterResultsCustom(actualArray, expectedArrayOfArrays, assert_equals, label); +} + +function propertyKeys(o, expectedNames, expectedSymbols, label) { + label = formatLabel(label); + assert_array_equals(Object.getOwnPropertyNames(o), expectedNames, `${label}property names`); + assert_array_equals(Object.getOwnPropertySymbols(o), expectedSymbols, + `${label}property symbols`); +} + +function formatLabel(label) { + return label !== undefined ? `${label} ` : ""; +} diff --git a/kv-storage/interface.https.html b/kv-storage/interface.https.html new file mode 100644 index 00000000000000..ab1930b25c355e --- /dev/null +++ b/kv-storage/interface.https.html @@ -0,0 +1,175 @@ + + +KV Storage: IDL interface tests + + + + + + + \ No newline at end of file diff --git a/kv-storage/keys-values-entries.https.html b/kv-storage/keys-values-entries.https.html index b26323809bb3d3..18d44324e82258 100644 --- a/kv-storage/keys-values-entries.https.html +++ b/kv-storage/keys-values-entries.https.html @@ -12,30 +12,11 @@