summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/performance-timeline
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/performance-timeline')
-rw-r--r--testing/web-platform/tests/performance-timeline/OWNERS3
-rw-r--r--testing/web-platform/tests/performance-timeline/case-sensitivity.html39
-rw-r--r--testing/web-platform/tests/performance-timeline/idlharness.html85
-rw-r--r--testing/web-platform/tests/performance-timeline/performanceobservers.js21
-rw-r--r--testing/web-platform/tests/performance-timeline/po-disconnect.html44
-rw-r--r--testing/web-platform/tests/performance-timeline/po-getentries.html50
-rw-r--r--testing/web-platform/tests/performance-timeline/po-mark-measure.html72
-rw-r--r--testing/web-platform/tests/performance-timeline/po-navigation.html28
-rw-r--r--testing/web-platform/tests/performance-timeline/po-observe.html58
-rw-r--r--testing/web-platform/tests/performance-timeline/po-resource.html48
-rw-r--r--testing/web-platform/tests/performance-timeline/resources/square.pngbin0 -> 249 bytes
11 files changed, 448 insertions, 0 deletions
diff --git a/testing/web-platform/tests/performance-timeline/OWNERS b/testing/web-platform/tests/performance-timeline/OWNERS
new file mode 100644
index 000000000..56997198b
--- /dev/null
+++ b/testing/web-platform/tests/performance-timeline/OWNERS
@@ -0,0 +1,3 @@
+@plehegar
+@igrigorik
+@toddreifsteck
diff --git a/testing/web-platform/tests/performance-timeline/case-sensitivity.html b/testing/web-platform/tests/performance-timeline/case-sensitivity.html
new file mode 100644
index 000000000..99ef66cce
--- /dev/null
+++ b/testing/web-platform/tests/performance-timeline/case-sensitivity.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<meta charset=utf-8>
+<title>PerformanceTimeline: case sensitivity</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<h1>PerformanceTimeline: case sensitivity</h1>
+<div id="log"></div>
+<script>
+ test(function () {
+ assert_equals(typeof window.performance, "object");
+ assert_equals(typeof window.performance.getEntriesByType, "function");
+ var lowerList = window.performance.getEntriesByType("resource");
+ var upperList = window.performance.getEntriesByType("RESOURCE");
+ var mixedList = window.performance.getEntriesByType("ReSoUrCe");
+
+ assert_not_equals(lowerList.length, 0, "Resource entries exist");
+ assert_equals(upperList.length, 0, "getEntriesByType('RESOURCE').length");
+ assert_equals(mixedList.length, 0, "getEntriesByType('ReSoUrCe').length");
+
+ }, "getEntriesByType values are case sensitive");
+
+ test(function () {
+ assert_equals(typeof window.performance, "object");
+ assert_equals(typeof window.performance.getEntriesByName, "function");
+ var origin = window.location.protocol + "//" + window.location.host;
+ var location1 = origin.toUpperCase() + "/resources/testharness.js";
+ var location2 = window.location.protocol + "//"
+ + window.location.host.toUpperCase() + "/resources/testharness.js";
+ var lowerList = window.performance.getEntriesByName(origin + "/resources/testharness.js");
+ var upperList = window.performance.getEntriesByName(location1);
+ var mixedList = window.performance.getEntriesByName(location2);
+
+ assert_equals(lowerList.length, 1, "Resource entry exist");
+ assert_equals(upperList.length, 0, "getEntriesByName('" + location1 + "').length");
+ assert_equals(mixedList.length, 0, "getEntriesByName('" + location2 + "').length");
+
+ }, "getEntriesByName values are case sensitive");
+
+</script>
diff --git a/testing/web-platform/tests/performance-timeline/idlharness.html b/testing/web-platform/tests/performance-timeline/idlharness.html
new file mode 100644
index 000000000..0500b3eee
--- /dev/null
+++ b/testing/web-platform/tests/performance-timeline/idlharness.html
@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Performance Timeline IDL tests</title>
+<link rel="author" title="W3C" href="http://www.w3.org/" />
+<link rel="help" href="http://www.w3.org/TR/performance-timeline/#performanceentry"/>
+<link rel="help" href="http://www.w3.org/TR/performance-timeline/#performance"/>
+<link rel="help" href="http://www.w3.org/TR/performance-timeline/#performanceentrylist"/>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/WebIDLParser.js"></script>
+<script src="/resources/idlharness.js"></script>
+</head>
+<body>
+<h1>Performance Timeline IDL tests</h1>
+<div id="log"></div>
+
+<pre id='untested_idl' style='display:none'>
+interface Performance {
+};
+</pre>
+
+<pre id='idl'>
+[Exposed=(Window,Worker)]
+interface PerformanceEntry {
+ readonly attribute DOMString name;
+ readonly attribute DOMString entryType;
+ readonly attribute DOMHighResTimeStamp startTime;
+ readonly attribute DOMHighResTimeStamp duration;
+ serializer = {attribute};
+};
+
+dictionary PerformanceEntryFilterOptions {
+ DOMString name;
+ DOMString entryType;
+ DOMString initiatorType;
+};
+
+partial interface Performance {
+ PerformanceEntryList getEntries(optional PerformanceEntryFilterOptions filter);
+ PerformanceEntryList getEntriesByType(DOMString type);
+ PerformanceEntryList getEntriesByName(DOMString name,
+ optional DOMString type);
+};
+
+typedef sequence &lt;PerformanceEntry> PerformanceEntryList;
+
+dictionary PerformanceObserverInit {
+ required sequence&lt;DOMString> entryTypes;
+};
+
+[Exposed=(Window,Worker)]
+interface PerformanceObserverEntryList {
+ PerformanceEntryList getEntries(optional PerformanceEntryFilterOptions filter);
+ PerformanceEntryList getEntriesByType(DOMString type);
+ PerformanceEntryList getEntriesByName(DOMString name,
+ optional DOMString type);
+};
+
+callback PerformanceObserverCallback = void (PerformanceObserverEntryList entries,
+ PerformanceObserver observer);
+
+[Constructor(PerformanceObserverCallback callback),
+ Exposed=(Window,Worker)]
+interface PerformanceObserver {
+ void observe(PerformanceObserverInit options);
+ void disconnect();
+};
+</pre>
+
+<script>
+var idl_array;
+setup(function() {
+ idl_array = new IdlArray();
+ idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
+ idl_array.add_idls(document.getElementById("idl").textContent);
+ idl_array.add_objects({
+ Performance: ["window.performance"]
+ });
+});
+idl_array.test();
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/performance-timeline/performanceobservers.js b/testing/web-platform/tests/performance-timeline/performanceobservers.js
new file mode 100644
index 000000000..08587694e
--- /dev/null
+++ b/testing/web-platform/tests/performance-timeline/performanceobservers.js
@@ -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");
+ });
+}
diff --git a/testing/web-platform/tests/performance-timeline/po-disconnect.html b/testing/web-platform/tests/performance-timeline/po-disconnect.html
new file mode 100644
index 000000000..dff39cfaa
--- /dev/null
+++ b/testing/web-platform/tests/performance-timeline/po-disconnect.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML>
+<meta charset=utf-8>
+<title>PerformanceObservers: disconnect</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="performanceobservers.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>
diff --git a/testing/web-platform/tests/performance-timeline/po-getentries.html b/testing/web-platform/tests/performance-timeline/po-getentries.html
new file mode 100644
index 000000000..556209df6
--- /dev/null
+++ b/testing/web-platform/tests/performance-timeline/po-getentries.html
@@ -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>
diff --git a/testing/web-platform/tests/performance-timeline/po-mark-measure.html b/testing/web-platform/tests/performance-timeline/po-mark-measure.html
new file mode 100644
index 000000000..7455c0e87
--- /dev/null
+++ b/testing/web-platform/tests/performance-timeline/po-mark-measure.html
@@ -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>
diff --git a/testing/web-platform/tests/performance-timeline/po-navigation.html b/testing/web-platform/tests/performance-timeline/po-navigation.html
new file mode 100644
index 000000000..ba3af6495
--- /dev/null
+++ b/testing/web-platform/tests/performance-timeline/po-navigation.html
@@ -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>
diff --git a/testing/web-platform/tests/performance-timeline/po-observe.html b/testing/web-platform/tests/performance-timeline/po-observe.html
new file mode 100644
index 000000000..84edea84e
--- /dev/null
+++ b/testing/web-platform/tests/performance-timeline/po-observe.html
@@ -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>
diff --git a/testing/web-platform/tests/performance-timeline/po-resource.html b/testing/web-platform/tests/performance-timeline/po-resource.html
new file mode 100644
index 000000000..00c173eea
--- /dev/null
+++ b/testing/web-platform/tests/performance-timeline/po-resource.html
@@ -0,0 +1,48 @@
+<!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 gUniqueCounter = 0;
+ function generateUniqueValues() {
+ return Date.now() + "-" + (++gUniqueCounter);
+ }
+ var stored_entries = [];
+ var img_location = document.location.origin + path(document.location.pathname)
+ + "resources/square.png?random=";
+ var img1 = img_location + generateUniqueValues();
+ var img2 = img_location + generateUniqueValues();
+ 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>
diff --git a/testing/web-platform/tests/performance-timeline/resources/square.png b/testing/web-platform/tests/performance-timeline/resources/square.png
new file mode 100644
index 000000000..be211bc37
--- /dev/null
+++ b/testing/web-platform/tests/performance-timeline/resources/square.png
Binary files differ