webusb: Feature-Policy is now Permissions-Policy

This finishes the work started in web-platform-tests/wpt#37107 and
renames all the Feature Policy tests for WebUSB so that they are
Permissions Policy tests and use the resources from /permissions-policy.

Change-Id: Ib6c6722b25654d926cedefc0d0031c37cfbfcc9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4049072
Reviewed-by: Raphael Kubo Da Costa <raphael.kubo.da.costa@intel.com>
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1075238}
diff --git a/feature-policy/resources/feature-policy-usb-worker.html b/feature-policy/resources/feature-policy-usb-worker.html
deleted file mode 100644
index fa8a2d7..0000000
--- a/feature-policy/resources/feature-policy-usb-worker.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<script>
-'use strict';
-
-let worker = new Worker('feature-policy-usb-worker.js');
-
-worker.onmessage = event => {
-  window.parent.postMessage(event.data, '*');
-};
-worker.postMessage({ type: 'ready' });
-</script>
\ No newline at end of file
diff --git a/feature-policy/resources/feature-policy-usb-worker.js b/feature-policy/resources/feature-policy-usb-worker.js
deleted file mode 100644
index c294f14..0000000
--- a/feature-policy/resources/feature-policy-usb-worker.js
+++ /dev/null
@@ -1,14 +0,0 @@
-'use strict';
-
-// Dedicated worker
-if (typeof postMessage === 'function') {
-  onmessage = event => {
-    switch(event.data.type) {
-      case 'ready':
-        navigator.usb.getDevices().then(
-            () => postMessage({ enabled: true }),
-            error => postMessage ({ enabled: false }));
-        break;
-    }
-  };
-}
\ No newline at end of file
diff --git a/feature-policy/resources/feature-policy-usb.html b/feature-policy/resources/feature-policy-usb.html
deleted file mode 100644
index 99d47c6..0000000
--- a/feature-policy/resources/feature-policy-usb.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<script>
-'use strict';
-
-Promise.resolve().then(() => navigator.usb.getDevices()).then(devices => {
-  window.parent.postMessage({ enabled: true }, '*');
-}, error => {
-  window.parent.postMessage({ enabled: false }, '*');
-});
-</script>
diff --git a/permissions-policy/resources/permissions-policy-usb-worker.js b/permissions-policy/resources/permissions-policy-usb-worker.js
index c294f14..97d96e7 100644
--- a/permissions-policy/resources/permissions-policy-usb-worker.js
+++ b/permissions-policy/resources/permissions-policy-usb-worker.js
@@ -6,9 +6,9 @@
     switch(event.data.type) {
       case 'ready':
         navigator.usb.getDevices().then(
-            () => postMessage({ enabled: true }),
-            error => postMessage ({ enabled: false }));
+            () => postMessage({ type: 'availability-result', enabled: true }),
+            error => postMessage ({ type: 'availability-result', enabled: false }));
         break;
     }
   };
-}
\ No newline at end of file
+}
diff --git a/permissions-policy/resources/permissions-policy-usb.html b/permissions-policy/resources/permissions-policy-usb.html
index 99d47c6..8812ca7 100644
--- a/permissions-policy/resources/permissions-policy-usb.html
+++ b/permissions-policy/resources/permissions-policy-usb.html
@@ -2,8 +2,8 @@
 'use strict';
 
 Promise.resolve().then(() => navigator.usb.getDevices()).then(devices => {
-  window.parent.postMessage({ enabled: true }, '*');
+  window.parent.postMessage({ type: 'availability-result', enabled: true }, '*');
 }, error => {
-  window.parent.postMessage({ enabled: false }, '*');
+  window.parent.postMessage({ type: 'availability-result', enabled: false }, '*');
 });
 </script>
