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. This downgrades the resources submodule due to #5568 which prevents these tests (and many, many other tests in WPT) from working.

Worklets are not tested at this time due to spec uncertainty.
  • Loading branch information
domenic committed Apr 14, 2017
1 parent 2ea12eb commit 295a5e1
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 1 deletion.
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:d@domenic.me">
<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:d@domenic.me">
<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:d@domenic.me">
<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:d@domenic.me">
<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,17 @@
"use strict";
importScripts("/resources/testharness.js");

console.log("what is wrong with shared workers");

test(() => {
console.log("got here?! 1111");
const sab = new SharedArrayBuffer(16);
const ta = new Int32Array(sab);

console.log("got here?!");

// Test passes if this doesn't throw
Atomics.wait(ta, 0, 0, 10);
}, `[[CanBlock]] in a ${self.constructor.name}`);

done();
2 changes: 1 addition & 1 deletion resources

0 comments on commit 295a5e1

Please sign in to comment.