Files
tubestation/testing/web-platform/tests/idle-detection/idle-detection-disabled-by-feature-policy.https.sub.html
Sam Goto bdf8f37952 Bug 1536014 [wpt PR 15829] - [idle] Port to the IdleDetector API, a=testonly
Automatic update from web-platform-tests
[idle] Port to the IdleDetector API

This is a minimal/incomplete/incremental port from the existing API
to the IdleDetector API under consideration.

https://github.com/w3ctag/design-reviews/issues/336#issuecomment-470077151

I'm trying to keep this baseline deliberately small, so we can introduce
the other parts of the API incrementally.

Change-Id: I4db6c67c561d397f1b027bc7c5524c5f8af17715
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1512681
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Sam Goto <goto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642648}

--

wpt-commits: 6e129aedfa10bbd9801fe25f8e401d251964afe2
wpt-pr: 15829
2019-04-24 11:18:43 +01:00

57 lines
2.1 KiB
HTML

<!DOCTYPE html>
<body>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/feature-policy/resources/featurepolicy.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'
const same_origin_worker_frame_src =
'/feature-policy/resources/feature-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;
promise_test(async () => {
try {
let idleDetector = new IdleDetector();
await idleDetector.start();
assert_unreached('expected promise to reject with SecurityError');
} catch (error) {
assert_equals(error.name, 'SecurityError');
}
}, 'Feature-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 ' +
'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 ' +
'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 ' +
'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 ' +
'disallows workers in cross-origin iframes.');
fetch_tests_from_worker(new Worker(
'resources/idle-detection-disabled-by-feature-policy-worker.js'))
</script>
</body>