Runtime feature flag for Server-Timing
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2018 18:33:43 +0000 (18:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2018 18:33:43 +0000 (18:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184758

Patch by Charles Vazac <cvazac@gmail.com> on 2018-05-11
Reviewed by Youenn Fablet.

Source/WebCore:

* Source/WebCore/CMakeLists.txt: Added reference to PerformanceServerTiming.idl.
* Source/WebCore/DerivedSources.make: Added reference to PerformanceServerTiming.idl.
* Source/WebCore/Sources.txt: Added reference to PerformanceServerTiming.cpp and JSPerformanceServerTiming.cpp.
* Source/WebCore/WebCore.xcodeproj/project.pbxproj: Added references to PerformanceServerTiming.cpp, PerformanceServerTiming.h, and PerformanceServerTiming.idl.
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h: Added PerformanceServerTiming.
* Source/WebCore/page/PerformanceResourceTiming.h: Added serverTiming member.
* Source/WebCore/page/PerformanceResourceTiming.idl: Added serverTiming attribute.
* Source/WebCore/page/PerformanceServerTiming.cpp: Added.
* Source/WebCore/page/PerformanceServerTiming.h: Added.
* Source/WebCore/page/PerformanceServerTiming.idl: Added.

Source/WebKit:

* Shared/WebPreferences.yaml: Added ServerTimingEnabled.
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesGetServerTimingEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h: WK_EXPORT for WKPreferencesSetServerTimingEnabled.
* WebProcess/Storage/WebSWContextManagerConnection.cpp: Call setServerTimingEnabled.

Source/WebKitLegacy:

* mac/WebView/WebPreferenceKeysPrivate.h: Added server-timing preference.
* mac/WebView/WebPreferences.mm:
(WebKit::WebPreferences::serverTimingEnabled):
(WebKit::WebPreferences::setServerTimingEnabled):
* mac/WebView/WebPreferencesPrivate.h:
(WebKit::WebPreferences::setServerTimingEnabled):
(WebKit::WebPreferences::serverTimingEnabled):
* mac/WebView/WebView.mm: Set runtime enabled feature based on preference.
* win/Interfaces/IWebPreferencesPrivate.idl: define serverTimingEnabled and setServerTimingEnabled.
* win/WebPreferenceKeysPrivate.h: Added server-timing preference.
* win/WebPreferences.cpp: Initialize server-timing as false and define setter and getter.
(WebKit::WebPreferences::serverTimingEnabled):
(WebKit::WebPreferences::setServerTimingEnabled):
* win/WebPreferences.h: Define serverTimingEnabled and setServerTimingEnabled.
* win/WebView.cpp: Set runtime enabled feature based on preference.

Tools:

* TestWebKitAPI/Configurations/FeatureDefines.xcconfig: added ENABLE_SERVER_TIMING.
* DumpRenderTree/win/DumpRenderTree.cpp: enable Server Timing

LayoutTests:

* imported/w3c/resources/import-expectations.json: Import server-timing tests.
* imported/w3c/web-platform-tests/server-timing/resource_timing_idl.html: Added.
* imported/w3c/web-platform-tests/server-timing/resource_timing_idl-expected.txt: Added.
* platform/ios-wk1/TestExpectations: Skip service-worker test.
* platform/mac-wk1/TestExpectations: Skip service-worker test.
* platform/win/TestExpectations: Skip service-worker test.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231709 268f45cc-cd09-0410-ab3c-d52691b4dbfc

41 files changed:
LayoutTests/ChangeLog
LayoutTests/imported/w3c/resources/import-expectations.json
LayoutTests/imported/w3c/web-platform-tests/server-timing/resource_timing_idl-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/server-timing/resource_timing_idl.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/server-timing/service_worker_idl-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/server-timing/service_worker_idl.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/server-timing/sw.js [new file with mode: 0644]
LayoutTests/platform/ios-wk1/TestExpectations
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Source/WebCore/page/PerformanceResourceTiming.h
Source/WebCore/page/PerformanceResourceTiming.idl
Source/WebCore/page/PerformanceServerTiming.cpp [new file with mode: 0644]
Source/WebCore/page/PerformanceServerTiming.h [new file with mode: 0644]
Source/WebCore/page/PerformanceServerTiming.idl [new file with mode: 0644]
Source/WebCore/page/RuntimeEnabledFeatures.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/C/WKPreferences.cpp
Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
Source/WebKitLegacy/ChangeLog
Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKitLegacy/mac/WebView/WebPreferences.mm
Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h
Source/WebKitLegacy/mac/WebView/WebView.mm
Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl
Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h
Source/WebKitLegacy/win/WebPreferences.cpp
Source/WebKitLegacy/win/WebPreferences.h
Source/WebKitLegacy/win/WebView.cpp
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/DumpRenderTree/win/DumpRenderTree.cpp
Tools/WebKitTestRunner/TestController.cpp

index 50aaf21..5223243 100644 (file)
@@ -1,3 +1,17 @@
+2018-05-11  Charles Vazac  <cvazac@gmail.com>
+
+        Runtime feature flag for Server-Timing
+        https://bugs.webkit.org/show_bug.cgi?id=184758
+
+        Reviewed by Youenn Fablet.
+
+        * imported/w3c/resources/import-expectations.json: Import server-timing tests.
+        * imported/w3c/web-platform-tests/server-timing/resource_timing_idl.html: Added.
+        * imported/w3c/web-platform-tests/server-timing/resource_timing_idl-expected.txt: Added.
+        * platform/ios-wk1/TestExpectations: Skip service-worker test.
+        * platform/mac-wk1/TestExpectations: Skip service-worker test.
+        * platform/win/TestExpectations: Skip service-worker test.
+
 2018-05-11  Youenn Fablet  <youenn@apple.com>
 
         Layout Test webrtc/addICECandidate-closed.html is a flaky failure
index 054ff2f..56fe4f6 100644 (file)
     "web-platform-tests/selection": "skip", 
     "web-platform-tests/selectors": "skip", 
     "web-platform-tests/selectors-api": "skip", 
-    "web-platform-tests/server-timing": "skip", 
+    "web-platform-tests/server-timing": "import", 
     "web-platform-tests/service-workers/cache-storage": "import", 
     "web-platform-tests/service-workers/service-worker": "import", 
     "web-platform-tests/service-workers/tools": "import", 
diff --git a/LayoutTests/imported/w3c/web-platform-tests/server-timing/resource_timing_idl-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/server-timing/resource_timing_idl-expected.txt
new file mode 100644 (file)
index 0000000..c2c15e0
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Untitled 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/server-timing/resource_timing_idl.html b/LayoutTests/imported/w3c/web-platform-tests/server-timing/resource_timing_idl.html
new file mode 100644 (file)
index 0000000..d2c3c92
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<head>
+    <meta charset='utf-8' />
+    <script src="/resources/testharness.js"></script>
+    <script src='/resources/testharnessreport.js'></script>
+    <script>
+      setup({explicit_done: true})
+      window.addEventListener('load', function(){
+        assert_not_equals(typeof performance.getEntriesByType('resource')[0].serverTiming, 'undefined',
+          'An instance of `PerformanceResourceTiming` should have a `serverTiming` attribute.')
+        done()
+      })
+    </script>
+</head>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/server-timing/service_worker_idl-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/server-timing/service_worker_idl-expected.txt
new file mode 100644 (file)
index 0000000..c2c15e0
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Untitled 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/server-timing/service_worker_idl.html b/LayoutTests/imported/w3c/web-platform-tests/server-timing/service_worker_idl.html
new file mode 100644 (file)
index 0000000..1c1be89
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<head>
+    <meta charset='utf-8' />
+    <script src="/resources/testharness.js"></script>
+    <script src='/resources/testharnessreport.js'></script>
+    <script>
+      (async () => {
+        const scope = 'does/not/exist'
+
+        let registration = await navigator.serviceWorker.getRegistration(scope)
+        if (registration)
+          await registration.unregister()
+        registration = await navigator.serviceWorker.register('./sw.js', {scope})
+
+        fetch_tests_from_worker(registration.installing)
+      })()
+    </script>
+</head>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/server-timing/sw.js b/LayoutTests/imported/w3c/web-platform-tests/server-timing/sw.js
new file mode 100644 (file)
index 0000000..f593c9f
--- /dev/null
@@ -0,0 +1,12 @@
+importScripts('/resources/testharness.js')
+
+promise_test(async (test) => {
+  return fetch('./sw.js').then(function(response) {
+    setTimeout(() => {
+      assert_not_equals(typeof performance.getEntriesByName(response.url)[0].serverTiming,
+        'undefined',
+        'An instance of `PerformanceResourceTiming` should have a `serverTiming` attribute in the Service Worker context.')
+      done()
+    }, 100)
+  })
+})
index 0b4a3ca..ea68a10 100644 (file)
@@ -9,6 +9,7 @@ editing/input/focus-change-with-marked-text.html [ Pass ]
 
 # No service worker implementation for WK1
 imported/w3c/web-platform-tests/service-workers [ Skip ]
+imported/w3c/web-platform-tests/server-timing/service_worker_idl.html [ Skip ]
 http/wpt/service-workers [ Skip ]
 http/wpt/cache-storage [ Skip ]
 http/tests/cache-storage [ Skip ]
index df0f144..275d910 100644 (file)
@@ -149,6 +149,7 @@ imported/w3c/web-platform-tests/streams/readable-byte-streams/detached-buffers.s
 http/tests/appcache/main-resource-redirect-with-sw.html [ Skip ]
 http/tests/cookies/same-site/fetch-in-cross-origin-service-worker.html [ Skip ]
 http/tests/cookies/same-site/fetch-in-same-origin-service-worker.html [ Skip ]
+imported/w3c/web-platform-tests/server-timing/service_worker_idl.html [ Skip ]
 
 # Skip WebRTC for now in WK1
 imported/w3c/web-platform-tests/webrtc [ Skip ]
index d83d77d..b3615b2 100644 (file)
@@ -3797,6 +3797,7 @@ imported/w3c/web-platform-tests/fetch/api/policies/referrer-origin-service-worke
 imported/w3c/web-platform-tests/fetch/api/policies/referrer-origin-when-cross-origin-service-worker.https.html [ Skip ]
 imported/w3c/web-platform-tests/fetch/api/policies/referrer-unsafe-url-service-worker.https.html [ Skip ]
 imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/canblock-serviceworker.https.html [ Skip ]
+imported/w3c/web-platform-tests/server-timing/service_worker_idl.html [ Skip ]
 imported/w3c/web-platform-tests/service-workers [ Skip ]
 http/tests/cache-storage [ Skip ]
 http/wpt/cache-storage [ Skip ]
index 264414e..5deaeec 100644 (file)
@@ -819,6 +819,7 @@ set(WebCore_NON_SVG_IDL_FILES
     page/PerformanceObserverEntryList.idl
     page/PerformanceNavigation.idl
     page/PerformanceResourceTiming.idl
+    page/PerformanceServerTiming.idl
     page/PerformanceTiming.idl
     page/RemoteDOMWindow.idl
     page/Screen.idl
index bb3e5a4..76a3898 100644 (file)
@@ -1,3 +1,21 @@
+2018-05-11  Charles Vazac  <cvazac@gmail.com>
+
+        Runtime feature flag for Server-Timing
+        https://bugs.webkit.org/show_bug.cgi?id=184758
+
+        Reviewed by Youenn Fablet.
+
+        * Source/WebCore/CMakeLists.txt: Added reference to PerformanceServerTiming.idl.
+        * Source/WebCore/DerivedSources.make: Added reference to PerformanceServerTiming.idl.
+        * Source/WebCore/Sources.txt: Added reference to PerformanceServerTiming.cpp and JSPerformanceServerTiming.cpp.
+        * Source/WebCore/WebCore.xcodeproj/project.pbxproj: Added references to PerformanceServerTiming.cpp, PerformanceServerTiming.h, and PerformanceServerTiming.idl.
+        * Source/WebCore/bindings/js/WebCoreBuiltinNames.h: Added PerformanceServerTiming.
+        * Source/WebCore/page/PerformanceResourceTiming.h: Added serverTiming member.
+        * Source/WebCore/page/PerformanceResourceTiming.idl: Added serverTiming attribute.
+        * Source/WebCore/page/PerformanceServerTiming.cpp: Added.
+        * Source/WebCore/page/PerformanceServerTiming.h: Added.
+        * Source/WebCore/page/PerformanceServerTiming.idl: Added.
+
 2018-05-11  Brady Eidson  <beidson@apple.com>
 
         Make sure history navigations reuse the existing process when necessary.
index b660e32..262e0c7 100644 (file)
@@ -783,6 +783,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/page/PerformanceObserverCallback.idl \
     $(WebCore)/page/PerformanceObserverEntryList.idl \
     $(WebCore)/page/PerformanceResourceTiming.idl \
+    $(WebCore)/page/PerformanceServerTiming.idl \
     $(WebCore)/page/PerformanceTiming.idl \
     $(WebCore)/page/RemoteDOMWindow.idl \
     $(WebCore)/page/Screen.idl \
index 5d544ee..c7045af 100644 (file)
@@ -1392,6 +1392,7 @@ page/PerformanceNavigation.cpp
 page/PerformanceObserver.cpp
 page/PerformanceObserverEntryList.cpp
 page/PerformanceResourceTiming.cpp
+page/PerformanceServerTiming.cpp
 page/PerformanceTiming.cpp
 page/PerformanceUserTiming.cpp
 page/PointerLockController.cpp
@@ -2809,6 +2810,7 @@ JSPerformanceObserver.cpp
 JSPerformanceObserverCallback.cpp
 JSPerformanceObserverEntryList.cpp
 JSPerformanceResourceTiming.cpp
+JSPerformanceServerTiming.cpp
 JSPerformanceTiming.cpp
 JSPeriodicWave.cpp
 JSPlaybackDirection.cpp
index c33895e..e5bb1b8 100644 (file)
                26F756B41B3B68F20005DD79 /* ImmutableNFANodeBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImmutableNFANodeBuilder.h; sourceTree = "<group>"; };
                26F9A83618A046AC00AEB88A /* ViewportConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewportConfiguration.cpp; sourceTree = "<group>"; };
                26F9A83718A046AC00AEB88A /* ViewportConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewportConfiguration.h; sourceTree = "<group>"; };
+               28DB9BC52020EA0400E54A07 /* PerformanceServerTiming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceServerTiming.cpp; sourceTree = "<group>"; };
+               28DB9BC62020EA0400E54A07 /* PerformanceServerTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceServerTiming.h; sourceTree = "<group>"; };
+               28DB9BC72020EA0400E54A07 /* PerformanceServerTiming.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PerformanceServerTiming.idl; sourceTree = "<group>"; };
                2914E3051CAB5A440049966F /* AccessibilityAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityAttachment.cpp; sourceTree = "<group>"; };
                2914E3061CAB5A440049966F /* AccessibilityAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityAttachment.h; sourceTree = "<group>"; };
                2917B55E1473496C0052C9D0 /* LayerFlushScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayerFlushScheduler.cpp; sourceTree = "<group>"; };
                                86512EDB154A2AEE00A90426 /* PerformanceResourceTiming.cpp */,
                                86512EDC154A2AEF00A90426 /* PerformanceResourceTiming.h */,
                                86512EDD154A2AEF00A90426 /* PerformanceResourceTiming.idl */,
+                               28DB9BC52020EA0400E54A07 /* PerformanceServerTiming.cpp */,
+                               28DB9BC62020EA0400E54A07 /* PerformanceServerTiming.h */,
+                               28DB9BC72020EA0400E54A07 /* PerformanceServerTiming.idl */,
                                0F43C85C189E10CF00019AE2 /* PerformanceTiming.cpp */,
                                8AF4E55911DC5A63000ED3DE /* PerformanceTiming.h */,
                                8AF4E55A11DC5A63000ED3DE /* PerformanceTiming.idl */,
index 150192f..e9bf55c 100644 (file)
@@ -118,6 +118,7 @@ namespace WebCore {
     macro(PerformanceObserver) \
     macro(PerformanceObserverEntryList) \
     macro(PerformanceResourceTiming) \
+    macro(PerformanceServerTiming) \
     macro(PublicKeyCredential) \
     macro(RTCDTMFSender) \
     macro(RTCDTMFToneChangeEvent) \
index f994d9e..bbb3f34 100644 (file)
@@ -39,6 +39,7 @@
 
 namespace WebCore {
 
+class PerformanceServerTiming;
 class ResourceTiming;
 
 class PerformanceResourceTiming final : public PerformanceEntry {
@@ -60,6 +61,7 @@ public:
     double requestStart() const;
     double responseStart() const;
     double responseEnd() const;
+    const Vector<Ref<PerformanceServerTiming>>& serverTiming() const { return m_serverTiming; }
 
 private:
     PerformanceResourceTiming(MonotonicTime timeOrigin, ResourceTiming&&);
@@ -72,6 +74,7 @@ private:
     LoadTiming m_loadTiming;
     NetworkLoadMetrics m_networkLoadMetrics;
     bool m_shouldReportDetails;
+    Vector<Ref<PerformanceServerTiming>> m_serverTiming;
 };
 
 } // namespace WebCore
index 8a62d5c..bbd800a 100644 (file)
@@ -51,6 +51,7 @@ typedef double DOMHighResTimeStamp;
     readonly attribute DOMHighResTimeStamp requestStart;
     readonly attribute DOMHighResTimeStamp responseStart;
     readonly attribute DOMHighResTimeStamp responseEnd;
+    [EnabledAtRuntime=ServerTiming] readonly attribute FrozenArray<PerformanceServerTiming> serverTiming;
 
     serializer = { inherit, attribute };
 };
diff --git a/Source/WebCore/page/PerformanceServerTiming.cpp b/Source/WebCore/page/PerformanceServerTiming.cpp
new file mode 100644 (file)
index 0000000..4840876
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017 The Chromium Authors. All rights reserved.
+ * Copyright (C) 2018 Akamai Technologies Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PerformanceServerTiming.h"
+
+namespace WebCore {
+
+Ref<PerformanceServerTiming> PerformanceServerTiming::create(String&& name, double duration, String&& description)
+{
+    return adoptRef(*new PerformanceServerTiming(WTFMove(name), duration, WTFMove(description)));
+}
+
+PerformanceServerTiming::PerformanceServerTiming(String&& name, double duration, String&& description)
+    : m_name(WTFMove(name))
+    , m_duration(duration)
+    , m_description(WTFMove(description))
+{
+}
+
+PerformanceServerTiming::~PerformanceServerTiming() = default;
+
+} // namespace WebCore
diff --git a/Source/WebCore/page/PerformanceServerTiming.h b/Source/WebCore/page/PerformanceServerTiming.h
new file mode 100644 (file)
index 0000000..fba9922
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2017 The Chromium Authors. All rights reserved.
+ * Copyright (C) 2018 Akamai Technologies Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class PerformanceServerTiming : public RefCounted<PerformanceServerTiming> {
+public:
+    static Ref<PerformanceServerTiming> create(String&& name, double duration, String&& description);
+    ~PerformanceServerTiming();
+
+    const String& name() const { return m_name; }
+    double duration() const { return m_duration; }
+    const String& description() const { return m_description; }
+
+private:
+    PerformanceServerTiming(String&& name, double duration, String&& description);
+    String m_name;
+    double m_duration;
+    String m_description;
+};
+
+} // namespace WebCore
diff --git a/Source/WebCore/page/PerformanceServerTiming.idl b/Source/WebCore/page/PerformanceServerTiming.idl
new file mode 100644 (file)
index 0000000..e4cefec
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2017 The Chromium Authors. All rights reserved.
+ * Copyright (C) 2018 Akamai Technologies Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// https://w3c.github.io/server-timing/#dom-performanceservertiming
+
+typedef double DOMHighResTimeStamp;
+
+[
+    Exposed=(Window,Worker),
+    ImplementationLacksVTable,
+    EnabledAtRuntime=ServerTiming
+] interface PerformanceServerTiming {
+    readonly attribute DOMString name;
+    readonly attribute DOMHighResTimeStamp duration;
+    readonly attribute DOMString description;
+    serializer = {attribute};
+};
index f692e57..d761125 100644 (file)
@@ -259,6 +259,9 @@ public:
     void setStorageAccessPromptsEnabled(bool isEnabled)  { m_promptForStorageAccessAPIEnabled = isEnabled; }
     bool storageAccessPromptsEnabled() const { return m_promptForStorageAccessAPIEnabled; }
 
+    void setServerTimingEnabled(bool isEnabled) { m_isServerTimingEnabled = isEnabled; }
+    bool serverTimingEnabled() const { return m_isServerTimingEnabled; }
+
     WEBCORE_EXPORT static RuntimeEnabledFeatures& sharedFeatures();
 
 private:
@@ -394,11 +397,13 @@ private:
     bool m_isRestrictedHTTPResponseAccess { true };
 
     bool m_fromOriginResponseHeaderEnabled { false };
-    
+
     bool m_isWebGLCompressedTextureASTCSupportEnabled { false };
 
     bool m_promptForStorageAccessAPIEnabled { false };
 
+    bool m_isServerTimingEnabled { false };
+
     friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>;
 };
 
index 4eb5c6d..5b571af 100644 (file)
@@ -1,3 +1,16 @@
+2018-05-11  Charles Vazac  <cvazac@gmail.com>
+
+        Runtime feature flag for Server-Timing
+        https://bugs.webkit.org/show_bug.cgi?id=184758
+
+        Reviewed by Youenn Fablet.
+
+        * Shared/WebPreferences.yaml: Added ServerTimingEnabled.
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesGetServerTimingEnabled):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h: WK_EXPORT for WKPreferencesSetServerTimingEnabled.
+        * WebProcess/Storage/WebSWContextManagerConnection.cpp: Call setServerTimingEnabled.
+
 2018-05-11  Antti Koivisto  <antti@apple.com>
 
         Network process should not stat() all cache files on startup to find their sizes
