mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
36 lines
1.4 KiB
HTML
36 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset="utf-8">
|
|
<title>Async local storage: undefined keys</title>
|
|
<!-- https://github.com/domenic/async-local-storage/commit/5bf31109f37d1371f619ea33d0e2391f10e8b8f5 -->
|
|
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
|
|
<script type="module">
|
|
import { StorageArea } from "std:async-local-storage";
|
|
import { testWithArea } from "./helpers/als-tests.js";
|
|
|
|
testWithArea(async (area) => {
|
|
assert_equals(await area.get("key"), undefined);
|
|
}, "Get on a non-existant key returns undefined");
|
|
|
|
testWithArea(async (area) => {
|
|
await area.set("key", undefined);
|
|
assert_equals(await area.get("key"), undefined);
|
|
|
|
assert_equals((await area.keys()).length, 0, "number of keys");
|
|
assert_equals((await area.values()).length, 0, "number of values");
|
|
assert_equals((await area.entries()).length, 0, "number of entries");
|
|
}, "Setting undefined as a value when nothing was present is a no-op");
|
|
|
|
testWithArea(async (area) => {
|
|
await area.set("key", "value");
|
|
await area.set("key", undefined);
|
|
|
|
assert_equals(await area.get("key"), undefined);
|
|
|
|
assert_equals((await area.keys()).length, 0, "number of keys");
|
|
assert_equals((await area.values()).length, 0, "number of values");
|
|
assert_equals((await area.entries()).length, 0, "number of entries");
|
|
}, "Setting undefined as a value deletes what was previously there");
|
|
</script>
|