Skip to content

Commit

Permalink
[PerformanceObserver] Ship |type| in PerformanceObserverInit
Browse files Browse the repository at this point in the history
This CL aligns PerformanceObserverInit with the latest changes in
https://w3c.github.io/performance-timeline/ except for the buffered flag
which is still unsupported. This changed in
w3c/performance-timeline#112.

Intent to Ship:
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/IPl_CSXhMbw

Bug: 922622
Change-Id: I39f510f302713c3f12f8f80ada1052fdeedc97a3
  • Loading branch information
npm1 authored and chromium-wpt-export-bot committed Jan 24, 2019
1 parent 309c462 commit 5deaab4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 5 deletions.
54 changes: 54 additions & 0 deletions performance-timeline/po-observe-type.any.js
@@ -0,0 +1,54 @@
// META: script=performanceobservers.js

test(() => {
const obs = new PerformanceObserver(() =>{});
obs.observe({entryTypes: ["mark"]});
assert_throws('InvalidModificationError', function () {
obs.observe({type: "measure"});
});
}, "Calling observe() with entryTypes and then type should throw an InvalidModificationError");

test(() => {
const obs = new PerformanceObserver(() =>{});
obs.observe({type: "mark"});
assert_throws('InvalidModificationError', function () {
obs.observe({entryTypes: ["measure"]});
});
}, "Calling observe() with type and then entryTypes should throw an InvalidModificationError");

test(() => {
const obs = new PerformanceObserver(() =>{});
assert_throws(new SyntaxError(), function () {
obs.observe({type: "mark", entryTypes: ["measure"]});
});
}, "Calling observe() with type and entryTypes should throw a SyntaxError");

test(function () {
const obs = new PerformanceObserver(() =>{});
// Definitely not an entry type.
obs.observe({type: "this-cannot-match-an-entryType"});
// Close to an entry type, but not quite.
obs.observe({type: "marks"});
}, "Passing in unknown values to type does not throw an exception.");

async_test(function (t) {
let observedMark = false;
let observedMeasure = false;
const observer = new PerformanceObserver(
t.step_func(function (entryList, obs) {
observedMark |= entryList.getEntries().filter(
entry => entry.entryType === 'mark').length;
observedMeasure |= entryList.getEntries().filter(
entry => entry.entryType === 'measure').length
// Only conclude the test once we receive both entries!
if (observedMark && observedMeasure) {
observer.disconnect();
t.done();
}
})
);
observer.observe({type: "mark"});
observer.observe({type: "measure"});
self.performance.mark("mark1");
self.performance.measure("measure1");
}, "observe() with different type values stacks.");
10 changes: 5 additions & 5 deletions performance-timeline/po-observe.any.js
Expand Up @@ -2,13 +2,13 @@

test(function () {
var obs = new PerformanceObserver(function () { return true; });
assert_throws(new TypeError(), function () {
assert_throws(new SyntaxError(), function () {
obs.observe({});
});
assert_throws(new TypeError(), function () {
assert_throws(new SyntaxError(), function () {
obs.observe({entryType: []});
});
}, "no entryTypes throws a TypeError");
}, "no 'type' or 'entryTypes' throws a SyntaxError");
test(function () {
var obs = new PerformanceObserver(function () { return true; });
assert_throws(new TypeError(), function () {
Expand All @@ -19,13 +19,13 @@
test(function () {
var obs = new PerformanceObserver(function () { return true; });
obs.observe({entryTypes: []});
}, "Empty sequence entryTypes is a no-op");
}, "Empty sequence entryTypes does not throw an exception.");

test(function () {
var obs = new PerformanceObserver(function () { return true; });
obs.observe({entryTypes: ["this-cannot-match-an-entryType"]});
obs.observe({entryTypes: ["marks","navigate", "resources"]});
}, "Unknown entryTypes are no-op");
}, "Unknown entryTypes do not cause an exception to be thrown.");

test(function () {
var obs = new PerformanceObserver(function () { return true; });
Expand Down

0 comments on commit 5deaab4

Please sign in to comment.