index cc6b498..b54dc13 100644 (file)
@@ -1274,3 +1274,12 @@ StorageAccessPromptsEnabled:
     humanReadableDescription: "Prompt the user when Storage Access API calls are made"
     category: experimental
     webcoreBinding: RuntimeEnabledFeatures
+
+ServerTimingEnabled:
+    type: bool
+    defaultValue: false
+    humanReadableName: "Server Timing"
+    humanReadableDescription: "Enable Server Timing API"
+    category: experimental
+    webcoreBinding: RuntimeEnabledFeatures
+    webcoreName: serverTimingEnabled
index 80a1e5c..20d5f12 100644 (file)
@@ -1993,3 +1993,13 @@ bool WKPreferencesGetRestrictedHTTPResponseAccess(WKPreferencesRef preferencesRe
 {
     return toImpl(preferencesRef)->restrictedHTTPResponseAccess();
 }
+
+void WKPreferencesSetServerTimingEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setServerTimingEnabled(flag);
+}
+
+bool WKPreferencesGetServerTimingEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->serverTimingEnabled();
+}
index 809b318..142ba22 100644 (file)
@@ -561,6 +561,10 @@ WK_EXPORT bool WKPreferencesGetShouldAllowUserInstalledFonts(WKPreferencesRef);
 WK_EXPORT void WKPreferencesSetAllowCrossOriginSubresourcesToAskForCredentials(WKPreferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetAllowCrossOriginSubresourcesToAskForCredentials(WKPreferencesRef);
 
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetServerTimingEnabled(WKPreferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetServerTimingEnabled(WKPreferencesRef);
+
 #ifdef __cplusplus
 }
 #endif
index 1c42d0b..259824c 100644 (file)
@@ -129,6 +129,7 @@ void WebSWContextManagerConnection::updatePreferencesStore(const WebPreferencesS
     RuntimeEnabledFeatures::sharedFeatures().setResourceTimingEnabled(store.getBoolValueForKey(WebPreferencesKey::resourceTimingEnabledKey()));
     RuntimeEnabledFeatures::sharedFeatures().setFetchAPIKeepAliveEnabled(store.getBoolValueForKey(WebPreferencesKey::fetchAPIKeepAliveEnabledKey()));
     RuntimeEnabledFeatures::sharedFeatures().setRestrictedHTTPResponseAccess(store.getBoolValueForKey(WebPreferencesKey::restrictedHTTPResponseAccessKey()));
+    RuntimeEnabledFeatures::sharedFeatures().setServerTimingEnabled(store.getBoolValueForKey(WebPreferencesKey::serverTimingEnabledKey()));
 
     m_storageBlockingPolicy = static_cast<SecurityOrigin::StorageBlockingPolicy>(store.getUInt32ValueForKey(WebPreferencesKey::storageBlockingPolicyKey()));
 }
index 2279487..c2ba26d 100644 (file)
@@ -1,3 +1,26 @@
+2018-05-11  Charles Vazac  <cvazac@gmail.com>
+
+        Runtime feature flag for Server-Timing
+        https://bugs.webkit.org/show_bug.cgi?id=184758
+
+        Reviewed by Youenn Fablet.
+
+        * mac/WebView/WebPreferenceKeysPrivate.h: Added server-timing preference.
+        * mac/WebView/WebPreferences.mm:
+        (WebKit::WebPreferences::serverTimingEnabled):
+        (WebKit::WebPreferences::setServerTimingEnabled):
+        * mac/WebView/WebPreferencesPrivate.h:
+        (WebKit::WebPreferences::setServerTimingEnabled):
+        (WebKit::WebPreferences::serverTimingEnabled):
+        * mac/WebView/WebView.mm: Set runtime enabled feature based on preference.
+        * win/Interfaces/IWebPreferencesPrivate.idl: define serverTimingEnabled and setServerTimingEnabled.
+        * win/WebPreferenceKeysPrivate.h: Added server-timing preference.
+        * win/WebPreferences.cpp: Initialize server-timing as false and define setter and getter.
+        (WebKit::WebPreferences::serverTimingEnabled):
+        (WebKit::WebPreferences::setServerTimingEnabled):
+        * win/WebPreferences.h: Define serverTimingEnabled and setServerTimingEnabled.
+        * win/WebView.cpp: Set runtime enabled feature based on preference.
+
 2018-05-02  Keith Rollin  <krollin@apple.com>
 
         Add facility for tracking times and results of page and resource loading
index 71185d2..ed7466d 100644 (file)
 #define WebKitInspectorAdditionsEnabledPreferenceKey @"WebKitInspectorAdditionsEnabled"
 #define WebKitAccessibilityObjectModelEnabledPreferenceKey @"WebKitAccessibilityObjectModelEnabled"
 #define WebKitMediaCapabilitiesEnabledPreferenceKey @"WebKitMediaCapabilitiesEnabled"
+#define WebKitServerTimingEnabledPreferenceKey @"WebKitServerTimingEnabled"
index a16022a..5ec00af 100644 (file)
@@ -684,6 +684,7 @@ public:
         @NO, WebKitAccessibilityObjectModelEnabledPreferenceKey,
         @NO, WebKitMediaCapabilitiesEnabledPreferenceKey,
         @NO, WebKitFetchAPIKeepAliveEnabledPreferenceKey,
+        @NO, WebKitServerTimingEnabledPreferenceKey,
         nil];
 
 #if !PLATFORM(IOS)