diff --git a/webusb/resources/usb-allowed-by-feature-policy-worker.js b/webusb/resources/usb-allowed-by-permissions-policy-worker.js
similarity index 73%
rename from webusb/resources/usb-allowed-by-feature-policy-worker.js
rename to webusb/resources/usb-allowed-by-permissions-policy-worker.js
index 99ac97e..d06a586 100644
--- a/webusb/resources/usb-allowed-by-feature-policy-worker.js
+++ b/webusb/resources/usb-allowed-by-permissions-policy-worker.js
@@ -9,6 +9,6 @@
 }
 
 promise_test(() => navigator.usb.getDevices(),
-    `Inherited header feature policy allows ${workerType} workers.`);
+    `Inherited header permissions policy allows ${workerType} workers.`);
 
 done();
diff --git a/webusb/resources/usb-disabled-by-feature-policy-worker.js b/webusb/resources/usb-disabled-by-permissions-policy-worker.js
similarity index 88%
rename from webusb/resources/usb-disabled-by-feature-policy-worker.js
rename to webusb/resources/usb-disabled-by-permissions-policy-worker.js
index 5934956..caf2727 100644
--- a/webusb/resources/usb-disabled-by-feature-policy-worker.js
+++ b/webusb/resources/usb-disabled-by-permissions-policy-worker.js
@@ -2,7 +2,7 @@
 
 importScripts('/resources/testharness.js');
 
