-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WPT tests for feature policy frame policy
1. Without specifying allow attribute, frame policy inherits correctly. 2. With allow attribute, frame policy inherits from and overrides header policy correctly. Updating allowfullscreen and allowpaymentrequest correctly updates frame policy. 3. Frame policy is not affected by the frame's document policy. Bug: 732003 Change-Id: Ib41f883a779f11c564c91cfc03ff1224330108f5
- Loading branch information
1 parent
998ec50
commit f5eda07
Showing
8 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<!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'; | ||
var local_origin = 'https://{{domains[]}}:{{ports[https][0]}}'; | ||
var cross_origin = 'https://{{domains[www]}}:{{ports[https][0]}}'; | ||
var src = '/feature-policy/resources/feature-policy-frame-policy.html'; | ||
var src1 = '/feature-policy/resources/feature-policy-frame-policy-with-headers.https.sub.html'; | ||
|
||
// Withouth iframe allow attribute, frame.policy will inherit from header policy. | ||
test(function() { | ||
test_frame_policy( | ||
['usb', 'speaker', 'camera', 'geolocation', 'fullscreen', 'payment'], | ||
['midi'], | ||
local_origin + src); | ||
}, 'Test frame.policy on local iframe without allow attribute'); | ||
test(function() { | ||
test_frame_policy( | ||
['usb', 'camera'], | ||
// speaker, geolocation, fullscreen and payment are allowed for self. | ||
['midi', 'speaker', 'geolocation', 'fullscreen', 'payment'], | ||
cross_origin + src); | ||
}, 'Test frame.policy on remote iframe without allow attribute'); | ||
|
||
// With allow attribute: | ||
// - midi is disabled by parents, cannot be enabled in subframes. | ||
// - geolocation is not disabled by parents, can be enabled for subframes. | ||
// - usb is enabled by parents, but disabled by subframes. | ||
// - allowfullscreen overrides parent policy, fullscreen is allowed for subframes. | ||
// - allowpaymentrequest overrides parent policy, but is overriden by allow attribute. | ||
var allow = "midi *; geolocation 'src'; usb 'none'; payment 'self';"; | ||
test(function() { | ||
test_frame_policy( | ||
['speaker', 'camera', 'geolocation', 'fullscreen', 'payment'], | ||
['usb', 'midi'], | ||
local_origin + src, | ||
allow, true, true); | ||
}, 'Test frame.policy on local iframe with allow attribute'); | ||
test(function() { | ||
test_frame_policy( | ||
['camera', 'geolocation', 'fullscreen'], | ||
['speaker', 'usb', 'midi', 'payment'], | ||
cross_origin + src, | ||
allow, true, true); | ||
}, 'Test frame.policy on remote iframe with allow attribute'); | ||
|
||
// However, if header policy is set for the subframe documents, frame.policy does not get affected. | ||
// Subframe header policy: | ||
// Feature-Policy: camera 'none'; fullscreen 'none'; payment 'none'; | ||
test(function() { | ||
test_frame_policy( | ||
['speaker', 'camera', 'geolocation', 'fullscreen', 'payment'], | ||
['usb', 'midi'], | ||
local_origin + src1, | ||
allow, true, true); | ||
}, 'Test frame.policy on local iframe with allow attribute and header policy'); | ||
test(function() { | ||
test_frame_policy( | ||
['camera', 'geolocation', 'fullscreen'], | ||
['speaker', 'usb', 'midi', 'payment'], | ||
cross_origin + src1, | ||
allow, true, true); | ||
}, 'Test frame.policy on remote iframe with allow attribute and header policy'); | ||
</script> | ||
</body> |
1 change: 1 addition & 0 deletions
1
feature-policy/feature-policy-frame-policy.https.sub.html.sub.headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Feature-Policy: usb *; speaker 'self'; midi 'none'; camera 'self' https://{{domains[www]}}:{{ports[https][0]}} https://www.example.com; geolocation 'self'; fullscreen 'self'; payment 'self'; |
1 change: 1 addition & 0 deletions
1
feature-policy/feature-policy-header-policy.https.sub.html.sub.headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Feature-Policy: fullscreen *; payment 'self'; midi 'none'; camera 'self' https://{{domains[www]}}:{{ports[https][0]}} https://www.example.com; geolocation 'self' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
'use strict'; | ||
|
||
window.onload = function() { | ||
parent.postMessage(document.policy.allowedFeatures(), '*'); | ||
} | ||
</script> |
2 changes: 2 additions & 0 deletions
2
feature-policy/resources/feature-policy-frame-policy-with-headers.https.sub.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<!DOCTYPE html> | ||
<p>Test frame policy</p> |
1 change: 1 addition & 0 deletions
1
feature-policy/resources/feature-policy-frame-policy-with-headers.https.sub.html.sub.headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Feature-Policy: camera 'none'; fullscreen 'none'; payment 'none'; |
7 changes: 7 additions & 0 deletions
7
feature-policy/resources/feature-policy-subframe-policy.https.sub.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
'use strict'; | ||
|
||
window.onload = function() { | ||
parent.postMessage(document.policy.allowedFeatures(), '*'); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters