summaryrefslogtreecommitdiffstats
path: root/dom/indexedDB/test/unit/test_URLSearchParams.js
blob: 92278989631038f26b35edd0de3347a55e06b3ae (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
44
45
46
47
48
49
50
51
/*
  Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/
*/

/* exported testSteps */
async function testSteps() {
  const name = "URLSearchParams";
  const options = { foo: "bar", baz: "bar" };
  const params = new URLSearchParams(options);
  const value = { urlSearchParams: params };
  const key = 42;

  info("Clearing");

  let request = clearAllDatabases();
  await requestFinished(request);

  info("Installing package");

  // The profile contains an IndexedDB database containing URLSearchParams.
  // The file make_URLSearchParams.js was run locally, specifically it was
  // temporarily enabled in xpcshell-parent-process.toml  and then executed:
  // mach test --interactive dom/indexedDB/test/unit/make_URLSearchParams.js
  installPackagedProfile("URLSearchParams_profile");

  info("Opening database");

  request = indexedDB.open(name);
  await requestSucceeded(request);

  const database = request.result;

  info("Getting value");

  request = database.transaction([name]).objectStore(name).get(key);
  await requestSucceeded(request);

  info("Verifying value");

  Assert.deepEqual(request.result, value, "Value is correctly structured");

  ok(
    request.result.urlSearchParams instanceof URLSearchParams,
    "Value urlSearchParams property is an instance of URLSearchParams"
  );

  info("Closing database");

  database.close();
}