-const header = 'Feature-Policy header {"usb" : []}';
+const header = 'Permissions-Policy header usb=()';
 let workerType;
 
 if (typeof postMessage === 'function') {
diff --git a/webusb/usb-allowed-by-feature-policy.https.sub.html.headers b/webusb/usb-allowed-by-feature-policy.https.sub.html.headers
deleted file mode 100644
index 5c7eac0..0000000
--- a/webusb/usb-allowed-by-feature-policy.https.sub.html.headers
+++ /dev/null
@@ -1 +0,0 @@
-Feature-Policy: usb *
diff --git a/webusb/usb-allowed-by-feature-policy-attribute-redirect-on-load.https.sub.html b/webusb/usb-allowed-by-permissions-policy-attribute-redirect-on-load.https.sub.html
similarity index 79%
rename from webusb/usb-allowed-by-feature-policy-attribute-redirect-on-load.https.sub.html
rename to webusb/usb-allowed-by-permissions-policy-attribute-redirect-on-load.https.sub.html
index e0757fe..013efd9 100644
--- a/webusb/usb-allowed-by-feature-policy-attribute-redirect-on-load.https.sub.html
+++ b/webusb/usb-allowed-by-permissions-policy-attribute-redirect-on-load.https.sub.html
@@ -2,20 +2,20 @@
 <body>
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
-<script src=/feature-policy/resources/featurepolicy.js></script>
+<script src=/permissions-policy/resources/permissions-policy.js></script>
 <script>
 'use strict';
-const relative_path = '/feature-policy/resources/feature-policy-usb.html';
-const base_src = '/feature-policy/resources/redirect-on-load.html#';
+const relative_path = '/permissions-policy/resources/permissions-policy-usb.html';
+const base_src = '/permissions-policy/resources/redirect-on-load.html#';
 const relative_worker_frame_path =
-    '/feature-policy/resources/feature-policy-usb-worker.html';
+    '/permissions-policy/resources/permissions-policy-usb-worker.html';
 const sub = 'https://{{domains[www]}}:{{ports[https][0]}}';
 const same_origin_src = base_src + relative_path;
 const cross_origin_src = base_src + sub + relative_path;
 const same_origin_worker_frame_src = base_src + relative_worker_frame_path;
 const cross_origin_worker_frame_src = base_src + sub +
     relative_worker_frame_path;
-const header = 'Feature-Policy allow="usb"';
+const header = 'Permissions-Policy allow="usb"';
 
 async_test(t => {
   test_feature_availability(
diff --git a/webusb/usb-allowed-by-feature-policy-attribute.https.sub.html b/webusb/usb-allowed-by-permissions-policy-attribute.https.sub.html
similarity index 79%
rename from webusb/usb-allowed-by-feature-policy-attribute.https.sub.html
rename to webusb/usb-allowed-by-permissions-policy-attribute.https.sub.html
index 078db14..54af693 100644
--- a/webusb/usb-allowed-by-feature-policy-attribute.https.sub.html
+++ b/webusb/usb-allowed-by-permissions-policy-attribute.https.sub.html
@@ -2,16 +2,16 @@
 <body>
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
-<script src=/feature-policy/resources/featurepolicy.js></script>
+<script src=/permissions-policy/resources/permissions-policy.js></script>
 <script>
 'use strict';
 const sub = 'https://{{domains[www]}}:{{ports[https][0]}}';
-const same_origin_src = '/feature-policy/resources/feature-policy-usb.html';
+const same_origin_src = '/permissions-policy/resources/permissions-policy-usb.html';
 const cross_origin_src = sub + same_origin_src;
 const same_origin_worker_frame_src =
-    '/feature-policy/resources/feature-policy-usb-worker.html';
+    '/permissions-policy/resources/permissions-policy-usb-worker.html';
 const cross_origin_worker_frame_src = sub + same_origin_worker_frame_src;
-const feature_name = 'Feature policy "usb"';
+const feature_name = 'Permissions policy "usb"';
 const header = 'allow="usb" attribute';
 
 async_test(t => {
@@ -41,6 +41,6 @@
     header);
 
 fetch_tests_from_worker(new Worker(
-    '/webusb/resources/usb-allowed-by-feature-policy-worker.js'));
+    '/webusb/resources/usb-allowed-by-permissions-policy-worker.js'));
 </script>
 </body>
diff --git a/webusb/usb-allowed-by-feature-policy.https.sub.html b/webusb/usb-allowed-by-permissions-policy.https.sub.html
similarity index 80%
rename from webusb/usb-allowed-by-feature-policy.https.sub.html
rename to webusb/usb-allowed-by-permissions-policy.https.sub.html
index 831cb42..e1461fe 100644
--- a/webusb/usb-allowed-by-feature-policy.https.sub.html
+++ b/webusb/usb-allowed-by-permissions-policy.https.sub.html
@@ -2,16 +2,16 @@
 <body>
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
-<script src=/feature-policy/resources/featurepolicy.js></script>
+<script src=/permissions-policy/resources/permissions-policy.js></script>
 <script>
 'use strict';
 const sub = 'https://{{domains[www]}}:{{ports[https][0]}}';
-const same_origin_src = '/feature-policy/resources/feature-policy-usb.html';
+const same_origin_src = '/permissions-policy/resources/permissions-policy-usb.html';
 const cross_origin_src = sub + same_origin_src;
 const same_origin_worker_frame_src =
-    '/feature-policy/resources/feature-policy-usb-worker.html';
+    '/permissions-policy/resources/permissions-policy-usb-worker.html';
 const cross_origin_worker_frame_src = sub + same_origin_worker_frame_src;
-const header = 'Feature-Policy header {"usb" : ["*"]}';
+const header = 'Permissions-Policy header usb=*';
 
 promise_test(
     () => navigator.usb.getDevices(),
@@ -41,6 +41,6 @@
 }, header + ' allows workers in cross-origin iframes.');
 
 fetch_tests_from_worker(new Worker(
-    '/webusb/resources/usb-allowed-by-feature-policy-worker.js'));
+    '/webusb/resources/usb-allowed-by-permissions-policy-worker.js'));
 </script>
 </body>
diff --git a/webusb/usb-allowed-by-permissions-policy.https.sub.html.headers b/webusb/usb-allowed-by-permissions-policy.https.sub.html.headers
new file mode 100644
index 0000000..022b027
--- /dev/null
+++ b/webusb/usb-allowed-by-permissions-policy.https.sub.html.headers
@@ -0,0 +1 @@
+Permissions-Policy: usb=*
diff --git a/webusb/usb-default-feature-policy.https.sub.html b/webusb/usb-default-permissions-policy.https.sub.html
similarity index 76%
rename from webusb/usb-default-feature-policy.https.sub.html
rename to webusb/usb-default-permissions-policy.https.sub.html
index 34dda52..5a9ddcb 100644
--- a/webusb/usb-default-feature-policy.https.sub.html
+++ b/webusb/usb-default-permissions-policy.https.sub.html
@@ -2,13 +2,13 @@
 <body>
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
-<script src=/feature-policy/resources/featurepolicy.js></script>
+<script src=/permissions-policy/resources/permissions-policy.js></script>
 <script>
 'use strict';
