Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PerformanceObserver] Ship |type| in PerformanceObserverInit
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
1 parent
309c462
commit 5deaab4
Showing
2 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters