summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/streams/transferable/resources/deserialize-error-frame.html
blob: 5ec2fcda2cdd8dba66ed97240cb836d45596c905 (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
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="create-wasm-module.js"></script>
<script>
async_test(t => {
  parent.postMessage('init done', '*');
  window.addEventListener('message', async evt => {
    if (evt.data.constructor.name !== 'WritableStream') {
      return;
    }
    const ws = evt.data;
    const writer = ws.getWriter();
    const module = await createWasmModule();
    writer.write(module);
    await promise_rejects_dom(t, 'DataCloneError', writer.closed,
                              'should reject with a DataCloneError');
    t.done();
    // Signal that this test is done. When both tests are done the iframe will
    // be removed.
    parent.postMessage('ws done', '*');
  });
}, 'a WritableStream deserialization failure should result in a DataCloneError');

async_test(t => {
  window.addEventListener('message', async evt => {
    if (evt.data.constructor.name !== 'ReadableStream') {
      return;
    }
    const rs = evt.data;
    const reader = rs.getReader();
    await promise_rejects_dom(t, 'DataCloneError', reader.read(),
                              'should reject with a DataCloneError');
    t.done();
    // Signal that this test is done. When both tests are done the iframe will
    // be removed.
    parent.postMessage('rs done', '*');
  });
}, 'a ReadableStream deserialization failure should result in a DataCloneError');
</script>