Bug 1481585 [wpt PR 12344] - Fix some minor feature policy parsing issues, a=testonly
authorEhsan Karamad <ekaramad@chromium.org>
Fri, 30 Nov 2018 18:03:09 +0000
changeset 449991 8be996ec799ff3d17847a26e53a950adbfe58855
parent 449990 9c3669e31126ac5d3de457e70e1bd2de46d6f9c5
child 449992 988fb1f286accc0c15d9fc19410ed514598dfaf7
push id110435
push userjames@hoppipolla.co.uk
push dateTue, 11 Dec 2018 15:53:47 +0000
treeherdermozilla-inbound@add833a587f5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1481585, 12344, 710324, 1161753, 610887
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1481585 [wpt PR 12344] - Fix some minor feature policy parsing issues, a=testonly Automatic update from web-platform-tests Fix some minor feature policy parsing issues This CL makes the following changes to the feature policy parsing code: 1- ParsedFeaturePolicyDeclaration holds a sorted vector of unique |origins|. 2- AllowList uses std::set instead of std::vector. 3- When parsing for list of origins, in case of matching all origins (*), the current set of origins is cleared. 4- When comparing ParsedFeaturePolicyDeclaration, if both declarations include '*' then the set of origins are not compared. The noticeable outcome of the CL is that parsed policy will ignore repeated origins and will be sorted. This would make the feature lookup algorithm more efficient. Bug: 710324 Change-Id: I5c67ee2d6cff891304781bea0998e07739006a2e Reviewed-on: https://chromium-review.googlesource.com/c/1161753 Reviewed-by: Jeremy Roman <jbroman@chromium.org> Reviewed-by: Alex Moshchuk <alexmos@chromium.org> Reviewed-by: Ian Clelland <iclelland@chromium.org> Commit-Queue: Ehsan Karamad <ekaramad@chromium.org> Cr-Commit-Position: refs/heads/master@{#610887} -- wpt-commits: e6c06e195cb0c9170dbd67c1aec2091fa2c687b4 wpt-pr: 12344
testing/web-platform/tests/feature-policy/feature-policy-header-policy-allowed-for-some.https.sub.html
testing/web-platform/tests/feature-policy/feature-policy-header-policy-declined.https.sub.html
--- a/testing/web-platform/tests/feature-policy/feature-policy-header-policy-allowed-for-some.https.sub.html
+++ b/testing/web-platform/tests/feature-policy/feature-policy-header-policy-allowed-for-some.https.sub.html
@@ -11,18 +11,18 @@
   var same_origin_src = '/feature-policy/resources/feature-policy-allowedfeatures.html';
   var cross_origin_src = cross_origin + same_origin_src;
   var header_policy = 'Feature-Policy: fullscreen \'self\' ' + cross_origin +
   ' https://www.example.com;';
 
   // Test that fullscreen's allowlist is [same_origin, cross_origin, 'https://www.example.com']
   test(function() {
     assert_array_equals(
-      document.policy.getAllowlistForFeature('fullscreen'),
-      [same_origin, cross_origin, 'https://www.example.com']);
+      document.policy.getAllowlistForFeature('fullscreen').sort(),
+      [same_origin, cross_origin, 'https://www.example.com'].sort());
   }, header_policy + ' -- test allowlist is [same_origin, cross_origin, https://www.example.com]');
 
   // Test that fullscreen is allowed on same_origin, some cross_origin subframes.
   test_allowed_feature_for_subframe(
     header_policy + ' -- test fullscreen is allowed on same-origin subframe',
     'fullscreen',
     same_origin_src);
   test_allowed_feature_for_subframe(
--- a/testing/web-platform/tests/feature-policy/feature-policy-header-policy-declined.https.sub.html
+++ b/testing/web-platform/tests/feature-policy/feature-policy-header-policy-declined.https.sub.html
@@ -12,17 +12,17 @@
   var cross_origin_src = cross_origin + same_origin_src;
   var header_policy = 'Feature-Policy: fullscreen \'self\' ' + cross_origin +
   ' https://www.example.com;';
 
   // Test that fullscreen's allowlist is [same_origin, cross_origin, 'https://www.example.com']
   test(function() {
     assert_array_equals(
       document.policy.getAllowlistForFeature('fullscreen'),
-      [cross_origin, 'https://www.example.com']);
+      [cross_origin, 'https://www.example.com'].sort());
   }, header_policy + ' -- test allowlist is [cross_origin, https://www.example.com]');
 
   // Test that fullscreen is disallowed on same_origin, allowed on some cross_origin subframes.
   test_disallowed_feature_for_subframe(
     header_policy + ' -- test fullscreen is allowed on same-origin subframe',
     'fullscreen',
     same_origin_src);
   test_allowed_feature_for_subframe(