Commit ae1255b2 authored by Takashi Toyoshima's avatar Takashi Toyoshima Committed by Commit Bot

Fix link-rel-prefetch.html not to depend on server logs

misc/link-rel-prefetch.html and css/mask-image-loading.html
use the same server logging infra, network-simulator.php,
and the access logs for them are sometime mixed and randomly
failed due to that.

This patch updates link-rel-prefetch.html not to depend on
the server logs as we can verify the behavior via client
side callbacks.

Bug: 1140244, 1140251
Change-Id: I092e092c7c9310b815b09419a206b1517ebd21f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521975
Commit-Queue: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825260}
parent b4af68b7
CONSOLE WARNING: line 5: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
CONSOLE WARNING: line 8: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
Resource requests:
border2.jpg
CONSOLE WARNING: line 5: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
CONSOLE WARNING: line 8: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
item
Resource requests:
......
CONSOLE WARNING: line 5: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
CONSOLE WARNING: line 8: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
Resource requests:
mask2.jpg
CONSOLE WARNING: line 5: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
CONSOLE WARNING: line 8: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
Resource requests:
mask2.jpg
// Do not use for new tests as this logging functionalities are not maintained,
// and are not safe to run tests in parallel. Accesses for other tests may be
// merged, or other commands may trim the log.
function CallCommand(cmd)
{
try {
......@@ -16,7 +19,7 @@ function startTest()
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
window.setTimeout(endTest, 0);
}
......
CONSOLE WARNING: line 8: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
Resource requests:
1st.jpg
2nd.jpg
3rd.jpg
<html>
<head>
<script>
function CallCommand(cmd)
{
try {
var req = new XMLHttpRequest;
req.open("GET", "/resources/network-simulator.php?command=" + cmd, false);
req.send(null);
return req.responseText;
} catch (ex) {
return "";
}
}
function startTest()
{
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
window.addEventListener('load', e => {
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
}, false);
var linkLoadCount = 3;
function decrementLinkLoadCount()
{
linkLoadCount--;
if (linkLoadCount == 0 && window.testRunner)
window.testRunner.notifyDone();
}
}
function endTest()
{
getResourceLog();
CallCommand("clear-resource-request-log");
if (window.testRunner)
testRunner.notifyDone();
}
function getResourceLog()
{
var log = CallCommand("get-resource-request-log");
var logLines = log.split('\n');
logLines.sort();
document.getElementById('result').innerText = logLines.join('\n');
}
CallCommand("start-resource-request-log");
window.addEventListener('load', startTest, false);
</script>
<script>
var linkLoadCount = 3;
function decrementLinkLoadCount()
{
linkLoadCount--;
if (linkLoadCount == 0) {
endTest();
}
}
</script>
<link rel=prefetch onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?command=log-resource-request&path=1st.jpg">
<link rel=prefetch onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?command=log-resource-request&path=2nd.jpg">
<link rel=prefetch onload="decrementLinkLoadCount()" href="/resources/network-simulator.php?command=log-resource-request&path=3rd.jpg">
<link rel=prefetch onload="decrementLinkLoadCount()" href="/resources/square100.png">
<link rel=prefetch onload="decrementLinkLoadCount()" href="/resources/square200.png">
<link rel=prefetch onload="decrementLinkLoadCount()" href="/resources/square20.png">
</head>
<body>
<div class="box bordered"></div>
<h2>Resource requests:</h2>
<pre id="result">Request log goes here in DRT</pre>
</body>
</html>
......@@ -79,7 +79,7 @@ function generateResponse($path)
if (file_exists($path)) {
header("Last-Modified: " . gmdate("D, d M Y H:i:s T", filemtime($path)));
header("Content-Type: " . contentType($path));
print file_get_contents($path);
} else {
header('HTTP/1.1 404 Not Found');
......@@ -124,6 +124,9 @@ function handleGetResourceCountCommand($path)
}
}
# Do not use for new tests as this logging functionalities are not maintained,
# and are not safe to run tests in parallel. Accesses for other tests may be
# merged, or other commands may trim the log.
function handleStartResourceRequestsLog()
{
$resourceLogFile = sys_get_temp_dir() . "/resource-log";
......@@ -149,7 +152,7 @@ function handleGetResourceRequestsLog()
function handleLogResourceRequest($path)
{
$resourceLogFile = sys_get_temp_dir() . "/resource-log";
$newData = "\n".$path;
file_put_contents($resourceLogFile, $newData, FILE_APPEND | LOCK_EX);
}
......
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