haikuwebkit/LayoutTests/performance-api/performance-observer-callba...

98 lines
3.6 KiB
HTML
Raw Permalink Normal View History

Implement PerformanceObserver https://bugs.webkit.org/show_bug.cgi?id=167546 <rdar://problem/30247959> Reviewed by Ryosuke Niwa. Source/JavaScriptCore: * runtime/CommonIdentifiers.h: Source/WebCore: This implements PerformanceObserver from Performance Timeline Level 2: https://w3c.github.io/performance-timeline/ Tests: performance-api/performance-observer-api.html performance-api/performance-observer-basic.html performance-api/performance-observer-callback-mutate.html performance-api/performance-observer-callback-task.html performance-api/performance-observer-entry-sort.html performance-api/performance-observer-exception.html performance-api/performance-observer-nested.html performance-api/performance-observer-order.html performance-api/performance-observer-periodic.html performance-api/performance-timeline-api.html * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: New files. * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::mark): (WebCore::Performance::measure): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::unregisterPerformanceObserver): (WebCore::Performance::queueEntry): Register PerformanceObservers with the Performance object. When new PerformanceEntries are created (Mark and Measure right now) check them against observers. * page/PerformanceEntry.cpp: (WebCore::PerformanceEntry::PerformanceEntry): (WebCore::PerformanceEntry::typeForEntryTypeString): * page/PerformanceEntry.h: (WebCore::PerformanceEntry::type): Give PerformanceEntry a convenience enum for easy comparison and to know if it is one of the built-in known types (which the PerformanceObserver API takes into account). * page/PerformanceObserver.cpp: Added. (WebCore::PerformanceObserver::PerformanceObserver): (WebCore::PerformanceObserver::observe): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::queueEntry): (WebCore::PerformanceObserver::deliver): * page/PerformanceObserver.h: (WebCore::PerformanceObserver::create): (WebCore::PerformanceObserver::typeFilter): - TypeErrors on observe bad behavior - Completely replace types filter on observe - Handle register and unregister - Handle calling the callback * page/PerformanceObserverCallback.idl: Added. * page/PerformanceObserverEntryList.cpp: Added. (WebCore::PerformanceObserverEntryList::PerformanceObserverEntryList): (WebCore::PerformanceObserverEntryList::getEntries): (WebCore::PerformanceObserverEntryList::getEntriesByType): (WebCore::PerformanceObserverEntryList::getEntriesByName): * page/PerformanceObserverEntryList.h: (WebCore::PerformanceObserverEntryList::create): * page/PerformanceObserverEntryList.idl: Added. Implement sorting and filtering of entries. * page/PerformanceObserver.idl: Added. * page/PerformanceObserverCallback.h: (WebCore::PerformanceObserverCallback::~PerformanceObserverCallback): Mostly autogenerated. * page/PerformanceUserTiming.cpp: (WebCore::UserTiming::mark): (WebCore::UserTiming::measure): * page/PerformanceUserTiming.h: Update these to return the entry so it can be passed on to any interested PerformanceObservers. Source/WebInspectorUI: * UserInterface/Models/NativeFunctionParameters.js: Improve API view display of built-in performance methods. LayoutTests: * performance-api/performance-observer-api-expected.txt: Added. * performance-api/performance-observer-api.html: Added. * performance-api/performance-observer-basic-expected.txt: Added. * performance-api/performance-observer-basic.html: Added. * performance-api/performance-observer-callback-mutate-expected.txt: Added. * performance-api/performance-observer-callback-mutate.html: Added. * performance-api/performance-observer-callback-task-expected.txt: Added. * performance-api/performance-observer-callback-task.html: Added. * performance-api/performance-observer-entry-sort-expected.txt: Added. * performance-api/performance-observer-entry-sort.html: Added. * performance-api/performance-observer-exception-expected.txt: Added. * performance-api/performance-observer-exception.html: Added. * performance-api/performance-observer-nested-expected.txt: Added. * performance-api/performance-observer-nested.html: Added. * performance-api/performance-observer-order-expected.txt: Added. * performance-api/performance-observer-order.html: Added. * performance-api/performance-observer-periodic-expected.txt: Added. * performance-api/performance-observer-periodic.html: Added. PerformanceObserver tests. * performance-api/performance-timeline-api-expected.txt: Added. * performance-api/performance-timeline-api.html: Added. Performance timeline tests. * platform/efl/js/dom/global-constructors-attributes-expected.txt: * platform/gtk/js/dom/global-constructors-attributes-expected.txt: * platform/mac-elcapitan/js/dom/global-constructors-attributes-expected.txt: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: * platform/win/js/dom/global-constructors-attributes-expected.txt: New global constructors. Canonical link: https://commits.webkit.org/184646@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211406 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-31 06:21:35 +00:00
<!DOCTYPE HTML>
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Test PerformanceObserver mutating itself while in its callback.");
window.jsTestIsAsync = true;
// Observer is first watching measures => then marks => measures => both.
// NOTE: Measures are sorted before marks due to startTime.
window.callbackCount = 0;
window.list = null;
let observer = new PerformanceObserver((list) => {
window.list = list;
callbackCount++;
testPassed("PerformanceObserver callback fired");
if (callbackCount === 1) {
// Expected: [measure1]
shouldBe(`list.getEntries().length`, `1`);
shouldBeEqualToString(`list.getEntries()[0].entryType`, "measure");
shouldBeEqualToString(`list.getEntries()[0].name`, "measure1");
updateObserver(["mark"]);
performance.mark("mark2");
performance.measure("measure2");
} else if (callbackCount === 2) {
// Expected: [mark2]
shouldBe(`list.getEntries().length`, `1`);
shouldBeEqualToString(`list.getEntries()[0].entryType`, "mark");
shouldBeEqualToString(`list.getEntries()[0].name`, "mark2");
performance.mark("mark-before-change-observe-state-to-measure");
performance.measure("measure-before-change-observe-state-to-measure");
updateObserver(["measure"]);
performance.mark("mark3");
performance.measure("measure3");
} else if (callbackCount === 3) {
// Expected: [measure3, mark-before-change-observe-state-to-measure]
shouldBe(`list.getEntries().length`, `2`);
shouldBeEqualToString(`list.getEntries()[0].entryType`, "measure");
shouldBeEqualToString(`list.getEntries()[0].name`, "measure3");
shouldBeEqualToString(`list.getEntries()[1].entryType`, "mark");
shouldBeEqualToString(`list.getEntries()[1].name`, "mark-before-change-observe-state-to-measure");
performance.mark("mark-before-change-observe-state-to-both");
performance.measure("measure-before-change-observe-state-to-both");
updateObserver(["mark", "measure"]);
performance.mark("mark4");
performance.measure("measure4");
} else if (callbackCount === 4) {
// Expected: [measure-before-change-observe-state-to-both, measure4, mark4]
shouldBe(`list.getEntries().length`, `3`);
shouldBeEqualToString(`list.getEntries()[0].entryType`, "measure");
shouldBeEqualToString(`list.getEntries()[0].name`, "measure-before-change-observe-state-to-both");
shouldBeEqualToString(`list.getEntries()[1].entryType`, "measure");
shouldBeEqualToString(`list.getEntries()[1].name`, "measure4");
shouldBeEqualToString(`list.getEntries()[2].entryType`, "mark");
shouldBeEqualToString(`list.getEntries()[2].name`, "mark4");
performance.mark("mark-before-disconnect");
performance.measure("measure-before-disconnect");
observer.disconnect();
performance.mark("mark-after-disconnect");
performance.measure("measure-after-disconnect");
setTimeout(finishJSTest, 50);
} else if (callbackCount === 5)
testFailed("Should not have received another callback, the observer was disconnected");
for (let mark of list.getEntries())
debug(" - " + mark.name);
});
function updateObserver(entryTypes) {
debug("Observing: " + JSON.stringify(entryTypes));
Implement PerformanceObserver https://bugs.webkit.org/show_bug.cgi?id=167546 <rdar://problem/30247959> Reviewed by Ryosuke Niwa. Source/JavaScriptCore: * runtime/CommonIdentifiers.h: Source/WebCore: This implements PerformanceObserver from Performance Timeline Level 2: https://w3c.github.io/performance-timeline/ Tests: performance-api/performance-observer-api.html performance-api/performance-observer-basic.html performance-api/performance-observer-callback-mutate.html performance-api/performance-observer-callback-task.html performance-api/performance-observer-entry-sort.html performance-api/performance-observer-exception.html performance-api/performance-observer-nested.html performance-api/performance-observer-order.html performance-api/performance-observer-periodic.html performance-api/performance-timeline-api.html * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: New files. * page/Performance.h: * page/Performance.cpp: (WebCore::Performance::mark): (WebCore::Performance::measure): (WebCore::Performance::registerPerformanceObserver): (WebCore::Performance::unregisterPerformanceObserver): (WebCore::Performance::queueEntry): Register PerformanceObservers with the Performance object. When new PerformanceEntries are created (Mark and Measure right now) check them against observers. * page/PerformanceEntry.cpp: (WebCore::PerformanceEntry::PerformanceEntry): (WebCore::PerformanceEntry::typeForEntryTypeString): * page/PerformanceEntry.h: (WebCore::PerformanceEntry::type): Give PerformanceEntry a convenience enum for easy comparison and to know if it is one of the built-in known types (which the PerformanceObserver API takes into account). * page/PerformanceObserver.cpp: Added. (WebCore::PerformanceObserver::PerformanceObserver): (WebCore::PerformanceObserver::observe): (WebCore::PerformanceObserver::disconnect): (WebCore::PerformanceObserver::queueEntry): (WebCore::PerformanceObserver::deliver): * page/PerformanceObserver.h: (WebCore::PerformanceObserver::create): (WebCore::PerformanceObserver::typeFilter): - TypeErrors on observe bad behavior - Completely replace types filter on observe - Handle register and unregister - Handle calling the callback * page/PerformanceObserverCallback.idl: Added. * page/PerformanceObserverEntryList.cpp: Added. (WebCore::PerformanceObserverEntryList::PerformanceObserverEntryList): (WebCore::PerformanceObserverEntryList::getEntries): (WebCore::PerformanceObserverEntryList::getEntriesByType): (WebCore::PerformanceObserverEntryList::getEntriesByName): * page/PerformanceObserverEntryList.h: (WebCore::PerformanceObserverEntryList::create): * page/PerformanceObserverEntryList.idl: Added. Implement sorting and filtering of entries. * page/PerformanceObserver.idl: Added. * page/PerformanceObserverCallback.h: (WebCore::PerformanceObserverCallback::~PerformanceObserverCallback): Mostly autogenerated. * page/PerformanceUserTiming.cpp: (WebCore::UserTiming::mark): (WebCore::UserTiming::measure): * page/PerformanceUserTiming.h: Update these to return the entry so it can be passed on to any interested PerformanceObservers. Source/WebInspectorUI: * UserInterface/Models/NativeFunctionParameters.js: Improve API view display of built-in performance methods. LayoutTests: * performance-api/performance-observer-api-expected.txt: Added. * performance-api/performance-observer-api.html: Added. * performance-api/performance-observer-basic-expected.txt: Added. * performance-api/performance-observer-basic.html: Added. * performance-api/performance-observer-callback-mutate-expected.txt: Added. * performance-api/performance-observer-callback-mutate.html: Added. * performance-api/performance-observer-callback-task-expected.txt: Added. * performance-api/performance-observer-callback-task.html: Added. * performance-api/performance-observer-entry-sort-expected.txt: Added. * performance-api/performance-observer-entry-sort.html: Added. * performance-api/performance-observer-exception-expected.txt: Added. * performance-api/performance-observer-exception.html: Added. * performance-api/performance-observer-nested-expected.txt: Added. * performance-api/performance-observer-nested.html: Added. * performance-api/performance-observer-order-expected.txt: Added. * performance-api/performance-observer-order.html: Added. * performance-api/performance-observer-periodic-expected.txt: Added. * performance-api/performance-observer-periodic.html: Added. PerformanceObserver tests. * performance-api/performance-timeline-api-expected.txt: Added. * performance-api/performance-timeline-api.html: Added. Performance timeline tests. * platform/efl/js/dom/global-constructors-attributes-expected.txt: * platform/gtk/js/dom/global-constructors-attributes-expected.txt: * platform/mac-elcapitan/js/dom/global-constructors-attributes-expected.txt: * platform/mac-wk1/js/dom/global-constructors-attributes-expected.txt: * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: * platform/win/js/dom/global-constructors-attributes-expected.txt: New global constructors. Canonical link: https://commits.webkit.org/184646@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211406 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-31 06:21:35 +00:00
observer.observe({entryTypes});
}
updateObserver(["measure"]);
performance.mark("mark1");
performance.measure("measure1");
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>