Skip to content

Commit

Permalink
idle-detection: Feature-Policy is now Permissions-Policy
Browse files Browse the repository at this point in the history
This change replaces #37110, renaming all of the
Feature Policy tests to Permissions Policy tests and using the
infrastructure from /permissions-policy instead.

Change-Id: I26c4619edd3aa12888fb4cef0aa371f0e14ffad4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4052880
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Raphael Kubo Da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/main@{#1075304}
  • Loading branch information
reillyeon authored and pull[bot] committed Dec 19, 2023
1 parent 33fd06e commit 5cad426
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 78 deletions.
10 changes: 0 additions & 10 deletions feature-policy/resources/feature-policy-idle-detection-worker.html

This file was deleted.

16 changes: 0 additions & 16 deletions feature-policy/resources/feature-policy-idle-detection-worker.js

This file was deleted.

10 changes: 0 additions & 10 deletions feature-policy/resources/feature-policy-idle-detection.html

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<script src=/resources/testdriver-vendor.js></script>
<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 base_src = '/feature-policy/resources/redirect-on-load.html#';
const base_src = '/permissions-policy/resources/redirect-on-load.html#';
const sub = 'https://{{domains[www]}}:{{ports[https][0]}}';
const relative_path =
'/feature-policy/resources/feature-policy-idle-detection.html';
'/permissions-policy/resources/permissions-policy-idle-detection.html';
const relative_worker_frame_path =
'/feature-policy/resources/feature-policy-idle-detection-worker.html';
'/permissions-policy/resources/permissions-policy-idle-detection-worker.html';
const same_origin_src = base_src + relative_path;
const same_origin_worker_frame_src = base_src + relative_worker_frame_path;
const cross_origin_src = base_src + sub + relative_path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<script src=/resources/testdriver-vendor.js></script>
<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-idle-detection.html'
'/permissions-policy/resources/permissions-policy-idle-detection.html'
const same_origin_worker_frame_src =
'/feature-policy/resources/feature-policy-idle-detection-worker.html';
'/permissions-policy/resources/permissions-policy-idle-detection-worker.html';
const cross_origin_src = sub + same_origin_src;
const cross_origin_worker_frame_src = sub + same_origin_worker_frame_src;

Expand All @@ -24,25 +24,25 @@
test_feature_availability('new IdleDetector().start()', t, same_origin_src,
expect_feature_available_default, 'idle-detection');
}, 'Attribute allow="idle-detection" in top-level frame can be enabled ' +
'in same-origin iframe using Feature policy "idle-detection".');
'in same-origin iframe using Permissions Policy "idle-detection".');

promise_test(async t => {
test_feature_availability('new IdleDetector().start()', t, same_origin_worker_frame_src,
expect_feature_available_default, 'idle-detection');
}, 'Attribute allow="idle-detection" in top-level frame can be enabled ' +
'in a worker in same-origin iframe using Feature policy "idle-detection".');
'in a worker in same-origin iframe using Permissions Policy "idle-detection".');

promise_test(async t => {
test_feature_availability('new IdleDetector().start()', t, cross_origin_src,
expect_feature_available_default, 'idle-detection');
}, 'Attribute allow="idle-detection" in top-level frame can be enabled ' +
'in cross-origin iframe using Feature policy "idle-detection".');
'in cross-origin iframe using Permissions Policy "idle-detection".');

promise_test(async t => {
test_feature_availability('new IdleDetector().start()', t, cross_origin_worker_frame_src,
expect_feature_available_default, 'idle-detection');
}, 'Attribute allow="idle-detection" in top-level frame can be enabled ' +
'in a worker in cross-origin iframe using Feature policy "idle-detection".');
'in a worker in cross-origin iframe using Permissions Policy "idle-detection".');

</script>
</body>
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<script src=/resources/testdriver-vendor.js></script>
<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-idle-detection.html'
'/permissions-policy/resources/permissions-policy-idle-detection.html'
const same_origin_worker_frame_src =
'/feature-policy/resources/feature-policy-idle-detection-worker.html';
'/permissions-policy/resources/permissions-policy-idle-detection-worker.html';
const cross_origin_src = sub + same_origin_src;
const cross_origin_worker_frame_src = sub + same_origin_worker_frame_src;

Expand All @@ -23,35 +23,35 @@
promise_test(async t => {
await new IdleDetector().start();
},
'Feature-Policy {"idle-detection" : ["*"]} explicity set by top-level ' +
'Permissions-Policy idle-detection=* explicity set by top-level ' +
'frame allows the top-level document.');

promise_test(async t => {
test_feature_availability('new IdleDetector().start()', t, same_origin_src,
expect_feature_available_default);
}, 'Feature-Policy {"idle-detection" : ["*"]} explicity set by top-level ' +
}, 'Permissions-Policy idle-detection=* explicity set by top-level ' +
'frame allows same-origin iframes.');

promise_test(async t => {
test_feature_availability('new IdleDetector().start()', t, same_origin_worker_frame_src,
expect_feature_available_default);
}, 'Feature-Policy {"idle-detection" : ["*"]} explicity set by top-level ' +
}, 'Permissions-Policy idle-detection=* explicity set by top-level ' +
'frame allows workers in same-origin iframes.');

