summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/key-value-store.https.html
blob: ba6b1c0a4f582a9de8ce91f6699c2c9cb7ac7245 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<title>Test the key value store</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="resources/utils.js"></script>

<body>

<script>
promise_test(async () => {
  const key = token();
  const test_value = "TESTVALUE";

  let server_value = await readValueFromServer(key);
  assert_false(server_value.status,
               "The server returns a sentinel value when requesting a value " +
               "that the stash does not have");

  server_value = await readValueFromServer(key);
  assert_false(server_value.status,
               "Requesting a not-set value twice is idempotent");

  writeValueToServer(key, "");
  server_value = await nextValueFromServer(key);
  assert_equals(server_value, "",
                "The server correctly identifies that an empty string was " +
                "set, and returns it, and not the sentinel value");

  writeValueToServer(key, test_value);
  server_value = await nextValueFromServer(key);
  assert_equals(server_value, test_value,
                "The server correctly sets and returns non-empty strings");

  writeValueToServer(key, "");
  server_value = await nextValueFromServer(key);
  assert_equals(server_value, "",
                "The server correctly identifies empty strings after dealing " +
                "with non-empty-string values");
}, "Test the key-value store, specifically with empty strings");
</script>

</body>