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: title=Web Locks API: navigator.locks.request method
<meta charset=utf-8> // META: script=resources/helpers.js
<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>
'use strict'; 'use strict';
promise_test(async t => { promise_test(async t => {
...@@ -126,5 +121,3 @@ promise_test(async t => { ...@@ -126,5 +121,3 @@ promise_test(async t => {
assert_equals(Promise.resolve(p), p, 'request() result is a Promise'); assert_equals(Promise.resolve(p), p, 'request() result is a Promise');
await promise_rejects(t, test_error, p, 'result should reject'); await promise_rejects(t, test_error, p, 'result should reject');
}, 'Returned Promise rejects if callback throws asynchronously'); }, 'Returned Promise rejects if callback throws asynchronously');
</script>
<!DOCTYPE html> // META: title=Web Locks API: Lock held until callback result resolves
<meta charset=utf-8> // META: script=resources/helpers.js
<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>
'use strict'; 'use strict';
// For uncaught rejections. // For uncaught rejections.
...@@ -93,5 +88,3 @@ promise_test(async t => { ...@@ -93,5 +88,3 @@ promise_test(async t => {
}); });
assert_true(callback_called, 'callback should have executed'); assert_true(callback_called, 'callback should have executed');
}, 'held lock prevents the same client from acquiring it'); }, 'held lock prevents the same client from acquiring it');
</script>
<!DOCTYPE html> // META: title=Web Locks API: ifAvailable option
<meta charset=utf-8> // META: script=resources/helpers.js
<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>
'use strict'; 'use strict';
promise_test(async t => { promise_test(async t => {
...@@ -165,5 +160,3 @@ promise_test(async t => { ...@@ -165,5 +160,3 @@ promise_test(async t => {
}); });
assert_true(callback1_called, 'callback1 should be called'); assert_true(callback1_called, 'callback1 should be called');
}, 'Locks are available once previous release is processed'); }, 'Locks are available once previous release is processed');
</script>
<!DOCTYPE html> // META: title=Web Locks API: Lock Attributes
<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>
'use strict'; 'use strict';
promise_test(async t => { promise_test(async t => {
...@@ -20,5 +15,3 @@ promise_test(async t => { ...@@ -20,5 +15,3 @@ promise_test(async t => {
assert_equals(lock.mode, 'shared'); assert_equals(lock.mode, 'shared');
}); });
}, 'Lock attributes reflect requested properties (shared)'); }, 'Lock attributes reflect requested properties (shared)');
</script>
<!DOCTYPE html> // META: title=Web Locks API: Exclusive Mode
<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>
'use strict'; 'use strict';
promise_test(async t => { promise_test(async t => {
...@@ -36,5 +31,3 @@ promise_test(async t => { ...@@ -36,5 +31,3 @@ promise_test(async t => {
await inner_promise; await inner_promise;
assert_array_equals(granted, [2, 1]); assert_array_equals(granted, [2, 1]);
}, 'Requests for distinct resources can be granted'); }, 'Requests for distinct resources can be granted');
</script>
<!DOCTYPE html> // META: title=Web Locks API: Mixed Modes
<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>
'use strict'; 'use strict';
promise_test(async t => { promise_test(async t => {
...@@ -47,5 +42,3 @@ 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']); ['a-shared-1', 'a-shared-2', 'a-shared-3', 'b-exclusive', 'a-exclusive']);
}, 'Lock requests are granted in order'); }, 'Lock requests are granted in order');
</script>
<!DOCTYPE html> // META: title=Web Locks API: Shared Mode
<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>
'use strict'; 'use strict';
promise_test(async t => { promise_test(async t => {
...@@ -40,5 +35,3 @@ promise_test(async t => { ...@@ -40,5 +35,3 @@ promise_test(async t => {
assert_true(a_acquired, 'first lock acquired'); assert_true(a_acquired, 'first lock acquired');
assert_true(a_acquired_again, 'second lock acquired'); assert_true(a_acquired_again, 'second lock acquired');
}, 'Shared locks are not exclusive'); }, 'Shared locks are not exclusive');
</script>
<!DOCTYPE html> // META title=Web Locks API: API not available in non-secure context
<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>
'use strict'; 'use strict';
test(t => { test(t => {
assert_false(window.isSecureContext); assert_false(self.isSecureContext);
assert_false('locks' in navigator, assert_false('locks' in navigator,
'navigator.locks is only present in secure contexts'); 'navigator.locks is only present in secure contexts');
assert_false('LockManager' in self, assert_false('LockManager' in self,
...@@ -16,4 +11,3 @@ test(t => { ...@@ -16,4 +11,3 @@ test(t => {
assert_false('Lock' in self, assert_false('Lock' in self,
'Lock interface is only present in secure contexts'); 'Lock interface is only present in secure contexts');
}, 'API presence in non-secure contexts'); }, 'API presence in non-secure contexts');
</script>
<!DOCTYPE html> // META: title=Web Locks API: navigator.locks.query method - no locks held
<meta charset=utf-8> // META: script=resources/helpers.js
<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>
'use strict'; 'use strict';
promise_test(async t => { promise_test(async t => {
...@@ -20,5 +15,3 @@ 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_true(Array.isArray(state.held), 'State `held` property is an array');
assert_array_equals(state.held, [], 'Held array is empty'); assert_array_equals(state.held, [], 'Held array is empty');
}, 'query() returns dictionary with empty arrays when no locks are held'); }, 'query() returns dictionary with empty arrays when no locks are held');
</script>
<!DOCTYPE html> // META: title=Web Locks API: navigator.locks.query ordering
<meta charset=utf-8> // META: script=resources/helpers.js
<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>
'use strict'; 'use strict';
// Grab a lock and hold until a release function is called. Resolves // Grab a lock and hold until a release function is called. Resolves
...@@ -112,5 +107,3 @@ promise_test(async t => { ...@@ -112,5 +107,3 @@ promise_test(async t => {
assert_array_equals(relevant_held_names, [res3, res1, res2], assert_array_equals(relevant_held_names, [res3, res1, res2],
'Held locks should appear in granted order.'); 'Held locks should appear in granted order.');
}, 'Held locks appear in state in order granted, including when stolen'); }, 'Held locks appear in state in order granted, including when stolen');
</script>
<!DOCTYPE html> // META: title=Web Locks API: navigator.locks.query method
<meta charset=utf-8> // META: script=resources/helpers.js
<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>
'use strict'; 'use strict';
// Returns an array of the modes for the locks with matching name. // Returns an array of the modes for the locks with matching name.
...@@ -230,5 +225,3 @@ promise_test(async t => { ...@@ -230,5 +225,3 @@ promise_test(async t => {
assert_equals(res1_held_clients[0], res2_pending_clients[0]); assert_equals(res1_held_clients[0], res2_pending_clients[0]);
assert_equals(res2_held_clients[0], res1_pending_clients[0]); assert_equals(res2_held_clients[0], res1_pending_clients[0]);
}, 'query() can observe a deadlock'); }, 'query() can observe a deadlock');
</script>
<!DOCTYPE html> // META: title=Web Locks API: Resources DOMString edge cases
<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>
'use strict'; 'use strict';
function code_points(s) { function code_points(s) {
...@@ -58,5 +53,3 @@ promise_test(async t => { ...@@ -58,5 +53,3 @@ promise_test(async t => {
}); });
assert_true(got_lock, 'Names with embedded "-" should be accepted'); assert_true(got_lock, 'Names with embedded "-" should be accepted');
}, 'Names cannot start with "-"'); }, 'Names cannot start with "-"');
</script>
<!DOCTYPE html> // META: title=Web Locks API: API requires secure context
<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>
'use strict'; 'use strict';
test(t => { test(t => {
assert_true(window.isSecureContext); assert_true(self.isSecureContext);
assert_idl_attribute(navigator, 'locks', assert_idl_attribute(navigator, 'locks',
'navigator.locks exists in secure context'); 'navigator.locks exists in secure context');
assert_true('LockManager' in self, assert_true('LockManager' in self,
...@@ -16,4 +11,3 @@ test(t => { ...@@ -16,4 +11,3 @@ test(t => {
assert_true('Lock' in self, assert_true('Lock' in self,
'Lock interface is present in secure contexts'); 'Lock interface is present in secure contexts');
}, 'API presence in secure contexts'); }, 'API presence in secure contexts');
</script>
<!DOCTYPE html> // META: title=Web Locks API: AbortSignal integration
<meta charset=utf-8> // META: script=resources/helpers.js
<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>
'use strict'; 'use strict';
function makePromiseAndResolveFunc() { function makePromiseAndResolveFunc() {
...@@ -198,5 +193,3 @@ promise_test(async t => { ...@@ -198,5 +193,3 @@ promise_test(async t => {
'Lock released promise should not reject'); 'Lock released promise should not reject');
}, 'Abort signaled after lock released'); }, 'Abort signaled after lock released');
</script>
<!DOCTYPE html> // META: title=Web Locks API: steal option
<meta charset=utf-8> // META: script=resources/helpers.js
<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>
'use strict'; 'use strict';
const never_settled = new Promise(resolve => { /* never */ }); const never_settled = new Promise(resolve => { /* never */ });
...@@ -93,5 +88,3 @@ promise_test(async t => { ...@@ -93,5 +88,3 @@ promise_test(async t => {
assert_true(saw_abort, 'First steal should have aborted'); assert_true(saw_abort, 'First steal should have aborted');
}, 'Last caller wins'); }, '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