Commit 09fe42b0 authored by Joshua Bell's avatar Joshua Bell Committed by Commit Bot

Web Locks API: Convert .html tests to .any.js where applicable

Most tests can run in window and worker contexts, so make it so.

Bug: 161072
Change-Id: Ic0df3a888e477d27562dce957807dde36dc8f420
Reviewed-on: https://chromium-review.googlesource.com/1171255
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582778}
parent 9ecd1145
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: navigator.locks.request method</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<script>
// META: title=Web Locks API: navigator.locks.request method
// META: script=resources/helpers.js
'use strict';
promise_test(async t => {
......@@ -126,5 +121,3 @@ promise_test(async t => {
assert_equals(Promise.resolve(p), p, 'request() result is a Promise');
await promise_rejects(t, test_error, p, 'result should reject');
}, 'Returned Promise rejects if callback throws asynchronously');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: Lock held until callback result resolves</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<script>
// META: title=Web Locks API: Lock held until callback result resolves
// META: script=resources/helpers.js
'use strict';
// For uncaught rejections.
......@@ -93,5 +88,3 @@ promise_test(async t => {
});
assert_true(callback_called, 'callback should have executed');
}, 'held lock prevents the same client from acquiring it');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: ifAvailable option</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<script>
// META: title=Web Locks API: ifAvailable option
// META: script=resources/helpers.js
'use strict';
promise_test(async t => {
......@@ -165,5 +160,3 @@ promise_test(async t => {
});
assert_true(callback1_called, 'callback1 should be called');
}, 'Locks are available once previous release is processed');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: Lock Attributes</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// META: title=Web Locks API: Lock Attributes
'use strict';
promise_test(async t => {
......@@ -20,5 +15,3 @@ promise_test(async t => {
assert_equals(lock.mode, 'shared');
});
}, 'Lock attributes reflect requested properties (shared)');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: Exclusive Mode</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// META: title=Web Locks API: Exclusive Mode
'use strict';
promise_test(async t => {
......@@ -36,5 +31,3 @@ promise_test(async t => {
await inner_promise;
assert_array_equals(granted, [2, 1]);
}, 'Requests for distinct resources can be granted');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: Mixed Modes</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// META: title=Web Locks API: Mixed Modes
'use strict';
promise_test(async t => {
......@@ -47,5 +42,3 @@ promise_test(async t => {
['a-shared-1', 'a-shared-2', 'a-shared-3', 'b-exclusive', 'a-exclusive']);
}, 'Lock requests are granted in order');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: Shared Mode</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// META: title=Web Locks API: Shared Mode
'use strict';
promise_test(async t => {
......@@ -40,5 +35,3 @@ promise_test(async t => {
assert_true(a_acquired, 'first lock acquired');
assert_true(a_acquired_again, 'second lock acquired');
}, 'Shared locks are not exclusive');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: API not available in non-secure context</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// META title=Web Locks API: API not available in non-secure context
'use strict';
test(t => {
assert_false(window.isSecureContext);
assert_false(self.isSecureContext);
assert_false('locks' in navigator,
'navigator.locks is only present in secure contexts');
assert_false('LockManager' in self,
......@@ -16,4 +11,3 @@ test(t => {
assert_false('Lock' in self,
'Lock interface is only present in secure contexts');
}, 'API presence in non-secure contexts');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: navigator.locks.query method - no locks held</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<script>
// META: title=Web Locks API: navigator.locks.query method - no locks held
// META: script=resources/helpers.js
'use strict';
promise_test(async t => {
......@@ -20,5 +15,3 @@ promise_test(async t => {
assert_true(Array.isArray(state.held), 'State `held` property is an array');
assert_array_equals(state.held, [], 'Held array is empty');
}, 'query() returns dictionary with empty arrays when no locks are held');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: navigator.locks.query ordering</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<script>
// META: title=Web Locks API: navigator.locks.query ordering
// META: script=resources/helpers.js
'use strict';
// Grab a lock and hold until a release function is called. Resolves
......@@ -112,5 +107,3 @@ promise_test(async t => {
assert_array_equals(relevant_held_names, [res3, res1, res2],
'Held locks should appear in granted order.');
}, 'Held locks appear in state in order granted, including when stolen');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: navigator.locks.query method</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<script>
// META: title=Web Locks API: navigator.locks.query method
// META: script=resources/helpers.js
'use strict';
// Returns an array of the modes for the locks with matching name.
......@@ -230,5 +225,3 @@ promise_test(async t => {
assert_equals(res1_held_clients[0], res2_pending_clients[0]);
assert_equals(res2_held_clients[0], res1_pending_clients[0]);
}, 'query() can observe a deadlock');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: Resources DOMString edge cases</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// META: title=Web Locks API: Resources DOMString edge cases
'use strict';
function code_points(s) {
......@@ -58,5 +53,3 @@ promise_test(async t => {
});
assert_true(got_lock, 'Names with embedded "-" should be accepted');
}, 'Names cannot start with "-"');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: API requires secure context</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// META: title=Web Locks API: API requires secure context
'use strict';
test(t => {
assert_true(window.isSecureContext);
assert_true(self.isSecureContext);
assert_idl_attribute(navigator, 'locks',
'navigator.locks exists in secure context');
assert_true('LockManager' in self,
......@@ -16,4 +11,3 @@ test(t => {
assert_true('Lock' in self,
'Lock interface is present in secure contexts');
}, 'API presence in secure contexts');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: AbortSignal integration</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<script>
// META: title=Web Locks API: AbortSignal integration
// META: script=resources/helpers.js
'use strict';
function makePromiseAndResolveFunc() {
......@@ -198,5 +193,3 @@ promise_test(async t => {
'Lock released promise should not reject');
}, 'Abort signaled after lock released');
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<title>Web Locks API: steal option</title>
<link rel=help href="https://wicg.github.io/web-locks/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<script>
// META: title=Web Locks API: steal option
// META: script=resources/helpers.js
'use strict';
const never_settled = new Promise(resolve => { /* never */ });
......@@ -93,5 +88,3 @@ promise_test(async t => {
assert_true(saw_abort, 'First steal should have aborted');
}, 'Last caller wins');
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment