Bug 1523562 [wpt PR 14867] - Ensure that all PerformanceObserver.supportedEntryTypes are observable, a=testonly

Automatic update from web-platform-tests
Merge branch 'master' of github.com:web-platform-tests/wpt

--
Ensure that all supportedEntryTypes are observable

--
Worker aware

--
address feedback

--
Merge pull request #14867 from cvazac/cvazac/supportedEntryTypes

Ensure that all PerformanceObserver.supportedEntryTypes are observable
--

wpt-commits: 854749b6ee9ddd4c5256b79b1c556ffc9c3da335, 170118fea3b35179c3200cacb2d6d7825ffd8cf2, e7a521e5e9a9011436e04456c9e94d7433820fb7, 47abba18888c01102b7db38916e2f1a708cd1f19, 8bcd5014970d502acab110861f516f66182fc596
wpt-pr: 14867
This commit is contained in:
Charles Vazac 2019-01-31 18:57:37 +00:00 коммит произвёл James Graham
Родитель 56b5a05579
Коммит 1bfa0ee80d
5 изменённых файлов: 106 добавлений и 0 удалений

Просмотреть файл

@ -7,3 +7,32 @@ test(() => {
assert_false(types.includes("taskattribution"),
"There should NOT be 'taskattribution' in PerformanceObserver.supportedEntryTypes");
}, "supportedEntryTypes contains 'longtask' but not 'taskattribution'.");
function syncWait(waitDuration) {
if (waitDuration <= 0)
return;
const startTime = performance.now();
let unused = '';
for (let i = 0; i < 10000; i++)
unused += '' + Math.random();
return syncWait(waitDuration - (performance.now() - startTime));
}
if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
const entryType = "longtask";
if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
promise_test(async () => {
await new Promise((resolve) => {
new PerformanceObserver(function (list, observer) {
observer.disconnect();
resolve();
}).observe({entryTypes: [entryType]});
// Force the PerformanceEntry.
syncWait(50);
})
}, `'${entryType}' entries should be observable.`)
}
}

Просмотреть файл

@ -4,3 +4,17 @@ test(() => {
assert_true(PerformanceObserver.supportedEntryTypes.includes("navigation"),
"There should be an entry 'navigation' in PerformanceObserver.supportedEntryTypes");
}, "supportedEntryTypes contains 'navigation'.");
if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
const entryType = "navigation";
if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
promise_test(async() => {
await new Promise((resolve) => {
new PerformanceObserver(function (list, observer) {
observer.disconnect();
resolve();
}).observe({entryTypes: [entryType]});
})
}, `'${entryType}' entries should be observable.`)
}
}

Просмотреть файл

@ -4,3 +4,22 @@ test(() => {
assert_true(PerformanceObserver.supportedEntryTypes.includes("paint"),
"There should be an entry 'paint' in PerformanceObserver.supportedEntryTypes");
}, "supportedEntryTypes contains 'paint'.");
if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
const entryType = 'paint';
if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
promise_test(async() => {
await new Promise((resolve) => {
new PerformanceObserver(function (list, observer) {
observer.disconnect();
resolve();
}).observe({entryTypes: [entryType]});
// Force the PerformanceEntry.
// Use `self` for Workers.
if (self.document)
document.head.parentNode.appendChild(document.createTextNode('foo'));
})
}, `'${entryType}' entries should be observable.`)
}
}

Просмотреть файл

@ -4,3 +4,21 @@
assert_true(PerformanceObserver.supportedEntryTypes.includes("resource"),
"There should be an entry 'resource' in PerformanceObserver.supportedEntryTypes");
}, "supportedEntryTypes contains 'resource'.");
if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
const entryType = "resource";
if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
promise_test(async() => {
await new Promise((resolve) => {
new PerformanceObserver(function (list, observer) {
observer.disconnect();
resolve();
}).observe({entryTypes: [entryType]});
// Force the PerformanceEntry.
// Use `self` for Workers.
fetch(self.location.href + "?" + Math.random());
})
}, `'${entryType}' entries should be observable.`)
}
}

Просмотреть файл

@ -9,3 +9,29 @@ test(() => {
assert_greater_than(types.indexOf("measure"), types.indexOf('mark'),
"The 'measure' entry should appear after the 'mark' entry");
}, "supportedEntryTypes contains 'mark' and 'measure'.");
if (typeof PerformanceObserver.supportedEntryTypes !== "undefined") {
const entryTypes = {
"mark": () => {
performance.mark('foo');
},
"measure": () => {
performance.measure('bar');
}
}
for (let entryType in entryTypes) {
if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
promise_test(async() => {
await new Promise((resolve) => {
new PerformanceObserver(function (list, observer) {
observer.disconnect();
resolve();
}).observe({entryTypes: [entryType]});
// Force the PerformanceEntry.
entryTypes[entryType]();
})
}, `'${entryType}' entries should be observable.`)
}
}
}