promise_test(async t => {
test_feature_availability('new IdleDetector().start()', t, cross_origin_src,
expect_feature_available_default);
}, 'Feature-Policy {"idle-detection" : ["*"]} explicity set by top-level ' +
}, 'Permissions-Policy idle-detection=* explicity set by top-level ' +
'frame allows cross-origin iframes.');

promise_test(async t => {
test_feature_availability('new IdleDetector().start()', t, cross_origin_worker_frame_src,
expect_feature_available_default);
}, 'Feature-Policy {"idle-detection" : ["*"]} explicity set by top-level ' +
}, 'Permissions-Policy idle-detection=* explicity set by top-level ' +
'frame allows workers in cross-origin iframes.');

fetch_tests_from_worker(new Worker(
'resources/idle-detection-allowed-by-feature-policy-worker.js'))
'resources/idle-detection-allowed-by-permissions-policy-worker.js'))

</script>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Permissions-Policy: idle-detection=*
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<script src=/resources/testdriver-vendor.js></script>
<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 same_origin_src =
'/feature-policy/resources/feature-policy-idle-detection.html'
'/permissions-policy/resources/permissions-policy-idle-detection.html'
const cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
same_origin_src;

Expand All @@ -20,19 +20,19 @@
promise_test(async t => {
await new IdleDetector().start()
},
'Default "idle-detection" feature policy ["self"] ' +
'Default "idle-detection" permissions policy "self" ' +
'allows the top-level document.');

promise_test(async t => {
test_feature_availability('new IdleDetector().start()', t, same_origin_src,
expect_feature_available_default);
}, 'Default "idle-detection" feature policy ["self"] ' +
}, 'Default "idle-detection" permissions policy "self" ' +
'allows same-origin iframes.');

promise_test(async t => {
test_feature_availability('new IdleDetector().start()', t, cross_origin_src,
expect_feature_unavailable_default);
}, 'Default "idle-detection" feature policy ["self"] ' +
}, 'Default "idle-detection" permissions policy "self" ' +
'disallows cross-origin iframes.');

</script>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<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-idle-detection.html'
'/permissions-policy/resources/permissions-policy-idle-detection.html'
const same_origin_worker_frame_src =
'/feature-policy/resources/feature-policy-idle-detection-worker.html';
'/permissions-policy/resources/permissions-policy-idle-detection-worker.html';
const cross_origin_src = sub + same_origin_src;
const cross_origin_worker_frame_src = sub + same_origin_worker_frame_src;

Expand All @@ -22,35 +22,35 @@
} catch (error) {
assert_equals(error.name, 'SecurityError');
}
}, 'Feature-Policy {"idle-detection" : []} explicitly set by top-level frame ' +
}, 'Permissions-Policy idle-detection=() explicitly set by top-level frame ' +
'disallows query in the top-level document.');

async_test(t => {
test_feature_availability('new IdleDetector().start()', t, same_origin_src,
expect_feature_unavailable_default);
}, 'Feature-Policy {"idle-detection" : []} explicitly set by top-level frame ' +
}, 'Permissions-Policy idle-detection=() explicitly set by top-level frame ' +
'disallows same-origin iframes.');

async_test(t => {
test_feature_availability('new IdleDetector().start()', t, same_origin_worker_frame_src,
expect_feature_unavailable_default);
}, 'Feature-Policy {"idle-detection" : []} explicitly set by top-level frame ' +
}, 'Permissions-Policy idle-detection=() explicitly set by top-level frame ' +
'disallows workers in same-origin iframes.');

async_test(t => {
test_feature_availability('new IdleDetector().start()', t, cross_origin_src,
expect_feature_unavailable_default);
}, 'Feature-Policy {"idle-detection" : []} explicitly set by top-level frame ' +
}, 'Permissions-Policy idle-detection=() explicitly set by top-level frame ' +
'disallows cross-origin iframes.');

async_test(t => {
test_feature_availability('new IdleDetector().start()', t, cross_origin_worker_frame_src,
expect_feature_unavailable_default);
}, 'Feature-Policy {"idle-detection" : []} explicitly set by top-level frame ' +
}, 'Permissions-Policy idle-detection=() explicitly set by top-level frame ' +
'disallows workers in cross-origin iframes.');

fetch_tests_from_worker(new Worker(
'resources/idle-detection-disabled-by-feature-policy-worker.js'))
'resources/idle-detection-disabled-by-permissions-policy-worker.js'))

</script>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Permissions-Policy: idle-detection=()
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ if (typeof postMessage === 'function') {
promise_test(async () => {
await new IdleDetector().start()
},
`Inherited header feature policy allows ${workerType} workers.`)
`Inherited header permissions policy allows ${workerType} workers.`)

done();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

importScripts('/resources/testharness.js');

const header = 'Feature-Policy header {"idle-detection" : []}';
const header = 'Permissions-Policy header idle-detection=()';
let workerType;

if (typeof postMessage === 'function') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ if (typeof postMessage === 'function') {
switch(event.data.type) {
case 'ready':
new IdleDetector().start().then(() => {
postMessage({ enabled: true });
postMessage({ type: 'availability-result', enabled: true });
}, error => {
postMessage ({ enabled: false });
postMessage ({ type: 'availability-result', enabled: false });
});
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
'use strict';

new IdleDetector().start().then(() => {
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>

0 comments on commit 5cad426

Please sign in to comment.