-var same_origin_src = '/feature-policy/resources/feature-policy-usb.html';
+var same_origin_src = '/permissions-policy/resources/permissions-policy-usb.html';
 var cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
   same_origin_src;
-var header = 'Default "usb" feature policy ["self"]';
+var header = 'Default "usb" permissions policy ["self"]';
 
 promise_test(
     () => navigator.usb.getDevices(),
diff --git a/webusb/usb-disabled-by-feature-policy.https.sub.html.headers b/webusb/usb-disabled-by-feature-policy.https.sub.html.headers
deleted file mode 100644
index 4fd1e26..0000000
--- a/webusb/usb-disabled-by-feature-policy.https.sub.html.headers
+++ /dev/null
@@ -1 +0,0 @@
-Feature-Policy: usb 'none'
diff --git a/webusb/usb-disabled-by-feature-policy.https.sub.html b/webusb/usb-disabled-by-permissions-policy.https.sub.html
similarity index 83%
rename from webusb/usb-disabled-by-feature-policy.https.sub.html
rename to webusb/usb-disabled-by-permissions-policy.https.sub.html
index 97e66b2..3217d32 100644
--- a/webusb/usb-disabled-by-feature-policy.https.sub.html
+++ b/webusb/usb-disabled-by-permissions-policy.https.sub.html
@@ -2,16 +2,16 @@
 <body>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
-<script src="/feature-policy/resources/featurepolicy.js"></script>
+<script src="/permissions-policy/resources/permissions-policy.js"></script>
 <script>
 'use strict';
 const sub = 'https://{{domains[www]}}:{{ports[https][0]}}';
-const same_origin_src = '/feature-policy/resources/feature-policy-usb.html';
+const same_origin_src = '/permissions-policy/resources/permissions-policy-usb.html';
 const cross_origin_src = sub + same_origin_src;
 const same_origin_worker_frame_src =
-    '/feature-policy/resources/feature-policy-usb-worker.html';
+    '/permissions-policy/resources/permissions-policy-usb-worker.html';
 const cross_origin_worker_frame_src = sub + same_origin_worker_frame_src;
-const header = 'Feature-Policy header {"usb" : []}';
+const header = 'Permissions-Policy header usb=()';
 
 promise_test(() => {
   return navigator.usb.getDevices().then(() => {
@@ -52,6 +52,6 @@
 }, header + ' disallows workers in cross-origin iframes.');
 
 fetch_tests_from_worker(new Worker(
-    '/webusb/resources/usb-disabled-by-feature-policy-worker.js'));
+    '/webusb/resources/usb-disabled-by-permissions-policy-worker.js'));
 </script>
 </body>
diff --git a/webusb/usb-disabled-by-permissions-policy.https.sub.html.headers b/webusb/usb-disabled-by-permissions-policy.https.sub.html.headers
new file mode 100644
index 0000000..ff22d62
--- /dev/null
+++ b/webusb/usb-disabled-by-permissions-policy.https.sub.html.headers
@@ -0,0 +1 @@
+Permissions-Policy: usb=()
diff --git a/webusb/usb-supported-by-feature-policy.html b/webusb/usb-supported-by-permissions-policy.html
similarity index 65%
rename from webusb/usb-supported-by-feature-policy.html
rename to webusb/usb-supported-by-permissions-policy.html
index d5b585a..8e63521 100644
--- a/webusb/usb-supported-by-feature-policy.html
+++ b/webusb/usb-supported-by-permissions-policy.html
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <title>Test that usb is advertised in the feature list</title>
-<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
-<link rel="help" href="https://wicg.github.io/webusb/#feature-policy">
+<link rel="help" href="https://w3c.github.io/webappsec-permissions-policy/#dom-permissionspolicy-features">
+<link rel="help" href="https://wicg.github.io/webusb/#permissions-policy">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script>