mirror of
https://github.com/servo/servo.git
synced 2025-09-03 11:38:22 +01:00
Update web-platform-tests to revision fab2c513bffb2bd19600d23b495264d123df092f
This commit is contained in:
parent
c226bf85a9
commit
ebddcc2d7f
441 changed files with 3689 additions and 1521 deletions
|
@ -0,0 +1,21 @@
|
|||
// Compares a performance entry to a predefined one
|
||||
// perfEntriesToCheck is an array of performance entries from the user agent
|
||||
// expectedEntries is an array of performance entries minted by the test
|
||||
function checkEntries(perfEntriesToCheck, expectedEntries) {
|
||||
function findMatch(pe) {
|
||||
// we match based on entryType and name
|
||||
for (var i = expectedEntries.length - 1; i >= 0; i--) {
|
||||
var ex = expectedEntries[i];
|
||||
if (ex.entryType === pe.entryType && ex.name === pe.name) {
|
||||
return ex;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
assert_equals(perfEntriesToCheck.length, expectedEntries.length, "performance entries must match");
|
||||
|
||||
perfEntriesToCheck.forEach(function (pe1) {
|
||||
assert_not_equals(findMatch(pe1), null, "Entry matches");
|
||||
});
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>PerformanceObservers: disconnect</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<h1>PerformanceObservers: disconnect</h1>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(function (t) {
|
||||
var observer = new PerformanceObserver(
|
||||
t.step_func(function (entryList, obs) {
|
||||
assert_unreached("This callback must not be invoked");
|
||||
})
|
||||
);
|
||||
observer.observe({entryTypes: ["mark", "measure", "navigation"]});
|
||||
observer.disconnect();
|
||||
performance.mark("mark1");
|
||||
performance.measure("measure1");
|
||||
t.step_timeout(function () {
|
||||
t.done();
|
||||
}, 2000);
|
||||
}, "disconnected callbacks must not be invoked");
|
||||
|
||||
test(function () {
|
||||
var obs = new PerformanceObserver(function () { return true; });
|
||||
obs.disconnect();
|
||||
obs.disconnect();
|
||||
}, "disconnecting an unconnected observer is a no-op");
|
||||
|
||||
async_test(function (t) {
|
||||
var observer = new PerformanceObserver(
|
||||
t.step_func(function(entryList, obs) {
|
||||
checkEntries(entryList.getEntries(),
|
||||
[{ entryType: "mark", name: "mark1"}]);
|
||||
t.done();
|
||||
})
|
||||
);
|
||||
observer.observe({entryTypes: ["mark"]});
|
||||
performance.mark("mark1");
|
||||
observer.disconnect();
|
||||
performance.mark("mark2");
|
||||
}, "An observer disconnected after a mark must receive the mark");
|
||||
</script>
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>PerformanceObservers: getEntries*</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="performanceobservers.js"></script>
|
||||
<h1>PerformanceObservers: getEntries*</h1>
|
||||
<p>
|
||||
getEntries, getEntriesByType and getEntriesByName work
|
||||
</p>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(function (t) {
|
||||
var observer = new PerformanceObserver(
|
||||
t.step_func(function (entryList, obs) {
|
||||
checkEntries(entryList.getEntries(),
|
||||
[{ entryType: "mark", name: "mark1"}], "getEntries");
|
||||
|
||||
checkEntries(entryList.getEntriesByType("mark"),
|
||||
[{ entryType: "mark", name: "mark1"}], "getEntriesByType");
|
||||
assert_equals(entryList.getEntriesByType("measure").length, 0,
|
||||
"getEntriesByType with no expected entry");
|
||||
assert_equals(entryList.getEntriesByType("234567").length, 0,
|
||||
"getEntriesByType with no expected entry");
|
||||
|
||||
checkEntries(entryList.getEntriesByName("mark1"),
|
||||
[{ entryType: "mark", name: "mark1"}], "getEntriesByName");
|
||||
assert_equals(entryList.getEntriesByName("mark2").length, 0,
|
||||
"getEntriesByName with no expected entry");
|
||||
assert_equals(entryList.getEntriesByName("234567").length, 0,
|
||||
"getEntriesByName with no expected entry");
|
||||
|
||||
checkEntries(entryList.getEntriesByName("mark1", "mark"),
|
||||
[{ entryType: "mark", name: "mark1"}], "getEntriesByName with a type");
|
||||
assert_equals(entryList.getEntriesByName("mark1", "measure").length, 0,
|
||||
"getEntriesByName with a type with no expected entry");
|
||||
assert_equals(entryList.getEntriesByName("mark2", "measure").length, 0,
|
||||
"getEntriesByName with a type with no expected entry");
|
||||
assert_equals(entryList.getEntriesByName("mark1", "234567").length, 0,
|
||||
"getEntriesByName with a type with no expected entry");
|
||||
|
||||
observer.disconnect();
|
||||
t.done();
|
||||
})
|
||||
);
|
||||
observer.observe({entryTypes: ["mark"]});
|
||||
performance.mark("mark1");
|
||||
}, "getEntries, getEntriesByType and getEntriesByName work");
|
||||
|
||||
</script>
|
|
@ -0,0 +1,72 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>PerformanceObservers: mark and measure</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="performanceobservers.js"></script>
|
||||
<h1>PerformanceObservers: mark and measure</h1>
|
||||
<p>
|
||||
Performance.mark() and Performance.measure() will <a href="https://w3c.github.io/performance-timeline/#dfn-queue-a-performanceentry">queue a PerformanceEntry</a>.
|
||||
</p>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(function (t) {
|
||||
var stored_entries = [];
|
||||
var observer = new PerformanceObserver(
|
||||
t.step_func(function (entryList, obs) {
|
||||
stored_entries =
|
||||
stored_entries.concat(entryList.getEntries());
|
||||
if (stored_entries.length >= 4) {
|
||||
checkEntries(stored_entries,
|
||||
[{ entryType: "mark", name: "mark1"},
|
||||
{ entryType: "mark", name: "mark2"},
|
||||
{ entryType: "measure", name: "measure1"},
|
||||
{ entryType: "measure", name: "measure2"}]);
|
||||
observer.disconnect();
|
||||
t.done();
|
||||
}
|
||||
})
|
||||
);
|
||||
observer.observe({entryTypes: ["mark", "measure"]});
|
||||
}, "entries are observable");
|
||||
|
||||
async_test(function (t) {
|
||||
var mark_entries = [];
|
||||
var observer = new PerformanceObserver(
|
||||
t.step_func(function (entryList, obs) {
|
||||
mark_entries =
|
||||
mark_entries.concat(entryList.getEntries());
|
||||
if (mark_entries.length >= 2) {
|
||||
checkEntries(mark_entries,
|
||||
[{ entryType: "mark", name: "mark1"},
|
||||
{ entryType: "mark", name: "mark2"}]);
|
||||
observer.disconnect();
|
||||
t.done();
|
||||
}
|
||||
})
|
||||
);
|
||||
observer.observe({entryTypes: ["mark"]});
|
||||
performance.mark("mark1");
|
||||
performance.mark("mark2");
|
||||
}, "mark entries are observable");
|
||||
|
||||
async_test(function (t) {
|
||||
var measure_entries = [];
|
||||
var observer = new PerformanceObserver(
|
||||
t.step_func(function (entryList, obs) {
|
||||
measure_entries =
|
||||
measure_entries.concat(entryList.getEntries());
|
||||
if (measure_entries.length >= 2) {
|
||||
checkEntries(measure_entries,
|
||||
[{ entryType: "measure", name: "measure1"},
|
||||
{ entryType: "measure", name: "measure2"}]);
|
||||
observer.disconnect();
|
||||
t.done();
|
||||
}
|
||||
})
|
||||
);
|
||||
observer.observe({entryTypes: ["measure"]});
|
||||
performance.measure("measure1");
|
||||
performance.measure("measure2");
|
||||
}, "measure entries are observable");
|
||||
</script>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>PerformanceObservers: navigation</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="performanceobservers.js"></script>
|
||||
<h1>PerformanceObservers: navigation</h1>
|
||||
<p>
|
||||
Navigation will <a href="https://w3c.github.io/performance-timeline/#dfn-queue-a-performanceentry">queue a PerformanceEntry</a>.
|
||||
</p>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(function (t) {
|
||||
var observer = new PerformanceObserver(
|
||||
t.step_func(function (entryList, obs) {
|
||||
checkEntries(entryList.getEntries(),
|
||||
[{ entryType: "navigation", name: "document"}]);
|
||||
checkEntries(entryList.getEntriesByType("navigation"),
|
||||
[{ entryType: "navigation", name: "document"}]);
|
||||
checkEntries(entryList.getEntriesByName("document"),
|
||||
[{ entryType: "navigation", name: "document"}]);
|
||||
observer.disconnect();
|
||||
t.done();
|
||||
})
|
||||
);
|
||||
observer.observe({entryTypes: ["navigation"]});
|
||||
}, "navigation entry is observable");
|
||||
</script>
|
|
@ -0,0 +1,58 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>PerformanceObservers: observe</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="performanceobservers.js"></script>
|
||||
<h1>PerformanceObservers: observe</h1>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function () {
|
||||
var obs = new PerformanceObserver(function () { return true; });
|
||||
assert_throws(new TypeError(), function () {
|
||||
obs.observe({});
|
||||
});
|
||||
assert_throws(new TypeError(), function () {
|
||||
obs.observe({entryType: []});
|
||||
});
|
||||
}, "no entryTypes throws a TypeError");
|
||||
test(function () {
|
||||
var obs = new PerformanceObserver(function () { return true; });
|
||||
assert_throws(new TypeError(), function () {
|
||||
obs.observe({entryTypes: "mark"});
|
||||
});
|
||||
assert_throws(new TypeError(), function () {
|
||||
obs.observe({entryTypes: []});
|
||||
});
|
||||
assert_throws(new TypeError(), function () {
|
||||
obs.observe({entryTypes: ["this-cannot-match-an-entryType"]});
|
||||
});
|
||||
assert_throws(new TypeError(), function () {
|
||||
obs.observe({entryTypes: ["marks","navigate", "resources"]});
|
||||
});
|
||||
}, "Empty sequence entryTypes throws a TypeError");
|
||||
|
||||
test(function () {
|
||||
var obs = new PerformanceObserver(function () { return true; });
|
||||
obs.observe({entryTypes: ["mark","this-cannot-match-an-entryType"]});
|
||||
obs.observe({entryTypes: ["this-cannot-match-an-entryType","mark"]});
|
||||
obs.observe({entryTypes: ["mark"], others: true});
|
||||
}, "Filter unsupported entryType entryType names within the entryTypes sequence");
|
||||
|
||||
async_test(function (t) {
|
||||
var observer = new PerformanceObserver(
|
||||
t.step_func(function (entryList, obs) {
|
||||
assert_equals(observer, obs, "observer is second parameter");
|
||||
checkEntries(entryList.getEntries(),
|
||||
[{ entryType: "measure", name: "measure1"}]);
|
||||
observer.disconnect();
|
||||
t.done();
|
||||
})
|
||||
);
|
||||
performance.clearMarks();
|
||||
observer.observe({entryTypes: ["mark"]});
|
||||
observer.observe({entryTypes: ["measure"]});
|
||||
performance.mark("mark1");
|
||||
performance.measure("measure1");
|
||||
}, "replace observer if already present");
|
||||
</script>
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>PerformanceObservers: resource</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="performanceobservers.js"></script>
|
||||
<h1>PerformanceObservers: resource</h1>
|
||||
<p>
|
||||
New resources will <a href="https://w3c.github.io/performance-timeline/#dfn-queue-a-performanceentry">queue a PerformanceEntry</a>.
|
||||
</p>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(function (t) {
|
||||
function path(pathname) {
|
||||
var filename = pathname.substring(pathname.lastIndexOf('/')+1);
|
||||
return pathname.substring(0, pathname.length - filename.length);
|
||||
}
|
||||
var stored_entries = [];
|
||||
var img_location = document.location.origin + path(document.location.pathname)
|
||||
+ "resources/square.png?random=";
|
||||
var img1 = img_location + Math.floor(Math.random() * 100);
|
||||
var img2 = img_location + Math.floor(Math.random() * 1000);
|
||||
var observer = new PerformanceObserver(
|
||||
t.step_func(function (entryList, obs) {
|
||||
stored_entries =
|
||||
stored_entries.concat(entryList.getEntriesByType("resource"));
|
||||
if (stored_entries.length >= 2) {
|
||||
checkEntries(stored_entries,
|
||||
[{ entryType: "resource", name: img1},
|
||||
{ entryType: "resource", name: img2}]);
|
||||
observer.disconnect();
|
||||
t.done();
|
||||
}
|
||||
})
|
||||
);
|
||||
observer.observe({entryTypes: ["resource"]});
|
||||
var img = document.createElement("img");
|
||||
img.src = img1;
|
||||
document.body.appendChild(img);
|
||||
img = document.createElement("img");
|
||||
img.src = img2;
|
||||
document.body.appendChild(img);
|
||||
}, "resource entries are observable");
|
||||
</script>
|
Binary file not shown.
After Width: | Height: | Size: 249 B |
Loading…
Add table
Add a link
Reference in a new issue