@@ -3322,6 +3323,16 @@ static NSString *classIBCreatorID = nil;
     [self _setBoolValue:flag forKey:WebKitMediaCapabilitiesEnabledPreferenceKey];
 }
 
+- (BOOL)serverTimingEnabled
+{
+    return [self _boolValueForKey:WebKitServerTimingEnabledPreferenceKey];
+}
+
+- (void)setServerTimingEnabled:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitServerTimingEnabledPreferenceKey];
+}
+
 @end
 
 @implementation WebPreferences (WebInternal)
index c90ce46..0918aaa 100644 (file)
@@ -579,6 +579,9 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification WEBKIT_DEPR
 - (void)setIsSecureContextAttributeEnabled:(BOOL)flag;
 - (BOOL)isSecureContextAttributeEnabled;
 
+- (void)setServerTimingEnabled:(BOOL)flag;
+- (BOOL)serverTimingEnabled;
+
 @property (nonatomic) BOOL visualViewportEnabled;
 @property (nonatomic) BOOL visualViewportAPIEnabled;
 @property (nonatomic) BOOL largeImageAsyncDecodingEnabled;
index 335641d..5ef3042 100644 (file)
@@ -3162,6 +3162,8 @@ static bool needsSelfRetainWhileLoadingQuirk()
 
     settings.setLargeImageAsyncDecodingEnabled([preferences largeImageAsyncDecodingEnabled]);
     settings.setAnimatedImageAsyncDecodingEnabled([preferences animatedImageAsyncDecodingEnabled]);
