mirror of
https://github.com/servo/servo.git
synced 2025-09-14 17:08:22 +01:00
Update web-platform-tests to revision 3137d1d2d7757366a69f8a449b458b5057e0e81e
This commit is contained in:
parent
81ca858678
commit
d6ba94ca28
2339 changed files with 89274 additions and 9328 deletions
|
@ -0,0 +1,52 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Resource Timing cached resources</title>
|
||||
<link rel="author" title="Google" href="http://www.google.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
setup({explicit_done: true});
|
||||
|
||||
// explicitly test the namespace before we start testing
|
||||
test_namespace("getEntriesByType");
|
||||
|
||||
var d;
|
||||
var iframe;
|
||||
var iframeBody;
|
||||
var image;
|
||||
var random = Math.random();
|
||||
|
||||
function setup_iframe() {
|
||||
iframe = document.getElementById('frameContext');
|
||||
d = iframe.contentWindow.document;
|
||||
iframeBody = d.body;
|
||||
iframe.addEventListener('load', onload_test, false);
|
||||
}
|
||||
function onload_test() {
|
||||
if (window.performance.getEntriesByType === undefined) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
var context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
var entries = context.getEntriesByType('resource');
|
||||
test_equals(entries.length, 2, "There should be two entries");
|
||||
if (entries.length >= 2) {
|
||||
test_equals(entries[0].name, entries[1].name, "Both entries should have the same name");
|
||||
}
|
||||
done();
|
||||
}
|
||||
window.setup_iframe = setup_iframe;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that a 304 Not Modified resource appears in the buffer.</p>
|
||||
<div id="log"></div>
|
||||
<iframe id="frameContext" src="resources/fake_responses.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,57 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Resource Timing connection reuse</title>
|
||||
<link rel="author" title="Google" href="http://www.google.com/" />
|
||||
<link rel="help" href="https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
setup({explicit_done: true});
|
||||
var iframe;
|
||||
var d;
|
||||
var body;
|
||||
|
||||
// explicitly test the namespace before we start testing
|
||||
test_namespace("getEntriesByType");
|
||||
|
||||
function setup_iframe() {
|
||||
iframe = document.getElementById('frameContext');
|
||||
d = iframe.contentWindow.document;
|
||||
iframeBody = d.body;
|
||||
iframe.addEventListener('load', onload_test, false);
|
||||
}
|
||||
|
||||
function onload_test() {
|
||||
if (window.performance.getEntriesByType === undefined) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
var context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
var entries = context.getEntriesByType('resource');
|
||||
|
||||
// when a persistent connection is used, follow-on resources should be included as PerformanceResourceTiming objects
|
||||
test_equals(entries.length, 2, 'There should be 2 PerformanceEntries');
|
||||
|
||||
// when a persistent connection is used, for the resource that reuses the socket, connectStart and connectEnd should have the same value as fetchStart
|
||||
var entry = entries[1];
|
||||
test_equals(entry.fetchStart, entry.connectStart, "connectStart and fetchStart should be the same");
|
||||
|
||||
test_equals(entry.fetchStart, entry.connectEnd, "connectEnd and fetchStart should be the same");
|
||||
|
||||
done();
|
||||
}
|
||||
|
||||
window.setup_iframe = setup_iframe;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that connectStart and connectEnd are the same when a connection is reused (e.g. when a persistent connection is used).</p>
|
||||
<div id="log"></div>
|
||||
<iframe id="frameContext" src="resources/fake_responses.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,64 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Resource Timing initiator types with dynamic insertion</title>
|
||||
<link rel="author" title="Google" href="http://www.google.com/" />
|
||||
<link rel="help" href="https://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
// explicitly test the namespace before we start testing
|
||||
test_namespace("getEntriesByType");
|
||||
|
||||
|
||||
var iframe;
|
||||
function setup_iframe() {
|
||||
iframe = document.getElementById('frameContext');
|
||||
var d = iframe.contentWindow.document;
|
||||
var body = d.createElement('body');
|
||||
d.getElementsByTagName('html')[0].appendChild(body);
|
||||
|
||||
var style = d.createElement('link');
|
||||
style.rel = 'stylesheet';
|
||||
style.href = 'resource_timing_test0.css';
|
||||
body.appendChild(style);
|
||||
|
||||
var image = d.createElement('img');
|
||||
image.src = 'resource_timing_test0.png';
|
||||
body.appendChild(image);
|
||||
|
||||
var subframe = d.createElement('iframe');
|
||||
subframe.src = 'inject_resource_test.html';
|
||||
body.appendChild(subframe);
|
||||
}
|
||||
function onload_test() {
|
||||
if (window.performance.getEntriesByType === undefined) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
var context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
var entries = context.getEntriesByType('resource');
|
||||
|
||||
var index = window.location.pathname.lastIndexOf('/');
|
||||
var pathname = window.location.pathname.substring(0, index) + '/';
|
||||
|
||||
var expected_entries = { };
|
||||
expected_entries[ pathname + 'resources/resource_timing_test0.css' ] = 'link',
|
||||
expected_entries[ pathname + 'resources/resource_timing_test0.png' ] = 'img',
|
||||
expected_entries[ pathname + 'resources/inject_resource_test.html' ] = 'iframe',
|
||||
|
||||
test_resource_entries(entries, expected_entries);
|
||||
}
|
||||
window.setup_iframe = setup_iframe;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that initiator types are represented even when dynamically inserted.</p>
|
||||
<div id="log"></div>
|
||||
<iframe id="frameContext" onload="onload_test();" src="resources/inject_resource_test.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,19 @@
|
|||
<body>
|
||||
<script>
|
||||
function request(type) {
|
||||
var client = new XMLHttpRequest,
|
||||
identifier = type == "tag" ? Math.random() : new Date().toGMTString(),
|
||||
url = "fake_responses.py?" + type + "=" + identifier
|
||||
client.open("GET", url, false)
|
||||
client.send(null)
|
||||
client.open("GET", url, false)
|
||||
client.setRequestHeader(type == "tag" ? "If-None-Match" : "If-Modified-Since", identifier)
|
||||
client.send(null)
|
||||
}
|
||||
|
||||
if(window.parent.setup_iframe) {
|
||||
window.parent.setup_iframe();
|
||||
request("tag");
|
||||
}
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,19 @@
|
|||
# XMLHttpRequest/resources/conditional.py -- to fake a 304 response
|
||||
|
||||
def main(request, response):
|
||||
tag = request.GET.first("tag", None)
|
||||
match = request.headers.get("If-None-Match", None)
|
||||
date = request.GET.first("date", "")
|
||||
modified = request.headers.get("If-Modified-Since", None)
|
||||
if tag:
|
||||
response.headers.set("ETag", '"%s"' % tag)
|
||||
elif date:
|
||||
response.headers.set("Last-Modified", date)
|
||||
|
||||
if ((match is not None and match == tag) or
|
||||
(modified is not None and modified == date)):
|
||||
response.status = (304, "SUPERCOOL")
|
||||
return ""
|
||||
else:
|
||||
response.headers.set("Content-Type", "text/plain")
|
||||
return "MAYBE NOT"
|
|
@ -0,0 +1,7 @@
|
|||
<body>
|
||||
<script>
|
||||
if(window.parent.setup_iframe) {
|
||||
window.parent.setup_iframe();
|
||||
}
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,198 @@
|
|||
/*
|
||||
Distributed under both the W3C Test Suite License [1] and the W3C
|
||||
3-clause BSD License [2]. To contribute to a W3C Test Suite, see the
|
||||
policies and contribution forms [3].
|
||||
|
||||
[1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
|
||||
[2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
|
||||
[3] http://www.w3.org/2004/10/27-testcases
|
||||
*/
|
||||
|
||||
var mark_names = [
|
||||
'',
|
||||
'1',
|
||||
'abc',
|
||||
];
|
||||
|
||||
var measures = [
|
||||
[''],
|
||||
['2', 1],
|
||||
['aaa', 'navigationStart', ''],
|
||||
];
|
||||
|
||||
function test_method_exists(method, method_name, properties)
|
||||
{
|
||||
var msg;
|
||||
if (typeof method === 'function')
|
||||
msg = 'performance.' + method.name + ' is supported!';
|
||||
else
|
||||
msg = 'performance.' + method_name + ' is supported!';
|
||||
wp_test(function() { assert_true(typeof method === 'function', msg); }, msg, properties);
|
||||
}
|
||||
|
||||
function test_method_throw_exception(func_str, exception, msg)
|
||||
{
|
||||
var exception_name = typeof exception === "object" ? exception.name : exception;
|
||||
var msg = 'Invocation of ' + func_str + ' should throw ' + exception_name + ' Exception.';
|
||||
wp_test(function() { assert_throws(exception, function() {eval(func_str)}, msg); }, msg);
|
||||
}
|
||||
|
||||
function test_noless_than(value, greater_than, msg, properties)
|
||||
{
|
||||
wp_test(function () { assert_true(value >= greater_than, msg); }, msg, properties);
|
||||
}
|
||||
|
||||
function test_fail(msg, properties)
|
||||
{
|
||||
wp_test(function() { assert_unreached(); }, msg, properties);
|
||||
}
|
||||
|
||||
function test_resource_entries(entries, expected_entries)
|
||||
{
|
||||
// This is slightly convoluted so that we can sort the output.
|
||||
var actual_entries = {};
|
||||
var origin = window.location.protocol + "//" + window.location.host;
|
||||
|
||||
for (var i = 0; i < entries.length; ++i) {
|
||||
var entry = entries[i];
|
||||
var found = false;
|
||||
for (var expected_entry in expected_entries) {
|
||||
if (entry.name == origin + expected_entry) {
|
||||
found = true;
|
||||
if (expected_entry in actual_entries) {
|
||||
test_fail(expected_entry + ' is not expected to have duplicate entries');
|
||||
}
|
||||
actual_entries[expected_entry] = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
test_fail(entries[i].name + ' is not expected to be in the Resource Timing buffer');
|
||||
}
|
||||
}
|
||||
|
||||
sorted_urls = [];
|
||||
for (var i in actual_entries) {
|
||||
sorted_urls.push(i);
|
||||
}
|
||||
sorted_urls.sort();
|
||||
for (var i in sorted_urls) {
|
||||
var url = sorted_urls[i];
|
||||
test_equals(actual_entries[url].initiatorType,
|
||||
expected_entries[url],
|
||||
origin + url + ' is expected to have initiatorType ' + expected_entries[url]);
|
||||
}
|
||||
for (var j in expected_entries) {
|
||||
if (!(j in actual_entries)) {
|
||||
test_fail(origin + j + ' is expected to be in the Resource Timing buffer');
|
||||
}
|
||||
}
|
||||
}
|
||||
function performance_entrylist_checker(type)
|
||||
{
|
||||
var entryType = type;
|
||||
|
||||
function entry_check(entry, expectedNames)
|
||||
{
|
||||
var msg = 'Entry \"' + entry.name + '\" should be one that we have set.';
|
||||
wp_test(function() { assert_in_array(entry.name, expectedNames, msg); }, msg);
|
||||
test_equals(entry.entryType, entryType, 'entryType should be \"' + entryType + '\".');
|
||||
if (type === "measure") {
|
||||
test_true(isFinite(entry.startTime), 'startTime should be a number.');
|
||||
test_true(isFinite(entry.duration), 'duration should be a number.');
|
||||
} else if (type === "mark") {
|
||||
test_greater_than(entry.startTime, 0, 'startTime should greater than 0.');
|
||||
test_equals(entry.duration, 0, 'duration of mark should be 0.');
|
||||
}
|
||||
}
|
||||
|
||||
function entrylist_order_check(entryList)
|
||||
{
|
||||
var inOrder = true;
|
||||
for (var i = 0; i < entryList.length - 1; ++i)
|
||||
{
|
||||
if (entryList[i + 1].startTime < entryList[i].startTime) {
|
||||
inOrder = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return inOrder;
|
||||
}
|
||||
|
||||
function entrylist_check(entryList, expectedLength, expectedNames)
|
||||
{
|
||||
test_equals(entryList.length, expectedLength, 'There should be ' + expectedLength + ' entries.');
|
||||
test_true(entrylist_order_check(entryList), 'Entries in entrylist should be in order.');
|
||||
for (var i = 0; i < entryList.length; ++i)
|
||||
{
|
||||
entry_check(entryList[i], expectedNames);
|
||||
}
|
||||
}
|
||||
|
||||
return{"entrylist_check":entrylist_check};
|
||||
}
|
||||
|
||||
function PerformanceContext(context)
|
||||
{
|
||||
this.performanceContext = context;
|
||||
}
|
||||
|
||||
PerformanceContext.prototype = {
|
||||
initialMeasures: function(item, index, array)
|
||||
{
|
||||
this.performanceContext.measure.apply(this.performanceContext, item);
|
||||
},
|
||||
|
||||
mark: function()
|
||||
{
|
||||
this.performanceContext.mark.apply(this.performanceContext, arguments);
|
||||
},
|
||||
|
||||
measure: function()
|
||||
{
|
||||
this.performanceContext.measure.apply(this.performanceContext, arguments);
|
||||
},
|
||||
|
||||
clearMarks: function()
|
||||
{
|
||||
this.performanceContext.clearMarks.apply(this.performanceContext, arguments);
|
||||
|
||||
},
|
||||
|
||||
clearMeasures: function()
|
||||
{
|
||||
this.performanceContext.clearMeasures.apply(this.performanceContext, arguments);
|
||||
|
||||
},
|
||||
|
||||
getEntries: function()
|
||||
{
|
||||
return this.performanceContext.getEntries.apply(this.performanceContext, arguments);
|
||||
},
|
||||
|
||||
getEntriesByType: function()
|
||||
{
|
||||
return this.performanceContext.getEntriesByType.apply(this.performanceContext, arguments);
|
||||
},
|
||||
|
||||
getEntriesByName: function()
|
||||
{
|
||||
return this.performanceContext.getEntriesByName.apply(this.performanceContext, arguments);
|
||||
},
|
||||
|
||||
setResourceTimingBufferSize: function()
|
||||
{
|
||||
return this.performanceContext.setResourceTimingBufferSize.apply(this.performanceContext, arguments);
|
||||
},
|
||||
|
||||
registerResourceTimingBufferFullCallback: function(func)
|
||||
{
|
||||
this.performanceContext.onresourcetimingbufferfull = func;
|
||||
},
|
||||
|
||||
clearResourceTimings: function()
|
||||
{
|
||||
this.performanceContext.clearResourceTimings.apply(this.performanceContext, arguments);
|
||||
}
|
||||
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue