11cb0ef41Sopenharmony_ci<!doctype html>
21cb0ef41Sopenharmony_ci<meta charset="utf-8">
31cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
41cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
51cb0ef41Sopenharmony_ci<body>
61cb0ef41Sopenharmony_ci<script>
71cb0ef41Sopenharmony_ciasync_test(t => {
81cb0ef41Sopenharmony_ci  const blob_contents = 'test blob contents';
91cb0ef41Sopenharmony_ci  const blob = new Blob([blob_contents]);
101cb0ef41Sopenharmony_ci  const url = URL.createObjectURL(blob);
111cb0ef41Sopenharmony_ci  const frame = document.createElement('iframe');
121cb0ef41Sopenharmony_ci  frame.setAttribute('style', 'display:none;');
131cb0ef41Sopenharmony_ci  frame.src = 'resources/revoke-helper.html';
141cb0ef41Sopenharmony_ci  document.body.appendChild(frame);
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci  frame.onload = t.step_func(e => {
171cb0ef41Sopenharmony_ci    frame.contentWindow.postMessage({url: url}, '*');
181cb0ef41Sopenharmony_ci  });
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci  self.addEventListener('message', t.step_func(e => {
211cb0ef41Sopenharmony_ci    if (e.source !== frame.contentWindow) return;
221cb0ef41Sopenharmony_ci    assert_equals(e.data, 'revoked');
231cb0ef41Sopenharmony_ci    promise_rejects_js(t, TypeError, fetch(url)).then(t.step_func_done());
241cb0ef41Sopenharmony_ci  }));
251cb0ef41Sopenharmony_ci}, 'It is possible to revoke same-origin blob URLs from different frames.');
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ciasync_test(t => {
281cb0ef41Sopenharmony_ci  const blob_contents = 'test blob contents';
291cb0ef41Sopenharmony_ci  const blob = new Blob([blob_contents]);
301cb0ef41Sopenharmony_ci  const url = URL.createObjectURL(blob);
311cb0ef41Sopenharmony_ci  const worker = new Worker('resources/revoke-helper.js');
321cb0ef41Sopenharmony_ci  worker.onmessage = t.step_func(e => {
331cb0ef41Sopenharmony_ci    assert_equals(e.data, 'revoked');
341cb0ef41Sopenharmony_ci    promise_rejects_js(t, TypeError, fetch(url)).then(t.step_func_done());
351cb0ef41Sopenharmony_ci  });
361cb0ef41Sopenharmony_ci  worker.postMessage({url: url});
371cb0ef41Sopenharmony_ci}, 'It is possible to revoke same-origin blob URLs from a different worker global.');
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ciasync_test(t => {
401cb0ef41Sopenharmony_ci  const blob_contents = 'test blob contents';
411cb0ef41Sopenharmony_ci  const blob = new Blob([blob_contents]);
421cb0ef41Sopenharmony_ci  const url = URL.createObjectURL(blob);
431cb0ef41Sopenharmony_ci  const frame = document.createElement('iframe');
441cb0ef41Sopenharmony_ci  frame.setAttribute('style', 'display:none;');
451cb0ef41Sopenharmony_ci  frame.src = '//{{domains[www1]}}:{{location[port]}}/FileAPI/url/resources/revoke-helper.html';
461cb0ef41Sopenharmony_ci  document.body.appendChild(frame);
471cb0ef41Sopenharmony_ci
481cb0ef41Sopenharmony_ci  frame.onload = t.step_func(e => {
491cb0ef41Sopenharmony_ci    frame.contentWindow.postMessage({url: url}, '*');
501cb0ef41Sopenharmony_ci  });
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci  self.addEventListener('message', t.step_func(e => {
531cb0ef41Sopenharmony_ci    if (e.source !== frame.contentWindow) return;
541cb0ef41Sopenharmony_ci    assert_equals(e.data, 'revoked');
551cb0ef41Sopenharmony_ci    fetch(url).then(response => response.text()).then(t.step_func_done(text => {
561cb0ef41Sopenharmony_ci      assert_equals(text, blob_contents);
571cb0ef41Sopenharmony_ci    }), t.unreached_func('Unexpected promise rejection'));
581cb0ef41Sopenharmony_ci  }));
591cb0ef41Sopenharmony_ci}, 'It is not possible to revoke cross-origin blob URLs.');
601cb0ef41Sopenharmony_ci
611cb0ef41Sopenharmony_ci</script>