[go: nahoru, domu]

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: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582778}
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/acquire.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/acquire.tentative.https.any.js
similarity index 92%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/acquire.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/acquire.tentative.https.any.js
index 65bf0e4..be0e837 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/acquire.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/acquire.tentative.https.any.js
@@ -1,11 +1,6 @@
-<!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 @@
   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>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/held.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/held.tentative.https.any.js
similarity index 88%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/held.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/held.tentative.https.any.js
index aecbbd3..151e3b3 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/held.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/held.tentative.https.any.js
@@ -1,11 +1,6 @@
-<!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 @@
   });
   assert_true(callback_called, 'callback should have executed');
 }, 'held lock prevents the same client from acquiring it');
-
-</script>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/ifAvailable.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/ifAvailable.tentative.https.any.js
similarity index 94%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/ifAvailable.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/ifAvailable.tentative.https.any.js
index 2b6e1ff..a63caf6 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/ifAvailable.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/ifAvailable.tentative.https.any.js
@@ -1,11 +1,6 @@
-<!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 @@
   });
   assert_true(callback1_called, 'callback1 should be called');
 }, 'Locks are available once previous release is processed');
-
-</script>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/lock-attributes.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/lock-attributes.tentative.https.any.js
similarity index 65%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/lock-attributes.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/lock-attributes.tentative.https.any.js
index 89ffec41..e94fc95a 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/lock-attributes.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/lock-attributes.tentative.https.any.js
@@ -1,10 +1,5 @@
-<!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 @@
     assert_equals(lock.mode, 'shared');
   });
 }, 'Lock attributes reflect requested properties (shared)');
-
-</script>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-exclusive.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-exclusive.tentative.https.any.js
similarity index 77%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-exclusive.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-exclusive.tentative.https.any.js
index 8c6005d04..91404622 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-exclusive.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-exclusive.tentative.https.any.js
@@ -1,10 +1,5 @@
-<!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 @@
   await inner_promise;
   assert_array_equals(granted, [2, 1]);
 }, 'Requests for distinct resources can be granted');
-
-</script>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-mixed.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-mixed.tentative.https.any.js
similarity index 83%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-mixed.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-mixed.tentative.https.any.js
index 0ce058364..3b30494 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-mixed.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-mixed.tentative.https.any.js
@@ -1,10 +1,5 @@
-<!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 @@
     ['a-shared-1', 'a-shared-2', 'a-shared-3', 'b-exclusive', 'a-exclusive']);
 
 }, 'Lock requests are granted in order');
-
-</script>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-shared.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-shared.tentative.https.any.js
similarity index 81%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-shared.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-shared.tentative.https.any.js
index 309ee57b..7c8a8448 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-shared.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/mode-shared.tentative.https.any.js
@@ -1,10 +1,5 @@
-<!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 @@
   assert_true(a_acquired, 'first lock acquired');
   assert_true(a_acquired_again, 'second lock acquired');
 }, 'Shared locks are not exclusive');
-
-</script>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/non-secure-context.tentative.any.js b/third_party/WebKit/LayoutTests/external/wpt/web-locks/non-secure-context.tentative.any.js
new file mode 100644
index 0000000..e9726e6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/non-secure-context.tentative.any.js
@@ -0,0 +1,13 @@
+// META title=Web Locks API: API not available in non-secure context
+
+'use strict';
+
+test(t => {
+  assert_false(self.isSecureContext);
+  assert_false('locks' in navigator,
+               'navigator.locks is only present in secure contexts');
+  assert_false('LockManager' in self,
+               'LockManager is only present in secure contexts');
+  assert_false('Lock' in self,
+               'Lock interface is only present in secure contexts');
+}, 'API presence in non-secure contexts');
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/non-secure-context.tentative.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/non-secure-context.tentative.html
deleted file mode 100644
index 568eb30e..0000000
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/non-secure-context.tentative.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!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>
-'use strict';
-
-test(t => {
-  assert_false(window.isSecureContext);
-  assert_false('locks' in navigator,
-               'navigator.locks is only present in secure contexts');
-  assert_false('LockManager' in self,
-               'LockManager is only present in secure contexts');
-  assert_false('Lock' in self,
-               'Lock interface is only present in secure contexts');
-}, 'API presence in non-secure contexts');
-</script>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/query-empty.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/query-empty.tentative.https.any.js
similarity index 64%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/query-empty.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/query-empty.tentative.https.any.js
index 38fed37..fe7e0bb 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/query-empty.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/query-empty.tentative.https.any.js
@@ -1,11 +1,6 @@
-<!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 @@
   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>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/query-order.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/query-order.tentative.https.any.js