+
+    RuntimeEnabledFeatures::sharedFeatures().setServerTimingEnabled([preferences serverTimingEnabled]);
 }
 
 static inline IMP getMethod(id o, SEL s)
index f33b471..734f8be 100644 (file)
@@ -227,6 +227,8 @@ interface IWebPreferencesPrivate6 : IWebPreferencesPrivate5
     HRESULT setSpatialNavigationEnabled([in] BOOL enabled);
     HRESULT menuItemElementEnabled([out, retval] BOOL* enabled);
     HRESULT setMenuItemElementEnabled([in] BOOL enabled);
+    HRESULT serverTimingEnabled([out, retval] BOOL* enabled);
+    HRESULT setServerTimingEnabled([in] BOOL enabled);
 }
 
 [uuid(9A49D1DE-53DD-11E8-95E6-003EE1C28AB6)]
index 872b647..08e8473 100644 (file)
 #define WebKitInspectorAdditionsEnabledPreferenceKey "WebKitInspectorAdditionsEnabled"
 
 #define WebKitVisualViewportAPIEnabledPreferenceKey "WebKitVisualViewportAPIEnabled"
+
+#define WebKitServerTimingEnabledPreferenceKey "WebKitServerTimingEnabled"
index a2f05c7..1f40703 100644 (file)
@@ -2231,3 +2231,17 @@ HRESULT WebPreferences::resourceTimingEnabled(_Out_ BOOL* enabled)
     *enabled = boolValueForKey(WebKitResourceTimingEnabledPreferenceKey);
     return S_OK;
 }
