Bug 1639938 [wpt PR 23731] - Reduce cross frame messages in feature-policy-nested-subframe-policy.https.sub.html, a=testonly
authorBlink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Wed, 27 May 2020 21:36:43 +0000
changeset 533057 9d767e432fd5738efba8e735ec2a6b423c0aafe0
parent 533056 a5e2ffab8261722c789e678ece54f36e844c05c1
child 533058 66dc5283c5b374b61bd32a772d0168a6371dc876
push id37462
push usermalexandru@mozilla.com
push dateSat, 30 May 2020 09:46:43 +0000
treeherdermozilla-central@8aaca63ec5c6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1639938, 23731, 2212486, 771658
milestone78.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 1639938 [wpt PR 23731] - Reduce cross frame messages in feature-policy-nested-subframe-policy.https.sub.html, a=testonly Automatic update from web-platform-tests Reduce cross frame messages in feature-policy-nested-subframe-policy.https.sub.html (#23731) Previously each 1st level subframe will post 6 messages to main frame. This CL reduce the message send to to main frame to 1 message, effectively improve the test speed. Change-Id: I20dcbe3a74aa9359185c61673ff1b5e39a1eea68 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212486 Commit-Queue: Charlie Hu <chenleihu@google.com> Reviewed-by: Ian Clelland <iclelland@chromium.org> Cr-Commit-Position: refs/heads/master@{#771658} Co-authored-by: Charlie Hu <chenleihu@google.com> -- wpt-commits: 2228dbdd370235f8bad3330aaec613f9d3ec6ac7 wpt-pr: 23731
testing/web-platform/tests/feature-policy/resources/feature-policy-nested-subframe-policy.https.sub.html
testing/web-platform/tests/feature-policy/resources/featurepolicy.js
--- a/testing/web-platform/tests/feature-policy/resources/feature-policy-nested-subframe-policy.https.sub.html
+++ b/testing/web-platform/tests/feature-policy/resources/feature-policy-nested-subframe-policy.https.sub.html
@@ -1,18 +1,22 @@
 <!DOCTYPE html>
 <body>
 <script>
 'use strict';
-var same_origin_src = '/feature-policy/resources/feature-policy-allowedfeatures.html';
-var cross_origin_src = 'https://{{domains[www1]}}:{{ports[https][0]}}' + same_origin_src;
-var subframe_header_policy = '?pipe=header(Feature-Policy, fullscreen ';
-var policy_all = '*';
-var policy_self = '\'self\'';
-var policy_none = '\'none\'';
+const same_origin_src = '/feature-policy/resources/feature-policy-allowedfeatures.html';
+const cross_origin_src = 'https://{{domains[www1]}}:{{ports[https][0]}}' + same_origin_src;
+const subframe_header_policy = '?pipe=header(Feature-Policy, fullscreen ';
+const policy_all = '*';
+const policy_self = '\'self\'';
+const policy_none = '\'none\'';
+
+// Messages gathered from subframes. When all subframe messages are gathered,
+// it will be send back to top level frame.
+const subframe_messages = [];
 
 let local_frame_all = document.createElement('iframe');
 let local_frame_self = document.createElement('iframe');
 let local_frame_none = document.createElement('iframe');
 local_frame_all.src = same_origin_src + subframe_header_policy + policy_all + ';)';
 local_frame_self.src = same_origin_src + subframe_header_policy + policy_self + ';)';
 local_frame_none.src = same_origin_src + subframe_header_policy + policy_none + ';)';
 
@@ -20,28 +24,31 @@ let remote_frame_all = document.createEl
 let remote_frame_self = document.createElement('iframe');
 let remote_frame_none = document.createElement('iframe');
 remote_frame_all.src = cross_origin_src + subframe_header_policy + policy_all + ';)';
 remote_frame_self.src = cross_origin_src + subframe_header_policy + policy_self + ';)';
 remote_frame_none.src = cross_origin_src + subframe_header_policy + policy_none + ';)';
 
 window.addEventListener('message', function(evt) {
   if (evt.source === local_frame_all.contentWindow) {
-    parent.postMessage({frame: 'local', policy: policy_all, allowedfeatures: evt.data}, '*');
+    subframe_messages.push({frame: 'local', policy: policy_all, allowedfeatures: evt.data});
   } else if (evt.source === local_frame_self.contentWindow) {
-    parent.postMessage({frame: 'local', policy: policy_self, allowedfeatures: evt.data}, '*');
+    subframe_messages.push({frame: 'local', policy: policy_self, allowedfeatures: evt.data});
   } else if (evt.source === local_frame_none.contentWindow) {
-    parent.postMessage({frame: 'local', policy: policy_none, allowedfeatures: evt.data}, '*');
+    subframe_messages.push({frame: 'local', policy: policy_none, allowedfeatures: evt.data});
   } else if (evt.source === remote_frame_all.contentWindow) {
-    parent.postMessage({frame: 'remote', policy: policy_all, allowedfeatures: evt.data}, '*');
+    subframe_messages.push({frame: 'remote', policy: policy_all, allowedfeatures: evt.data});
   } else if (evt.source === remote_frame_self.contentWindow) {
-    parent.postMessage({frame: 'remote', policy: policy_self, allowedfeatures: evt.data}, '*');
+    subframe_messages.push({frame: 'remote', policy: policy_self, allowedfeatures: evt.data});
   } else if (evt.source === remote_frame_none.contentWindow) {
-    parent.postMessage({frame: 'remote', policy: policy_none, allowedfeatures: evt.data}, '*');
+    subframe_messages.push({frame: 'remote', policy: policy_none, allowedfeatures: evt.data});
   }
+
+  if (subframe_messages.length == 6)
+    parent.postMessage(subframe_messages, '*');
 });
 
 document.body.appendChild(local_frame_all);
 document.body.appendChild(local_frame_self);
 document.body.appendChild(local_frame_none);
 document.body.appendChild(remote_frame_all);
 document.body.appendChild(remote_frame_self);
 document.body.appendChild(remote_frame_none);
--- a/testing/web-platform/tests/feature-policy/resources/featurepolicy.js
+++ b/testing/web-platform/tests/feature-policy/resources/featurepolicy.js
@@ -349,23 +349,19 @@ function test_disallowed_feature_for_sub
 //     test_name: name of the test.
 function test_subframe_header_policy(
     feature, frame_header_policy, src, test_expects, test_name) {
   let frame = document.createElement('iframe');
   promise_test(function() {
     assert_feature_policy_supported()
     frame.src = src + '?pipe=sub|header(Feature-Policy,' + feature + ' '
         + frame_header_policy + ';)';
-    return new Promise(function(resolve, reject) {
-      let results = [];
+    return new Promise(function(resolve) {
       window.addEventListener('message', function handler(evt) {
-        results.push(evt.data);
-        if (results.length >= 6) {
-          resolve(results);
-        }
+        resolve(evt.data);
       });
       document.body.appendChild(frame);
     }).then(function(results) {
       for (var j = 0; j < results.length; j++) {
         var data = results[j];
 
         function test_result(message, test_expect) {
           if (test_expect) {