Skip to content

Commit

Permalink
[Permissions Policy] update default for focus-without-user-activation
Browse files Browse the repository at this point in the history
According to discussion[1] in webappsec WG and WHATWG, we should set
the default of `focus-without-user-activation` permissions policy to
`EnableForSelf`.

[1]: w3c/webappsec-permissions-policy#273 (comment)

Bug: 371112534
Change-Id: I7deb757d0074e1262d07f768e58ea53a99d5faa5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5950528
Reviewed-by: Sanket Joshi <sajos@microsoft.com>
Commit-Queue: Siye Liu <siliu@microsoft.com>
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1374868}
  • Loading branch information
siliu1 authored and chromium-wpt-export-bot committed Oct 28, 2024
1 parent 801bc17 commit d8fcad0
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<meta charset="utf-8">
<title>Focus test middle document</title>
<h1>Middle</h1><br>
<iframe src="https://{{hosts[][www]}}:{{ports[https][0]}}/focus/support/activeelement-after-calling-window-focus-inner.html"></iframe>
<iframe allow="focus-without-user-activation" src="https://{{hosts[][www]}}:{{ports[https][0]}}/focus/support/activeelement-after-calling-window-focus-inner.html"></iframe>
<script>
let middlelog = "middlelog:";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<meta charset="utf-8">
<title>Focus test outer document</title>
<iframe src="https://{{hosts[alt][www]}}:{{ports[https][0]}}/focus/support/activeelement-after-calling-window-focus-middle.sub.html"></iframe>
<iframe allow="focus-without-user-activation" src="https://{{hosts[alt][www]}}:{{ports[https][0]}}/focus/support/activeelement-after-calling-window-focus-middle.sub.html"></iframe>
<script>
let outerlog = "outerlog:";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<meta charset="utf-8">
<title>Focus test outer document</title>
<iframe src="https://{{hosts[][www]}}:{{ports[https][0]}}/focus/support/activeelement-after-calling-window-focus-middle.sub.html"></iframe>
<iframe allow="focus-without-user-activation" src="https://{{hosts[][www]}}:{{ports[https][0]}}/focus/support/activeelement-after-calling-window-focus-middle.sub.html"></iframe>
<script>
let outerlog = "outerlog:";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
}, 1500);
}
</script>
<iframe src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/activeelement-after-focusing-different-site-iframe-inner-contentwindow.html"></iframe>
<iframe allow="focus-without-user-activation" src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/activeelement-after-focusing-different-site-iframe-inner-contentwindow.html"></iframe>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<meta charset="utf-8">
<title>iframe.contentWindow.focus() with different-site intermediate frame middle</title>
<iframe src="http://{{hosts[][www]}}:{{ports[http][0]}}/focus/support/iframe-contentwindow-focus-with-different-site-intermediate-frame-inner.html"></iframe>
<iframe allow="focus-without-user-activation" src="http://{{hosts[][www]}}:{{ports[http][0]}}/focus/support/iframe-contentwindow-focus-with-different-site-intermediate-frame-inner.html"></iframe>
<script>
let iframe = document.getElementsByTagName("iframe")[0];
let log = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
}, 3000);
}
</script>
<iframe src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/iframe-contentwindow-focus-with-different-site-intermediate-frame-middle.sub.html"></iframe>
<iframe allow="focus-without-user-activation" src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/iframe-contentwindow-focus-with-different-site-intermediate-frame-middle.sub.html"></iframe>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<meta charset="utf-8">
<title>iframe.contentWindow.focus() with same-as-top intermediate frame middle</title>
<iframe src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/iframe-contentwindow-focus-with-same-as-top-intermediate-frame-inner.html"></iframe>
<iframe allow="focus-without-user-activation" src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/iframe-contentwindow-focus-with-same-as-top-intermediate-frame-inner.html"></iframe>
<script>
let iframe = document.getElementsByTagName("iframe")[0];
let log = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
}, 2000);
}
</script>
<iframe src="iframe-contentwindow-focus-with-same-as-top-intermediate-frame-middle.sub.html"></iframe>
<iframe allow="focus-without-user-activation" src="iframe-contentwindow-focus-with-same-as-top-intermediate-frame-middle.sub.html"></iframe>
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
}, 3000);
}
</script>
<iframe src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/iframe-focus-with-different-site-intermediate-frame-middle.sub.html"></iframe>
<iframe allow="focus-without-user-activation" src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/iframe-focus-with-different-site-intermediate-frame-middle.sub.html"></iframe>
2 changes: 1 addition & 1 deletion generic-sensor/generic-sensor-iframe-tests.sub.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function run_generic_sensor_iframe_tests(sensorData, readingData) {

// Create cross-origin iframe and a sensor inside it.
const iframe = document.createElement('iframe');
iframe.allow = featurePolicies.join(';') + ';';
iframe.allow = featurePolicies.join(';') + '; focus-without-user-activation;';
iframe.src =
'https://{{domains[www1]}}:{{ports[https][0]}}/generic-sensor/resources/iframe_sensor_handler.html';
const iframeLoadWatcher = new EventWatcher(t, iframe, 'load');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<title>Focus without user activation container policy test</title>

<body>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/permissions-policy/resources/permissions-policy.js></script>
<script>
'use strict';
var same_origin_src = '/permissions-policy/experimental-features/resources/permissions-policy-focus-without-user-activation.html';
var cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
same_origin_src;
const header = 'Default "focus-without-user-activation" permissions policy [self]';
async_test(t => {
test_feature_availability(
'focus-without-user-activation', t, same_origin_src, expect_feature_available_default);
}, header + " allows same-origin iframes.");

async_test(t => {
test_feature_availability(
'focus-without-user-activation', t, cross_origin_src, expect_feature_unavailable_default);
}, header + " doesn't allow cross-origin iframes.");
</script>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<script>
'use strict';
function post_result(enabled) {
parent.postMessage({ type: 'availability-result', enabled }, "*");
}

window.onload = function () {
post_result(document.featurePolicy.allowedFeatures().includes("focus-without-user-activation"));
}
</script>

0 comments on commit d8fcad0

Please sign in to comment.