-
Notifications
You must be signed in to change notification settings - Fork 54
/
po-observe-type.any.js
54 lines (49 loc) · 1.91 KB
/
po-observe-type.any.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 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.");