Diff
Modified: trunk/LayoutTests/ChangeLog (226450 => 226451)
--- trunk/LayoutTests/ChangeLog 2018-01-05 17:59:50 UTC (rev 226450)
+++ trunk/LayoutTests/ChangeLog 2018-01-05 18:14:15 UTC (rev 226451)
@@ -1,3 +1,26 @@
+2018-01-05 Joseph Pecoraro <[email protected]>
+
+ ServiceWorkers: Enable UserTiming / ResourceTiming
+ https://bugs.webkit.org/show_bug.cgi?id=181297
+ <rdar://problem/36307306>
+
+ Reviewed by Youenn Fablet.
+
+ * http/tests/workers/service/resources/data1.txt: Added.
+ * http/tests/workers/service/resources/data2.txt: Added.
+ Resources to load from a service-worker.
+
+ * http/tests/workers/service/resources/service-worker-resource-timing.js: Added.
+ * http/tests/workers/service/service-worker-resource-timing.https-expected.txt: Added.
+ * http/tests/workers/service/service-worker-resource-timing.https.html: Added.
+ Test that a ServiceWorker can produce resource entries for a few
+ different kinds of loads (CacheStorage load, and a fetch).
+
+ * http/tests/workers/service/resources/service-worker-user-timing.js: Added.
+ * http/tests/workers/service/service-worker-user-timing.https-expected.txt: Added.
+ * http/tests/workers/service/service-worker-user-timing.https.html: Added.
+ Test that a ServiceWorker can produce a mark/measure entries.
+
2018-01-05 Claudio Saavedra <[email protected]>
[WPE][GTK] Unreviewed gardening
Added: trunk/LayoutTests/http/tests/workers/service/resources/data1.txt (0 => 226451)
--- trunk/LayoutTests/http/tests/workers/service/resources/data1.txt (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/data1.txt 2018-01-05 18:14:15 UTC (rev 226451)
@@ -0,0 +1 @@
+Text data 1.
Added: trunk/LayoutTests/http/tests/workers/service/resources/data2.txt (0 => 226451)
--- trunk/LayoutTests/http/tests/workers/service/resources/data2.txt (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/data2.txt 2018-01-05 18:14:15 UTC (rev 226451)
@@ -0,0 +1 @@
+Text data 2.
Added: trunk/LayoutTests/http/tests/workers/service/resources/service-worker-resource-timing.js (0 => 226451)
--- trunk/LayoutTests/http/tests/workers/service/resources/service-worker-resource-timing.js (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/service-worker-resource-timing.js 2018-01-05 18:14:15 UTC (rev 226451)
@@ -0,0 +1,14 @@
+self.addEventListener("install", (event) => {
+ event.waitUntil(
+ caches.open("resource-timing-cache").then((cache) => {
+ return Promise.all([
+ cache.addAll(["/workers/service/resources/data1.txt"]),
+ fetch("/workers/service/resources/data2.txt"),
+ ]);
+ })
+ );
+});
+
+self.addEventListener("message", (event) => {
+ event.source.postMessage({entries: JSON.stringify(performance.getEntries())});
+});
Added: trunk/LayoutTests/http/tests/workers/service/resources/service-worker-user-timing.js (0 => 226451)
--- trunk/LayoutTests/http/tests/workers/service/resources/service-worker-user-timing.js (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/service-worker-user-timing.js 2018-01-05 18:14:15 UTC (rev 226451)
@@ -0,0 +1,9 @@
+self.addEventListener("message", (event) => {
+ performance.clearMarks();
+ performance.clearMeasures();
+ performance.mark("test-mark");
+ performance.measure("test-measure");
+
+ let entries = [...performance.getEntriesByType("mark"), ...performance.getEntriesByType("measure")];
+ event.source.postMessage({entries: JSON.stringify(entries)});
+});
Added: trunk/LayoutTests/http/tests/workers/service/service-worker-resource-timing.https-expected.txt (0 => 226451)
--- trunk/LayoutTests/http/tests/workers/service/service-worker-resource-timing.https-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/service-worker-resource-timing.https-expected.txt 2018-01-05 18:14:15 UTC (rev 226451)
@@ -0,0 +1,4 @@
+
+PASS Setup worker
+PASS Verify service worker had 2 ResourceTiming entries
+
Added: trunk/LayoutTests/http/tests/workers/service/service-worker-resource-timing.https.html (0 => 226451)
--- trunk/LayoutTests/http/tests/workers/service/service-worker-resource-timing.https.html (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/service-worker-resource-timing.https.html 2018-01-05 18:14:15 UTC (rev 226451)
@@ -0,0 +1,44 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script>
+let activeWorker;
+let scope = "/workers/service/resources/";
+
+promise_test(async (test) => {
+ let registration = await navigator.serviceWorker.getRegistration(scope);
+ if (registration && registration.scope.endsWith(scope))
+ await registration.unregister();
+
+ registration = await navigator.serviceWorker.register("resources/service-worker-resource-timing.js", {scope});
+ activeWorker = registration.active;
+ if (activeWorker)
+ return;
+
+ activeWorker = registration.installing;
+ return new Promise((resolve) => {
+ activeWorker.addEventListener("statechange", () => {
+ if (activeWorker.state === "activated")
+ resolve();
+ });
+ });
+}, "Setup worker");
+
+promise_test(async (test) => {
+ activeWorker.postMessage("TEST-RESOURCE-TIMING");
+ await new Promise((resolve, reject) => {
+ navigator.serviceWorker.addEventListener("message", test.step_func((event) => {
+ let entries = JSON.parse(event.data.entries);
+ assert_equals(entries.length, 2);
+ assert_true(entries.some((entry) => entry.name.endsWith("data1.txt")));
+ assert_true(entries.some((entry) => entry.name.endsWith("data2.txt")));
+ resolve();
+ }));
+ });
+}, "Verify service worker had 2 ResourceTiming entries");
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/workers/service/service-worker-user-timing.https-expected.txt (0 => 226451)
--- trunk/LayoutTests/http/tests/workers/service/service-worker-user-timing.https-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/service-worker-user-timing.https-expected.txt 2018-01-05 18:14:15 UTC (rev 226451)
@@ -0,0 +1,4 @@
+
+PASS Setup worker
+PASS Verify service worker had 2 UserTiming entries
+
Added: trunk/LayoutTests/http/tests/workers/service/service-worker-user-timing.https.html (0 => 226451)
--- trunk/LayoutTests/http/tests/workers/service/service-worker-user-timing.https.html (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/service-worker-user-timing.https.html 2018-01-05 18:14:15 UTC (rev 226451)
@@ -0,0 +1,46 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script>
+let activeWorker;
+let scope = "/workers/service/resources/";
+
+promise_test(async (test) => {
+ let registration = await navigator.serviceWorker.getRegistration(scope);
+ if (registration && registration.scope.endsWith(scope))
+ await registration.unregister();
+
+ registration = await navigator.serviceWorker.register("resources/service-worker-user-timing.js", {scope});
+ activeWorker = registration.active;
+ if (activeWorker)
+ return;
+
+ activeWorker = registration.installing;
+ return new Promise((resolve) => {
+ activeWorker.addEventListener("statechange", () => {
+ if (activeWorker.state === "activated")
+ resolve();
+ });
+ });
+}, "Setup worker");
+
+promise_test(async (test) => {
+ activeWorker.postMessage("TEST-USER-TIMING");
+ await new Promise((resolve, reject) => {
+ navigator.serviceWorker.addEventListener("message", test.step_func((event) => {
+ let entries = JSON.parse(event.data.entries);
+ assert_equals(entries.length, 2);
+ assert_equals(entries[0].entryType, "mark");
+ assert_equals(entries[0].name, "test-mark");
+ assert_equals(entries[1].entryType, "measure");
+ assert_equals(entries[1].name, "test-measure");
+ resolve();
+ }));
+ });
+}, "Verify service worker had 2 UserTiming entries");
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (226450 => 226451)
--- trunk/Source/WebCore/ChangeLog 2018-01-05 17:59:50 UTC (rev 226450)
+++ trunk/Source/WebCore/ChangeLog 2018-01-05 18:14:15 UTC (rev 226451)
@@ -1,3 +1,25 @@
+2018-01-05 Joseph Pecoraro <[email protected]>
+
+ ServiceWorkers: Enable UserTiming / ResourceTiming
+ https://bugs.webkit.org/show_bug.cgi?id=181297
+ <rdar://problem/36307306>
+
+ Reviewed by Youenn Fablet.
+
+ Tests: http/tests/workers/service/service-worker-resource-timing.https.html
+ http/tests/workers/service/service-worker-user-timing.https.html
+
+ * loader/ResourceTiming.cpp:
+ (WebCore::ResourceTiming::ResourceTiming):
+ We used to clear extra NetworkLoadMetrics data early on. However,
+ for Workers we want to pass the complete NetworkLoadMetrics to
+ the Worker so that a Worker inspector has access to it.
+
+ * page/PerformanceResourceTiming.cpp:
+ (WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
+ Instead move the clearing of extra data to here, when the NetworkLoadMetrics
+ have finally settled into being used only for a performance entry.
+
2018-01-04 Philippe Normand <[email protected]>
[EME][GStreamer] Fix wrong ifdef
Modified: trunk/Source/WebCore/loader/ResourceTiming.cpp (226450 => 226451)
--- trunk/Source/WebCore/loader/ResourceTiming.cpp 2018-01-05 17:59:50 UTC (rev 226450)
+++ trunk/Source/WebCore/loader/ResourceTiming.cpp 2018-01-05 18:14:15 UTC (rev 226451)
@@ -85,7 +85,6 @@
, m_networkLoadMetrics(networkLoadMetrics)
, m_allowTimingDetails(passesTimingAllowCheck(resource.response(), securityOrigin))
{
- m_networkLoadMetrics.clearNonTimingData();
}
ResourceTiming::ResourceTiming(const URL& url, const String& initiator, const LoadTiming& loadTiming, const NetworkLoadMetrics& networkLoadMetrics, const ResourceResponse& response, const SecurityOrigin& securityOrigin)
@@ -95,7 +94,6 @@
, m_networkLoadMetrics(networkLoadMetrics)
, m_allowTimingDetails(passesTimingAllowCheck(response, securityOrigin))
{
- m_networkLoadMetrics.clearNonTimingData();
}
ResourceTiming ResourceTiming::isolatedCopy() const
Modified: trunk/Source/WebCore/page/PerformanceResourceTiming.cpp (226450 => 226451)
--- trunk/Source/WebCore/page/PerformanceResourceTiming.cpp 2018-01-05 17:59:50 UTC (rev 226450)
+++ trunk/Source/WebCore/page/PerformanceResourceTiming.cpp 2018-01-05 18:14:15 UTC (rev 226451)
@@ -80,6 +80,7 @@
, m_networkLoadMetrics(resourceTiming.networkLoadMetrics())
, m_shouldReportDetails(resourceTiming.allowTimingDetails())
{
+ m_networkLoadMetrics.clearNonTimingData();
}
PerformanceResourceTiming::~PerformanceResourceTiming() = default;
@@ -91,6 +92,7 @@
double PerformanceResourceTiming::workerStart() const
{
+ // FIXME: <https://webkit.org/b/179377> Implement PerformanceResourceTiming.workerStart in ServiceWorkers
return 0.0;
}
Modified: trunk/Source/WebKit/ChangeLog (226450 => 226451)
--- trunk/Source/WebKit/ChangeLog 2018-01-05 17:59:50 UTC (rev 226450)
+++ trunk/Source/WebKit/ChangeLog 2018-01-05 18:14:15 UTC (rev 226451)
@@ -1,3 +1,15 @@
+2018-01-05 Joseph Pecoraro <[email protected]>
+
+ ServiceWorkers: Enable UserTiming / ResourceTiming
+ https://bugs.webkit.org/show_bug.cgi?id=181297
+ <rdar://problem/36307306>
+
+ Reviewed by Youenn Fablet.
+
+ * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+ (WebKit::WebSWContextManagerConnection::updatePreferencesStore):
+ Enable Resource Timing / User Timing for the ServiceWorker process.
+
2018-01-04 Zan Dobersek <[email protected]>
Unreviewed GTK+ build fix.
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (226450 => 226451)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2018-01-05 17:59:50 UTC (rev 226450)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2018-01-05 18:14:15 UTC (rev 226451)
@@ -112,6 +112,8 @@
RuntimeEnabledFeatures::sharedFeatures().setServiceWorkerEnabled(true);
RuntimeEnabledFeatures::sharedFeatures().setCacheAPIEnabled(store.getBoolValueForKey(WebPreferencesKey::cacheAPIEnabledKey()));
RuntimeEnabledFeatures::sharedFeatures().setFetchAPIEnabled(store.getBoolValueForKey(WebPreferencesKey::fetchAPIEnabledKey()));
+ RuntimeEnabledFeatures::sharedFeatures().setUserTimingEnabled(store.getBoolValueForKey(WebPreferencesKey::userTimingEnabledKey()));
+ RuntimeEnabledFeatures::sharedFeatures().setResourceTimingEnabled(store.getBoolValueForKey(WebPreferencesKey::resourceTimingEnabledKey()));
m_storageBlockingPolicy = static_cast<SecurityOrigin::StorageBlockingPolicy>(store.getUInt32ValueForKey(WebPreferencesKey::storageBlockingPolicyKey()));
}