Commit fb378298 authored by Blink WPT Bot's avatar Blink WPT Bot Committed by moz-wptsync-bot
Browse files

Bug 1639938 [wpt PR 23731] - Reduce cross frame messages in...

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: default avatarIan Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771658}
Co-authored-by: default avatarCharlie Hu <chenleihu@google.com>
--

wpt-commits: 2228dbdd370235f8bad3330aaec613f9d3ec6ac7
wpt-pr: 23731
parent bf5905c3
......@@ -2,12 +2,16 @@
<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');
......@@ -25,18 +29,21 @@ 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);
......
......@@ -354,13 +354,9 @@ function test_subframe_header_policy(
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) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment