summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/wasm/webapi/historical.any.js
blob: 257112c4160f5424d12d175319322c2f5ae1576b (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
// META: global=window,worker

promise_test(async t => {
  const db_name = "WebAssembly";
  const obj_store = "store";
  const module_key = "module";

  await new Promise((resolve, reject) => {
    const delete_request = indexedDB.deleteDatabase(db_name);
    delete_request.onsuccess = resolve;
    delete_request.onerror = reject;
  });

  const db = await new Promise((resolve, reject) => {
    const open_request = indexedDB.open(db_name);
    open_request.onupgradeneeded = function() {
      open_request.result.createObjectStore(obj_store);
    };
    open_request.onsuccess = function() {
      resolve(open_request.result);
    };
    open_request.onerror = reject;
  });

  const mod = await WebAssembly.compileStreaming(fetch('../incrementer.wasm'));
  const tx = db.transaction(obj_store, 'readwrite');
  const store = tx.objectStore(obj_store);
  assert_throws_dom("DataCloneError", () => store.put(mod, module_key));
});