+
+HRESULT WebPreferences::serverTimingEnabled(_Out_ BOOL* enabled)
+{
+    if (!enabled)
+        return E_POINTER;
+    *enabled = boolValueForKey(WebKitServerTimingEnabledPreferenceKey);
+    return S_OK;
+}
+
+HRESULT WebPreferences::setServerTimingEnabled(BOOL enabled)
+{
+    setBoolValue(WebKitServerTimingEnabledPreferenceKey, enabled);
+    return S_OK;
+}
index 9d93ff2..370a55c 100644 (file)
@@ -275,6 +275,8 @@ public:
     virtual HRESULT STDMETHODCALLTYPE setSpatialNavigationEnabled(BOOL);
     virtual HRESULT STDMETHODCALLTYPE menuItemElementEnabled(_Out_ BOOL*);
     virtual HRESULT STDMETHODCALLTYPE setMenuItemElementEnabled(BOOL);
+    virtual HRESULT STDMETHODCALLTYPE serverTimingEnabled(_Out_ BOOL*);
+    virtual HRESULT STDMETHODCALLTYPE setServerTimingEnabled(BOOL);
 
     // IWebPreferencesPrivate7
     virtual HRESULT STDMETHODCALLTYPE crossOriginOptionsSupportEnabled(_Out_ BOOL*);
