Skip to content

Commit

Permalink
Test [[CanBlock]] in various agents
Browse files Browse the repository at this point in the history
Follows whatwg/html#2521.

Worklets are not tested at this time as their API is still in flux.
  • Loading branch information
domenic authored and annevk committed Apr 26, 2017
1 parent c98a3f6 commit 848be29
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>[[CanBlock]] in a dedicated worker agent</title>
<link rel="author" title="Domenic Denicola" href="mailto:[email protected]">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dedicated-worker-agent">
<link rel="help" href="https://tc39.github.io/ecma262/#sec-agentcansuspend">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
"use strict";
fetch_tests_from_worker(new Worker("worker-that-requires-success.js"));
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>[[CanBlock]] in a service worker agent</title>
<link rel="author" title="Domenic Denicola" href="mailto:[email protected]">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#service-worker-agent">
<link rel="help" href="https://tc39.github.io/ecma262/#sec-agentcansuspend">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>

<script>
"use strict";
service_worker_test("worker-that-requires-failure.js", "Service worker test setup");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>[[CanBlock]] in a shared worker agent</title>
<link rel="author" title="Domenic Denicola" href="mailto:[email protected]">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#shared-worker-agent">
<link rel="help" href="https://tc39.github.io/ecma262/#sec-agentcansuspend">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
"use strict";
fetch_tests_from_worker(new SharedWorker("worker-that-requires-success.js"));
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>[[CanBlock]] in a similar-origin window agent</title>
<link rel="author" title="Domenic Denicola" href="mailto:[email protected]">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#similar-origin-window-agent">
<link rel="help" href="https://tc39.github.io/ecma262/#sec-agentcansuspend">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
"use strict";

const sab = new SharedArrayBuffer(16);
const ta = new Int32Array(sab);

assert_throws(new TypeError(), () => {
Atomics.wait(ta, 0, 0, 10);
}, "Atomics.wait must throw in a window context");

done();
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use strict";
importScripts("/resources/testharness.js");

test(() => {
const sab = new SharedArrayBuffer(16);
const ta = new Int32Array(sab);

assert_throws(new TypeError(), () => {
Atomics.wait(ta, 0, 0, 10);
});
}, `[[CanBlock]] in a ${self.constructor.name}`);

done();
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use strict";
importScripts("/resources/testharness.js");

test(() => {
const sab = new SharedArrayBuffer(16);
const ta = new Int32Array(sab);

assert_equals(Atomics.wait(ta, 0, 0, 10), "timed-out");
}, `[[CanBlock]] in a ${self.constructor.name}`);

done();

0 comments on commit 848be29

Please sign in to comment.