mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255
This commit is contained in:
parent
b2a5225831
commit
1a81b18b9f
12321 changed files with 544385 additions and 6 deletions
|
@ -0,0 +1,4 @@
|
|||
div#resource_link_css
|
||||
{
|
||||
color:hotpink;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
Child Frame
|
||||
</title>
|
||||
</head>
|
||||
<body style="background-color: #C0C0C0">
|
||||
|
||||
<h1>
|
||||
Child Document
|
||||
</h1>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,3 @@
|
|||
// This is a test script for purposes of testing the
|
||||
// script initiator type in the Resource Timing feature
|
||||
var testDummyValue = 0;
|
Binary file not shown.
After Width: | Height: | Size: 249 B |
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<TESTDATA>
|
||||
<ITEM>
|
||||
<DATA>Test XML Data</DATA>
|
||||
</ITEM>
|
||||
</TESTDATA>
|
|
@ -0,0 +1,145 @@
|
|||
//
|
||||
// Helper Functions for NavigationTiming W3C tests
|
||||
//
|
||||
|
||||
var performanceNamespace = window.performance;
|
||||
var timingAttributes = [
|
||||
'connectEnd',
|
||||
'connectStart',
|
||||
'domComplete',
|
||||
'domContentLoadedEventEnd',
|
||||
'domContentLoadedEventStart',
|
||||
'domInteractive',
|
||||
'domLoading',
|
||||
'domainLookupEnd',
|
||||
'domainLookupStart',
|
||||
'fetchStart',
|
||||
'loadEventEnd',
|
||||
'loadEventStart',
|
||||
'navigationStart',
|
||||
'redirectEnd',
|
||||
'redirectStart',
|
||||
'requestStart',
|
||||
'responseEnd',
|
||||
'responseStart',
|
||||
'unloadEventEnd',
|
||||
'unloadEventStart'
|
||||
];
|
||||
|
||||
var namespace_check = false;
|
||||
|
||||
//
|
||||
// All test() functions in the WebPerf test suite should use wp_test() instead.
|
||||
//
|
||||
// wp_test() validates the window.performance namespace exists prior to running tests and
|
||||
// immediately shows a single failure if it does not.
|
||||
//
|
||||
|
||||
function wp_test(func, msg, properties)
|
||||
{
|
||||
// only run the namespace check once
|
||||
if (!namespace_check)
|
||||
{
|
||||
namespace_check = true;
|
||||
|
||||
if (performanceNamespace === undefined || performanceNamespace == null)
|
||||
{
|
||||
// show a single error that window.performance is undefined
|
||||
test(function() { assert_true(performanceNamespace !== undefined && performanceNamespace != null, "window.performance is defined and not null"); }, "window.performance is defined and not null.", {author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "});
|
||||
}
|
||||
}
|
||||
|
||||
test(func, msg, properties);
|
||||
}
|
||||
|
||||
function test_namespace(child_name, skip_root)
|
||||
{
|
||||
if (skip_root === undefined) {
|
||||
var msg = 'window.performance is defined';
|
||||
wp_test(function () { assert_true(performanceNamespace !== undefined, msg); }, msg,{author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "});
|
||||
}
|
||||
|
||||
if (child_name !== undefined) {
|
||||
var msg2 = 'window.performance.' + child_name + ' is defined';
|
||||
wp_test(function() { assert_true(performanceNamespace[child_name] !== undefined, msg2); }, msg2,{author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "});
|
||||
}
|
||||
}
|
||||
|
||||
function test_attribute_exists(parent_name, attribute_name, properties)
|
||||
{
|
||||
var msg = 'window.performance.' + parent_name + '.' + attribute_name + ' is defined.';
|
||||
wp_test(function() { assert_true(performanceNamespace[parent_name][attribute_name] !== undefined, msg); }, msg, properties);
|
||||
}
|
||||
|
||||
function test_enum(parent_name, enum_name, value, properties)
|
||||
{
|
||||
var msg = 'window.performance.' + parent_name + '.' + enum_name + ' is defined.';
|
||||
wp_test(function() { assert_true(performanceNamespace[parent_name][enum_name] !== undefined, msg); }, msg, properties);
|
||||
|
||||
msg = 'window.performance.' + parent_name + '.' + enum_name + ' = ' + value;
|
||||
wp_test(function() { assert_equals(performanceNamespace[parent_name][enum_name], value, msg); }, msg, properties);
|
||||
}
|
||||
|
||||
function test_timing_order(attribute_name, greater_than_attribute, properties)
|
||||
{
|
||||
// ensure it's not 0 first
|
||||
var msg = "window.performance.timing." + attribute_name + " > 0";
|
||||
wp_test(function() { assert_true(performanceNamespace.timing[attribute_name] > 0, msg); }, msg, properties);
|
||||
|
||||
// ensure it's in the right order
|
||||
msg = "window.performance.timing." + attribute_name + " >= window.performance.timing." + greater_than_attribute;
|
||||
wp_test(function() { assert_true(performanceNamespace.timing[attribute_name] >= performanceNamespace.timing[greater_than_attribute], msg); }, msg, properties);
|
||||
}
|
||||
|
||||
function test_timing_greater_than(attribute_name, greater_than, properties)
|
||||
{
|
||||
var msg = "window.performance.timing." + attribute_name + " > " + greater_than;
|
||||
test_greater_than(performanceNamespace.timing[attribute_name], greater_than, msg, properties);
|
||||
}
|
||||
|
||||
function test_timing_equals(attribute_name, equals, msg, properties)
|
||||
{
|
||||
var test_msg = msg || "window.performance.timing." + attribute_name + " == " + equals;
|
||||
test_equals(performanceNamespace.timing[attribute_name], equals, test_msg, properties);
|
||||
}
|
||||
|
||||
//
|
||||
// Non-test related helper functions
|
||||
//
|
||||
|
||||
function sleep_milliseconds(n)
|
||||
{
|
||||
var start = new Date().getTime();
|
||||
while (true) {
|
||||
if ((new Date().getTime() - start) >= n) break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Common helper functions
|
||||
//
|
||||
|
||||
function test_true(value, msg, properties)
|
||||
{
|
||||
wp_test(function () { assert_true(value, msg); }, msg, properties);
|
||||
}
|
||||
|
||||
function test_equals(value, equals, msg, properties)
|
||||
{
|
||||
wp_test(function () { assert_equals(value, equals, msg); }, msg, properties);
|
||||
}
|
||||
|
||||
function test_greater_than(value, greater_than, msg, properties)
|
||||
{
|
||||
wp_test(function () { assert_true(value > greater_than, msg); }, msg, properties);
|
||||
}
|
||||
|
||||
function test_greater_or_equals(value, greater_than, msg, properties)
|
||||
{
|
||||
wp_test(function () { assert_true(value >= greater_than, msg); }, msg, properties);
|
||||
}
|
||||
|
||||
function test_not_equals(value, notequals, msg, properties)
|
||||
{
|
||||
wp_test(function() { assert_true(value !== notequals, msg); }, msg, properties);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>window.performance Resource Timing Entries exist</title>
|
||||
<link rel="author" title="Microsoft" href="http://www.microsoft.com/" />
|
||||
<link rel="help" href="https://w3c.github.io/web-performance/specs/ResourceTiming/Overview.html"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="test_resource_timing.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>
|
||||
NOTE: Due to caching behavior in the browser, it is possible that when revisiting this page, some resources
|
||||
may not have to be fetched from the network. As a result, the performance timeline will not contain entries
|
||||
for these resources. This test will fail if any entries are missing to ensure that all resources are fetched
|
||||
from the network and entries for these resources exist in the Performance Timeline. If revisiting this page,
|
||||
please either perform a full reload of the page or clear the cache between visits.
|
||||
</p>
|
||||
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,182 @@
|
|||
var TEST_ALLOWED_TIMING_DELTA = 20;
|
||||
|
||||
var waitTimer;
|
||||
var expectedEntries = {};
|
||||
|
||||
var initiatorTypes = ["iframe", "img", "link", "script", "xmlhttprequest"];
|
||||
|
||||
var tests = {};
|
||||
setup(function() {
|
||||
for (var i in initiatorTypes) {
|
||||
var type = initiatorTypes[i];
|
||||
tests[type] = {
|
||||
"entry": async_test("window.performance.getEntriesByName() and window.performance.getEntriesByNameType() return same data (" + type + ")"),
|
||||
"simple_attrs": async_test("PerformanceEntry has correct name, initiatorType, startTime, and duration (" + type + ")"),
|
||||
"timing_attrs": async_test("PerformanceEntry has correct order of timing attributes (" + type + ")")
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
function resolve(path) {
|
||||
var a = document.createElement("a");
|
||||
a.href = path;
|
||||
return a.href;
|
||||
}
|
||||
|
||||
onload = function()
|
||||
{
|
||||
// check that the Performance Timeline API exists
|
||||
test(function() {
|
||||
assert_idl_attribute(window.performance, "getEntriesByName",
|
||||
"window.performance.getEntriesByName() is defined");
|
||||
});
|
||||
test(function() {
|
||||
assert_idl_attribute(window.performance, "getEntriesByType",
|
||||
"window.performance.getEntriesByType() is defined");
|
||||
});
|
||||
test(function() {
|
||||
assert_idl_attribute(window.performance, "getEntries",
|
||||
"window.performance.getEntries() is defined");
|
||||
});
|
||||
|
||||
var expected_entry;
|
||||
var url;
|
||||
var type;
|
||||
var startTime;
|
||||
var element;
|
||||
for (var i in initiatorTypes) {
|
||||
startTime = window.performance.now();
|
||||
type = initiatorTypes[i];
|
||||
if (type != "xmlhttprequest") {
|
||||
element = document.createElement(type);
|
||||
} else {
|
||||
element = null;
|
||||
}
|
||||
switch (type) {
|
||||
case "iframe":
|
||||
url = resolve("resources/resource_timing_test0.html");
|
||||
element.src = url;
|
||||
break;
|
||||
case "img":
|
||||
url = resolve("resources/resource_timing_test0.png");
|
||||
element.src = url;
|
||||
break;
|
||||
case "link":
|
||||
element.rel = "stylesheet";
|
||||
url = resolve("resources/resource_timing_test0.css");
|
||||
element.href = url;
|
||||
break;
|
||||
case "script":
|
||||
element.type = "text/javascript";
|
||||
url = resolve("resources/resource_timing_test0.js");
|
||||
element.src = url;
|
||||
break;
|
||||
case "xmlhttprequest":
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
url = resolve("resources/resource_timing_test0.xml");
|
||||
xmlhttp.open('GET', url, true);
|
||||
xmlhttp.send();
|
||||
break;
|
||||
}
|
||||
|
||||
expected_entry = {name:url,
|
||||
startTime: startTime,
|
||||
initiatorType: type};
|
||||
|
||||
switch (type) {
|
||||
case "link":
|
||||
poll_for_stylesheet_load(expected_entry);
|
||||
document.body.appendChild(element);
|
||||
break;
|
||||
case "xmlhttprequest":
|
||||
xmlhttp.onload = (function(entry) {
|
||||
return function (event) {
|
||||
resource_load(entry);
|
||||
};
|
||||
})(expected_entry);
|
||||
break;
|
||||
default:
|
||||
element.onload = (function(entry) {
|
||||
return function (event) {
|
||||
resource_load(entry);
|
||||
};
|
||||
})(expected_entry);
|
||||
document.body.appendChild(element);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function poll_for_stylesheet_load(expected_entry) {
|
||||
function inner() {
|
||||
for(var i=0; i<document.styleSheets.length; i++) {
|
||||
var sheet = document.styleSheets[i];
|
||||
if (sheet.href === expected_entry.name) {
|
||||
try {
|
||||
// try/catch avoids throwing if sheet object exists before it is loaded,
|
||||
// which is a bug, but not what we are trying to test here.
|
||||
var hasRules = sheet.cssRules.length > 0;
|
||||
} catch(e) {
|
||||
hasRules = false;
|
||||
}
|
||||
if (hasRules) {
|
||||
setTimeout(function() {
|
||||
resource_load(expected_entry);
|
||||
}, 200);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
setTimeout(inner, 100);
|
||||
}
|
||||
inner();
|
||||
}
|
||||
|
||||
function resource_load(expected)
|
||||
{
|
||||
var t = tests[expected.initiatorType];
|
||||
|
||||
t["entry"].step(function() {
|
||||
var entries_by_name = window.performance.getEntriesByName(expected.name);
|
||||
assert_equals(entries_by_name.length, 1, "should have a single entry for each resource (without type)");
|
||||
var entries_by_name_type = window.performance.getEntriesByName(expected.name, "resource");
|
||||
assert_equals(entries_by_name_type.length, 1, "should have a single entry for each resource (with type)");
|
||||
assert_not_equals(entries_by_name, entries_by_name_type, "values should be copies");
|
||||
for (p in entries_by_name[0]) {
|
||||
assert_equals(entries_by_name[0][p], entries_by_name_type[0][p], "Property " + p + " should match");
|
||||
}
|
||||
this.done();
|
||||
});
|
||||
|
||||
t["simple_attrs"].step(function() {
|
||||
var actual = window.performance.getEntriesByName(expected.name)[0];
|
||||
var expected_type = expected.initiatorType;
|
||||
if (expected.initiatorType == "iframe") {
|
||||
expected_type = "subdocument";
|
||||
}
|
||||
assert_equals(actual.name, expected.name);
|
||||
assert_equals(actual.initiatorType, expected_type);
|
||||
assert_equals(actual.entryType, "resource");
|
||||
assert_greater_than_equal(actual.startTime, expected.startTime, "startTime is after the script to initiate the load ran");
|
||||
assert_equals(actual.duration, (actual.responseEnd - actual.startTime));
|
||||
this.done();
|
||||
});
|
||||
|
||||
t["timing_attrs"].step(function test() {
|
||||
var actual = window.performance.getEntriesByName(expected.name)[0];
|
||||
assert_equals(actual.redirectStart, 0, "redirectStart time");
|
||||
assert_equals(actual.redirectEnd, 0, "redirectEnd time");
|
||||
assert_true(actual.secureConnectionStart == undefined ||
|
||||
actual.secureConnectionStart == 0, "secureConnectionStart time");
|
||||
assert_equals(actual.fetchStart, actual.startTime, "fetchStart is equal to startTime");
|
||||
assert_greater_than_equal(actual.domainLookupStart, actual.fetchStart, "domainLookupStart after fetchStart");
|
||||
assert_greater_than_equal(actual.domainLookupEnd, actual.domainLookupStart, "domainLookupEnd after domainLookupStart");
|
||||
assert_greater_than_equal(actual.connectStart, actual.domainLookupEnd, "connectStart after domainLookupEnd");
|
||||
assert_greater_than_equal(actual.connectEnd, actual.connectStart, "connectEnd after connectStart");
|
||||
assert_greater_than_equal(actual.requestStart, actual.connectEnd, "requestStart after connectEnd");
|
||||
assert_greater_than_equal(actual.responseStart, actual.requestStart, "responseStart after requestStart");
|
||||
assert_greater_than_equal(actual.responseEnd, actual.responseStart, "responseEnd after responseStart");
|
||||
this.done();
|
||||
});
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue