Commit 1c0d3de1 authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Fix wpt/beacon/headers/header-content-type.html slowness

This CL uses ResourceTiming API to speed up the test cases while
avoiding flakiness.

Bug: 779965
Change-Id: I40dc2fae470df296c87c12e432fc7fc7644cc40a
Reviewed-on: https://chromium-review.googlesource.com/923625
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537664}
parent 7e4d9a27
......@@ -465,8 +465,6 @@ crbug.com/626703 [ Debug ] external/wpt/html/nemantics/tabular-data/processing-m
# This test continues to fail as timeout on Win7(dbg)
crbug.com/757292 [ Win Debug ] external/wpt/encoding/legacy-mb-korean/euc-kr/euckr-encode-form-errors-han.html [ Slow ]
crbug.com/779965 external/wpt/beacon/headers/header-content-type.html [ Slow ]
# This page loads slow in real browser, and can timeout in SPv2 layout test.
crbug.com/779366 fast/shapes/crash-allocating-very-large-raster-shape.html [ Slow ]
......
......@@ -10,36 +10,30 @@
<script src="/common/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script>
var RESOURCES_DIR = "/beacon/resources/";
function pollResult(test, id) {
var checkUrl = RESOURCES_DIR + "content-type.py?cmd=get&id=" + id;
return new Promise(resolve => {
step_timeout(test.step_func(() => {
fetch(checkUrl).then(response => {
response.text().then(body => {
resolve(body);
});
});
}), 1000);
});
}
const RESOURCES_DIR = "/beacon/resources/";
function testContentTypeHeader(what, contentType, title) {
var testBase = RESOURCES_DIR;
var id = self.token();
var testUrl = testBase + "content-type.py?cmd=put&id=" + id;
promise_test(function(test) {
function wait(ms) {
return new Promise(resolve => step_timeout(resolve, ms));
}
promise_test(async t => {
const id = self.token();
const testUrl = new Request(RESOURCES_DIR + "content-type.py?cmd=put&id=" + id).url;
assert_true(navigator.sendBeacon(testUrl, what), "SendBeacon Succeeded");
return pollResult(test, id) .then(result => {
if (contentType == "multipart/form-data") {
assert_true(result.startsWith(contentType), "Correct Content-Type header result");
} else {
assert_equals(result, contentType, "Correct Content-Type header result");
}
});
assert_equals(performance.getEntriesByName(testUrl).length, 0);
do {
await wait(50);
} while (performance.getEntriesByName(testUrl).length === 0);
assert_equals(performance.getEntriesByName(testUrl).length, 1);
const checkUrl = RESOURCES_DIR + "content-type.py?cmd=get&id=" + id;
const response = await fetch(checkUrl);
const text = await response.text();
if (contentType === "multipart/form-data") {
assert_true(text.startsWith(contentType), "Correct Content-Type header result");
} else {
assert_equals(text, contentType, "Correct Content-Type header result");
}
}, "Test content-type header for a body " + title);
}
......
Markdown is supported
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