similarity index 91%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/query-order.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/query-order.tentative.https.any.js
index e4fb7c5..1810a96 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/query-order.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/query-order.tentative.https.any.js
@@ -1,11 +1,6 @@
-<!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 @@
   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>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/query.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/query.tentative.https.any.js
similarity index 95%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/query.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/query.tentative.https.any.js
index 218e984..14fdeca7 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/query.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/query.tentative.https.any.js
@@ -1,11 +1,6 @@
-<!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 @@
   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>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/resource-names.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/resource-names.tentative.https.any.js
similarity index 84%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/resource-names.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/resource-names.tentative.https.any.js
index d4ac743..dbcd986 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/resource-names.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/resource-names.tentative.https.any.js
@@ -1,10 +1,5 @@
-<!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 @@
   });
   assert_true(got_lock, 'Names with embedded "-" should be accepted');
 }, 'Names cannot start with "-"');
-
-</script>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/secure-context.tentative.https.any.js b/third_party/WebKit/LayoutTests/external/wpt/web-locks/secure-context.tentative.https.any.js
new file mode 100644
index 0000000..2e1d3912
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/secure-context.tentative.https.any.js
@@ -0,0 +1,13 @@
+// META: title=Web Locks API: API requires secure context
+
+'use strict';
+
+test(t => {
+  assert_true(self.isSecureContext);
+  assert_idl_attribute(navigator, 'locks',
+                       'navigator.locks exists in secure context');
+  assert_true('LockManager' in self,
+              'LockManager is present in secure contexts');
+  assert_true('Lock' in self,
+              'Lock interface is present in secure contexts');
+}, 'API presence in secure contexts');
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/secure-context.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/secure-context.tentative.https.html
deleted file mode 100644
index a90b55d..0000000
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/secure-context.tentative.https.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!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>
-'use strict';
-
-test(t => {
-  assert_true(window.isSecureContext);
-  assert_idl_attribute(navigator, 'locks',
-                       'navigator.locks exists in secure context');
-  assert_true('LockManager' in self,
-              'LockManager is present in secure contexts');
-  assert_true('Lock' in self,
-              'Lock interface is present in secure contexts');
-}, 'API presence in secure contexts');
-</script>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/signal.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/signal.tentative.https.any.js
similarity index 94%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/signal.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/signal.tentative.https.any.js
index a070bde2..424b219 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/signal.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/signal.tentative.https.any.js
@@ -1,11 +1,6 @@
-<!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 @@
                 'Lock released promise should not reject');
 
 }, 'Abort signaled after lock released');
-
-</script>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-locks/steal.tentative.https.html b/third_party/WebKit/LayoutTests/external/wpt/web-locks/steal.tentative.https.any.js
similarity index 88%
rename from third_party/WebKit/LayoutTests/external/wpt/web-locks/steal.tentative.https.html
rename to third_party/WebKit/LayoutTests/external/wpt/web-locks/steal.tentative.https.any.js
index 169d849..ca99137 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/web-locks/steal.tentative.https.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/web-locks/steal.tentative.https.any.js
@@ -1,11 +1,6 @@
-<!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 @@
   assert_true(saw_abort, 'First steal should have aborted');
 
 }, 'Last caller wins');
-
-</script>