index 64de9ee..15c5c36 100644 (file)
@@ -5578,6 +5578,11 @@ HRESULT WebView::notifyPreferencesChanged(IWebNotification* notification)
         return hr;
     settings.setJavaScriptRuntimeFlags(JSC::RuntimeFlags(javaScriptRuntimeFlags));
 
+    hr = prefsPrivate->serverTimingEnabled(&enabled);
+    if (FAILED(hr))
+        return hr;
+    RuntimeEnabledFeatures::sharedFeatures().setServerTimingEnabled(!!enabled);
+
     return S_OK;
 }
 
index 29b8040..39cc15d 100644 (file)
@@ -1,3 +1,13 @@
+2018-05-11  Charles Vazac  <cvazac@gmail.com>
+
+        Runtime feature flag for Server-Timing
+        https://bugs.webkit.org/show_bug.cgi?id=184758
+
+        Reviewed by Youenn Fablet.
+
+        * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: added ENABLE_SERVER_TIMING.
+        * DumpRenderTree/win/DumpRenderTree.cpp: enable Server Timing
+
 2018-05-11  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         [Win][MiniBrowser] Move WK1 related code into MiniBrowser
index 73d5786..4235365 100644 (file)
@@ -863,6 +863,7 @@ static void enableExperimentalFeatures(WebPreferences* preferences)
     [preferences setVisualViewportAPIEnabled:YES];
     [preferences setColorFilterEnabled:YES];
     [preferences setCrossOriginOptionsSupportEnabled:YES];
+    [preferences setServerTimingEnabled:YES];
 }
 
 // Called before each test.
index 2038d63..9bf7264 100644 (file)
@@ -786,6 +786,7 @@ static void enableExperimentalFeatures(IWebPreferences* preferences)
     // FIXME: SubtleCrypto
     prefsPrivate->setVisualViewportAPIEnabled(TRUE);
     prefsPrivate->setWebAnimationsEnabled(TRUE);
+    prefsPrivate->setServerTimingEnabled(TRUE);
     // FIXME: WebGL2
     // FIXME: WebRTC
     prefsPrivate->setCrossOriginOptionsSupportEnabled(TRUE);
index 68c49c8..3fcfe63 100644 (file)
@@ -771,6 +771,8 @@ void TestController::resetPreferencesToConsistentValues(const TestOptions& optio
 
     WKPreferencesSetRestrictedHTTPResponseAccess(preferences, true);
 
+    WKPreferencesSetServerTimingEnabled(preferences, true);
+
     platformResetPreferencesToConsistentValues();
 }