Skip to content

Commit

Permalink
Bug 1561129 [wpt PR 17443] - KV Storage: update to match IDL, a=testonly
Browse files Browse the repository at this point in the history
Automatic update from web-platform-tests
KV Storage: update to match IDL

Along with https://chromium-review.googlesource.com/c/chromium/src/+/1670572, this aligns the KV Storage implementation with WICG/kv-storage#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 <domenic@chromium.org>
Reviewed-by: Joshua Bell <jsbell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#671975}

--

wpt-commits: 72da3e36e3657a358c4e74b495e582262b40a016
wpt-pr: 17443
  • Loading branch information
domenic authored and jgraham committed Jul 24, 2019
1 parent e863b6c commit 1081afa
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 239 deletions.
70 changes: 0 additions & 70 deletions testing/web-platform/tests/kv-storage/api-surface.https.html

This file was deleted.

6 changes: 3 additions & 3 deletions testing/web-platform/tests/kv-storage/entries.https.html
Expand Up @@ -7,7 +7,7 @@

<script type="module">
import { testWithArea } from "./helpers/kvs-tests.js";
import * as classAssert from "./helpers/class-assert.js";
import * as iterAssert from "./helpers/iter-assert.js";
import {
assertAsyncIteratorEquals,
assertAsyncIteratorCustomEquals,
Expand Down Expand Up @@ -76,7 +76,7 @@
await iter.next()
];

classAssert.iterResultsCustom(
iterAssert.iterResultsCustom(
iterResults,
[
[[1, "value 1"], false],
Expand Down Expand Up @@ -106,7 +106,7 @@
];
const iterResults = await Promise.all(promises);

classAssert.iterResultsCustom(
iterAssert.iterResultsCustom(
iterResults,
[
[[1, "value 1"], false],
Expand Down
139 changes: 0 additions & 139 deletions testing/web-platform/tests/kv-storage/helpers/class-assert.js

This file was deleted.

@@ -0,0 +1,8 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Helper file to be loaded in an iframe that exposes a copy of StorageArea as a global</title>

<script type="module">
import { StorageArea } from "std:kv-storage";
window.StorageArea = StorageArea;
</script>
42 changes: 42 additions & 0 deletions testing/web-platform/tests/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} ` : "";
}

0 comments on commit 1081afa

Please sign in to comment.